Index: user/attilio/vmcontention/Makefile.inc1 =================================================================== --- user/attilio/vmcontention/Makefile.inc1 (revision 249698) +++ user/attilio/vmcontention/Makefile.inc1 (revision 249699) @@ -1,1845 +1,1845 @@ # # $FreeBSD$ # # Make command line options: # -DNO_CLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir # -DNO_CLEAN do not clean at all # -DDB_FROM_SRC use the user/group databases in src/etc instead of # the system database when installing. # -DNO_SHARE do not go into share subdir # -DKERNFAST define NO_KERNEL{CONFIG,CLEAN,DEPEND,OBJ} # -DNO_KERNELCONFIG do not run config in ${MAKE} buildkernel # -DNO_KERNELCLEAN do not run ${MAKE} clean in ${MAKE} buildkernel # -DNO_KERNELDEPEND do not run ${MAKE} depend in ${MAKE} buildkernel # -DNO_KERNELOBJ do not run ${MAKE} obj in ${MAKE} buildkernel # -DNO_PORTSUPDATE do not update ports in ${MAKE} update # -DNO_ROOT install without using root privilege # -DNO_DOCUPDATE do not update doc in ${MAKE} update # -DNO_CTF do not run the DTrace CTF conversion tools on built objects # LOCAL_DIRS="list of dirs" to add additional dirs to the SUBDIR list # LOCAL_LIB_DIRS="list of dirs" to add additional dirs to libraries target # LOCAL_MTREE="list of mtree files" to process to allow local directories # to be created before files are installed # LOCAL_TOOL_DIRS="list of dirs" to add additional dirs to the build-tools # list # METALOG="path to metadata log" to write permission and ownership # when NO_ROOT is set. (default: ${DESTDIR}/METALOG) # TARGET="machine" to crossbuild world for a different machine type # TARGET_ARCH= may be required when a TARGET supports multiple endians # BUILDENV_SHELL= shell to launch for the buildenv target (def:/bin/sh) # WORLD_FLAGS= additional flags to pass to make(1) during buildworld # KERNEL_FLAGS= additional flags to pass to make(1) during buildkernel # # The intended user-driven targets are: # buildworld - rebuild *everything*, including glue to help do upgrades # installworld- install everything built by "buildworld" # doxygen - build API documentation of the kernel # update - convenient way to update your source tree (eg: cvsup/cvs) # # Standard targets (not defined here) are documented in the makefiles in # /usr/share/mk. These include: # obj depend all install clean cleandepend cleanobj # You are supposed to define both of these when calling Makefile.inc1 # directly. However, some old scripts don't. Cope for the moment, but # issue a new warning for a transition period. .if defined(TARGET) && !defined(TARGET_ARCH) .warning "You must pass both TARGET and TARGET_ARCH to Makefile.inc1. Setting TARGET_ARCH=${TARGET}." TARGET_ARCH=${TARGET} .endif .if !defined(TARGET) || !defined(TARGET_ARCH) .error "Both TARGET and TARGET_ARCH must be defined." .endif .include .include .include # We must do share/info early so that installation of info `dir' # entries works correctly. Do it first since it is less likely to # grow dependencies on include and lib than vice versa. # # We must do lib/ and libexec/ before bin/, because if installworld # installs a new /bin/sh, the 'make' command will *immediately* # use that new version. And the new (dynamically-linked) /bin/sh # will expect to find appropriate libraries in /lib and /libexec. # SUBDIR= share/info lib libexec SUBDIR+=bin .if ${MK_GAMES} != "no" SUBDIR+=games .endif .if ${MK_CDDL} != "no" SUBDIR+=cddl .endif SUBDIR+=gnu include .if ${MK_KERBEROS} != "no" SUBDIR+=kerberos5 .endif .if ${MK_RESCUE} != "no" SUBDIR+=rescue .endif SUBDIR+=sbin .if ${MK_CRYPT} != "no" SUBDIR+=secure .endif .if !defined(NO_SHARE) SUBDIR+=share .endif SUBDIR+=sys usr.bin usr.sbin .if ${MK_OFED} != "no" SUBDIR+=contrib/ofed .endif # # We must do etc/ last for install/distribute to work. # SUBDIR+=etc # These are last, since it is nice to at least get the base system # rebuilt before you do them. .for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS} .if exists(${.CURDIR}/${_DIR}/Makefile) SUBDIR+= ${_DIR} .endif .endfor .if defined(SUBDIR_OVERRIDE) SUBDIR= ${SUBDIR_OVERRIDE} .endif .if defined(NOCLEAN) NO_CLEAN= ${NOCLEAN} .endif .if defined(NO_CLEANDIR) CLEANDIR= clean cleandepend .else CLEANDIR= cleandir .endif LOCAL_TOOL_DIRS?= BUILDENV_SHELL?=/bin/sh CVS?= cvs CVSFLAGS?= -A -P -d -I! SVN?= svn SVNFLAGS?= -r HEAD SUP?= /usr/bin/csup SUPFLAGS?= -g -L 2 .if defined(SUPHOST) SUPFLAGS+= -h ${SUPHOST} .endif MAKEOBJDIRPREFIX?= /usr/obj .if !defined(OSRELDATE) .if exists(/usr/include/osreldate.h) OSRELDATE!= awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \ /usr/include/osreldate.h .else OSRELDATE= 0 .endif .endif .if !defined(VERSION) VERSION!= uname -srp VERSION+= ${OSRELDATE} .endif KNOWN_ARCHES?= amd64 arm armeb/arm armv6/arm armv6eb/arm i386 i386/pc98 ia64 mips mipsel/mips mips64el/mips mips64/mips mipsn32el/mips mipsn32/mips powerpc powerpc64/powerpc sparc64 .if ${TARGET} == ${TARGET_ARCH} _t= ${TARGET} .else _t= ${TARGET_ARCH}/${TARGET} .endif .for _t in ${_t} .if empty(KNOWN_ARCHES:M${_t}) .error Unknown target ${TARGET_ARCH}:${TARGET}. .endif .endfor .if ${TARGET} == ${MACHINE} TARGET_CPUTYPE?=${CPUTYPE} .else TARGET_CPUTYPE?= .endif .if !empty(TARGET_CPUTYPE) _TARGET_CPUTYPE=${TARGET_CPUTYPE} .else _TARGET_CPUTYPE=dummy .endif _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \ -f /dev/null -m ${.CURDIR}/share/mk -V CPUTYPE .if ${_CPUTYPE} != ${_TARGET_CPUTYPE} .error CPUTYPE global should be set with ?=. .endif .if make(buildworld) BUILD_ARCH!= uname -p .if ${MACHINE_ARCH} != ${BUILD_ARCH} .error To cross-build, set TARGET_ARCH. .endif .endif .if ${MACHINE} == ${TARGET} && ${MACHINE_ARCH} == ${TARGET_ARCH} && !defined(CROSS_BUILD_TESTING) OBJTREE= ${MAKEOBJDIRPREFIX} .else OBJTREE= ${MAKEOBJDIRPREFIX}/${TARGET}.${TARGET_ARCH} .endif WORLDTMP= ${OBJTREE}${.CURDIR}/tmp # /usr/games added for fortune which depend on strfile BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin XPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games STRICTTMPPATH= ${BPATH}:${XPATH} TMPPATH= ${STRICTTMPPATH}:${PATH} # # Avoid running mktemp(1) unless actually needed. # It may not be functional, e.g., due to new ABI # when in the middle of installing over this system. # .if make(distributeworld) || make(installworld) INSTALLTMP!= /usr/bin/mktemp -d -u -t install .endif # # Building a world goes through the following stages # # 1. legacy stage [BMAKE] # This stage is responsible for creating compatibility # shims that are needed by the bootstrap-tools, # build-tools and cross-tools stages. # 1. bootstrap-tools stage [BMAKE] # This stage is responsible for creating programs that # are needed for backward compatibility reasons. They # are not built as cross-tools. # 2. build-tools stage [TMAKE] # This stage is responsible for creating the object # tree and building any tools that are needed during # the build process. # 3. cross-tools stage [XMAKE] # This stage is responsible for creating any tools that # are needed for cross-builds. A cross-compiler is one # of them. # 4. world stage [WMAKE] # This stage actually builds the world. # 5. install stage (optional) [IMAKE] # This stage installs a previously built world. # BOOTSTRAPPING?= 0 # Common environment for world related stages CROSSENV= MAKEOBJDIRPREFIX=${OBJTREE} \ MACHINE_ARCH=${TARGET_ARCH} \ MACHINE=${TARGET} \ CPUTYPE=${TARGET_CPUTYPE} .if ${MK_GROFF} != "no" CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \ GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \ GROFF_TMAC_PATH=${WORLDTMP}/legacy/usr/share/tmac .endif # bootstrap-tools stage BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${BPATH}:${PATH} \ WORLDTMP=${WORLDTMP} \ VERSION="${VERSION}" \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ COMPILER_TYPE=${COMPILER_TYPE} BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ SSP_CFLAGS= \ -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT -DWITHOUT_MAN \ -DNO_PIC -DNO_PROFILE -DNO_SHARED \ -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD # build-tools stage TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \ ${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ DESTDIR= \ BOOTSTRAPPING=${OSRELDATE} \ SSP_CFLAGS= \ -DNO_LINT \ -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF -DEARLY_BUILD # cross-tools stage XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \ -DWITHOUT_GDB # world stage WMAKEENV= ${CROSSENV} \ _SHLIBDIRPREFIX=${WORLDTMP} \ _LDSCRIPTROOT= \ VERSION="${VERSION}" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${TMPPATH} .if ${MK_CDDL} == "no" WMAKEENV+= NO_CTF=1 .endif .if ${CC:T:Mgcc} == "gcc" WMAKE_COMPILER_TYPE= gcc .elif ${CC:T:Mclang} == "clang" WMAKE_COMPILER_TYPE= clang .elif ${MK_CLANG_IS_CC} == "no" WMAKE_COMPILER_TYPE= gcc .else WMAKE_COMPILER_TYPE= clang .endif WMAKEENV+= COMPILER_TYPE=${WMAKE_COMPILER_TYPE} WMAKE= ${WMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 DESTDIR=${WORLDTMP} .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64" # 32 bit world LIB32TMP= ${OBJTREE}${.CURDIR}/lib32 .if ${TARGET_ARCH} == "amd64" .if empty(TARGET_CPUTYPE) LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 .else LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} .endif LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ MACHINE_CPU="i686 mmx sse sse2" LIB32WMAKEFLAGS= \ AS="${AS} --32" \ LD="${LD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" .elif ${TARGET_ARCH} == "powerpc64" .if empty(TARGET_CPUTYPE) LIB32CPUFLAGS= -mcpu=powerpc .else LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} .endif LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc LIB32WMAKEFLAGS= \ LD="${LD} -m elf32ppc_fbsd" .endif LIB32FLAGS= -m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \ -isystem ${LIB32TMP}/usr/include/ \ -L${LIB32TMP}/usr/lib32 \ -B${LIB32TMP}/usr/lib32 # Yes, the flags are redundant. LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ _SHLIBDIRPREFIX=${LIB32TMP} \ _LDSCRIPTROOT=${LIB32TMP} \ VERSION="${VERSION}" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ PATH=${TMPPATH} \ LIBDIR=/usr/lib32 \ SHLIBDIR=/usr/lib32 \ COMPILER_TYPE=${WMAKE_COMPILER_TYPE} LIB32WMAKEFLAGS+= \ CC="${CC} ${LIB32FLAGS}" \ CXX="${CXX} ${LIB32FLAGS}" \ DESTDIR=${LIB32TMP} \ -DCOMPAT_32BIT \ -DLIBRARIES_ONLY \ -DNO_CPU_CFLAGS \ -DNO_CTF \ -DNO_LINT LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \ -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO -DWITHOUT_HTML LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} -DNO_INCS \ ${IMAKE_INSTALL} .endif IMAKEENV= ${CROSSENV:N_LDSCRIPTROOT=*} IMAKE= ${IMAKEENV} ${MAKE} -f Makefile.inc1 \ ${IMAKE_INSTALL} ${IMAKE_MTREE} .if empty(.MAKEFLAGS:M-n) IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \ LD_LIBRARY_PATH=${INSTALLTMP} \ PATH_LOCALE=${INSTALLTMP}/locale IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh .else IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP} .endif .if defined(DB_FROM_SRC) INSTALLFLAGS+= -N ${.CURDIR}/etc MTREEFLAGS+= -N ${.CURDIR}/etc .endif .if defined(NO_ROOT) METALOG?= ${DESTDIR}/${DISTDIR}/METALOG IMAKE+= -DNO_ROOT METALOG=${METALOG} INSTALL_DDIR= ${DESTDIR}/${DISTDIR} INSTALLFLAGS+= -U -M ${METALOG} -D ${INSTALL_DDIR:S://:/:g:C:/$::} MTREEFLAGS+= -W .endif .if defined(DB_FROM_SRC) || defined(NO_ROOT) IMAKE_INSTALL= INSTALL="install ${INSTALLFLAGS}" IMAKE_MTREE= MTREE_CMD="nmtree ${MTREEFLAGS}" .endif # kernel stage KMAKEENV= ${WMAKEENV} KMAKE= ${KMAKEENV} ${MAKE} ${.MAKEFLAGS} ${KERNEL_FLAGS} KERNEL=${INSTKERNNAME} # # buildworld # # Attempt to rebuild the entire system, with reasonable chance of # success, regardless of how old your existing system is. # _worldtmp: .if ${.CURDIR:C/[^,]//g} != "" # The m4 build of sendmail files doesn't like it if ',' is used # anywhere in the path of it's files. @echo @echo "*** Error: path to source tree contains a comma ','" @echo false .endif @echo @echo "--------------------------------------------------------------" @echo ">>> Rebuilding the temporary build tree" @echo "--------------------------------------------------------------" .if !defined(NO_CLEAN) rm -rf ${WORLDTMP} .if defined(LIB32TMP) rm -rf ${LIB32TMP} .endif .else rm -rf ${WORLDTMP}/legacy/usr/include # XXX - These three can depend on any header file. rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/ioctl.c rm -f ${OBJTREE}${.CURDIR}/usr.bin/kdump/kdump_subr.c rm -f ${OBJTREE}${.CURDIR}/usr.bin/truss/ioctl.c .endif .for _dir in \ lib usr legacy/bin legacy/usr mkdir -p ${WORLDTMP}/${_dir} .endfor mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${WORLDTMP}/legacy/usr >/dev/null .if ${MK_GROFF} != "no" mtree -deU -f ${.CURDIR}/etc/mtree/BSD.groff.dist \ -p ${WORLDTMP}/legacy/usr >/dev/null .endif mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${WORLDTMP}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${WORLDTMP}/usr/include >/dev/null ln -sf ${.CURDIR}/sys ${WORLDTMP} .if ${MK_BIND_LIBS} != "no" mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \ -p ${WORLDTMP}/usr/include >/dev/null .endif .for _mtree in ${LOCAL_MTREE} mtree -deU -f ${.CURDIR}/${_mtree} -p ${WORLDTMP} > /dev/null .endfor _legacy: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 1.1: legacy release compatibility shims" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${BMAKE} legacy _bootstrap-tools: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 1.2: bootstrap tools" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${BMAKE} bootstrap-tools _cleanobj: .if !defined(NO_CLEAN) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.1: cleaning up the object tree" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR:S/^/par-/} .if defined(LIB32TMP) ${_+_}cd ${.CURDIR}; ${LIB32WMAKE} -f Makefile.inc1 ${CLEANDIR:S/^/par-/} .endif .endif _obj: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.2: rebuilding the object tree" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} par-obj _build-tools: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.3: build tools" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${TMAKE} build-tools _cross-tools: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 3: cross tools" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${XMAKE} cross-tools _includes: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 4.1: building includes" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} SHARED=symlinks par-includes _libraries: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 4.2: building libraries" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; \ ${WMAKE} -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \ -DWITHOUT_MAN -DNO_PROFILE libraries _depend: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 4.3: make dependencies" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} par-depend everything: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 4.4: building everything" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${WMAKE} par-all .if defined(LIB32TMP) build32: @echo @echo "--------------------------------------------------------------" @echo ">>> stage 5.1: building 32 bit shim libraries" @echo "--------------------------------------------------------------" mkdir -p ${LIB32TMP}/usr/include mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${LIB32TMP}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${LIB32TMP}/usr/include >/dev/null mkdir -p ${WORLDTMP} ln -sf ${.CURDIR}/sys ${WORLDTMP} .for _t in obj includes cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t} cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t} .if ${MK_CDDL} != "no" cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t} .endif cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t} .if ${MK_CRYPT} != "no" cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t} .endif .if ${MK_KERBEROS} != "no" cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t} .endif .endfor .for _dir in usr.bin/lex/lib cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj .endfor .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic cd ${.CURDIR}/${_dir}; \ WORLDTMP=${WORLDTMP} \ MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ MAKEOBJDIRPREFIX=${OBJTREE}/lib32 ${MAKE} SSP_CFLAGS= DESTDIR= \ DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF \ -DEARLY_BUILD build-tools .endfor cd ${.CURDIR}; \ ${LIB32WMAKE} -f Makefile.inc1 libraries .for _t in obj depend all cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \ DIRPRFX=libexec/rtld-elf/ ${_t} cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \ DIRPRFX=usr.bin/ldd ${_t} .endfor distribute32 install32: cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .if ${MK_CDDL} != "no" cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .if ${MK_CRYPT} != "no" cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif .if ${MK_KERBEROS} != "no" cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif cd ${.CURDIR}/libexec/rtld-elf; \ PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//} cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//} .endif WMAKE_TGTS= .if !defined(SUBDIR_OVERRIDE) WMAKE_TGTS+= _worldtmp _legacy _bootstrap-tools .endif WMAKE_TGTS+= _cleanobj _obj _build-tools .if !defined(SUBDIR_OVERRIDE) WMAKE_TGTS+= _cross-tools .endif WMAKE_TGTS+= _includes _libraries _depend everything .if defined(LIB32TMP) && ${MK_LIB32} != "no" WMAKE_TGTS+= build32 .endif buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue .ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue buildworld_prologue: @echo "--------------------------------------------------------------" @echo ">>> World build started on `LC_ALL=C date`" @echo "--------------------------------------------------------------" buildworld_epilogue: @echo @echo "--------------------------------------------------------------" @echo ">>> World build completed on `LC_ALL=C date`" @echo "--------------------------------------------------------------" # # We need to have this as a target because the indirection between Makefile # and Makefile.inc1 causes the correct PATH to be used, rather than a # modification of the current environment's PATH. In addition, we need # to quote multiword values. # buildenvvars: @echo ${WMAKEENV:Q} buildenv: @echo Entering world for ${TARGET_ARCH}:${TARGET} @cd ${.CURDIR} && env ${WMAKEENV} ${BUILDENV_SHELL} || true TOOLCHAIN_TGTS= ${WMAKE_TGTS:N_depend:Neverything:Nbuild32} toolchain: ${TOOLCHAIN_TGTS} kernel-toolchain: ${TOOLCHAIN_TGTS:N_includes:N_libraries} # # installcheck # # Checks to be sure system is ready for installworld/installkernel. # installcheck: # # Require DESTDIR to be set if installing for a different architecture or # using the user/group database in the source tree. # .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${TARGET} != ${MACHINE} || \ defined(DB_FROM_SRC) .if !make(distributeworld) installcheck: installcheck_DESTDIR installcheck_DESTDIR: .if !defined(DESTDIR) || empty(DESTDIR) @echo "ERROR: Please set DESTDIR!"; \ false .endif .endif .endif .if !defined(DB_FROM_SRC) # # Check for missing UIDs/GIDs. # CHECK_UIDS= auditdistd CHECK_GIDS= audit .if ${MK_SENDMAIL} != "no" CHECK_UIDS+= smmsp CHECK_GIDS+= smmsp .endif .if ${MK_PF} != "no" CHECK_UIDS+= proxy CHECK_GIDS+= proxy authpf .endif installcheck: installcheck_UGID installcheck_UGID: .for uid in ${CHECK_UIDS} @if ! `id -u ${uid} >/dev/null 2>&1`; then \ echo "ERROR: Required ${uid} user is missing, see /usr/src/UPDATING."; \ false; \ fi .endfor .for gid in ${CHECK_GIDS} @if ! `find / -prune -group ${gid} >/dev/null 2>&1`; then \ echo "ERROR: Required ${gid} group is missing, see /usr/src/UPDATING."; \ false; \ fi .endfor .endif # # Required install tools to be saved in a scratch dir for safety. # .if ${MK_INFO} != "no" _install-info= install-info .endif .if ${MK_ZONEINFO} != "no" _zoneinfo= zic tzsetup .endif .if exists(/usr/sbin/nmtree) _nmtree_itools= nmtree .endif ITOOLS= [ awk cap_mkdb cat chflags chmod chown \ date echo egrep find grep id install ${_install-info} \ ln lockf make mkdir mtree ${_nmtree_itools} mv pwd_mkdb \ rm sed sh sysctl test true uname wc ${_zoneinfo} # # distributeworld # # Distributes everything compiled by a `buildworld'. # # installworld # # Installs everything compiled by a 'buildworld'. # # Non-base distributions produced by the base system EXTRA_DISTRIBUTIONS= doc .if ${MK_GAMES} != "no" EXTRA_DISTRIBUTIONS+= games .endif .if defined(LIB32TMP) && ${MK_LIB32} != "no" EXTRA_DISTRIBUTIONS+= lib32 .endif MTREE_MAGIC?= mtree 2.0 distributeworld installworld: installcheck mkdir -p ${INSTALLTMP} progs=$$(for prog in ${ITOOLS}; do \ if progpath=`which $$prog`; then \ echo $$progpath; \ else \ echo "Required tool $$prog not found in PATH." >&2; \ exit 1; \ fi; \ done); \ libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \ while read line; do \ set -- $$line; \ if [ "$$2 $$3" != "not found" ]; then \ echo $$2; \ else \ echo "Required library $$1 not found." >&2; \ exit 1; \ fi; \ done); \ cp $$libs $$progs ${INSTALLTMP} cp -R $${PATH_LOCALE:-"/usr/share/locale"} ${INSTALLTMP}/locale .if defined(NO_ROOT) echo "#${MTREE_MAGIC}" > ${METALOG} .endif .if make(distributeworld) .for dist in ${EXTRA_DISTRIBUTIONS} -mkdir ${DESTDIR}/${DISTDIR}/${dist} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ -p ${DESTDIR}/${DISTDIR}/${dist} >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null .if defined(NO_ROOT) ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.root.dist | \ sed -e 's#^\./#./${dist}/#' >> ${METALOG} ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.usr.dist | \ sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG} ${IMAKEENV} nmtree -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \ sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG} .endif .endfor -mkdir ${DESTDIR}/${DISTDIR}/base cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \ DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \ LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs .endif ${_+_}cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}; \ ${IMAKEENV} rm -rf ${INSTALLTMP} .if make(distributeworld) .for dist in ${EXTRA_DISTRIBUTIONS} find ${DESTDIR}/${DISTDIR}/${dist} -empty -delete .endfor .if defined(NO_ROOT) .for dist in base ${EXTRA_DISTRIBUTIONS} @# For each file that exists in this dist, print the corresponding @# line from the METALOG. This relies on the fact that @# a line containing only the filename will sort immediatly before @# the relevant mtree line. cd ${DESTDIR}/${DISTDIR}; \ find ./${dist} | sort -u ${METALOG} - | \ awk 'BEGIN { print "#${MTREE_MAGIC}" } !/ type=/ { file = $$1 } / type=/ { if ($$1 == file) { sub(/^\.\/${dist}\//, "./"); print } }' > \ ${DESTDIR}/${DISTDIR}/${dist}.meta .endfor .endif .endif packageworld: .for dist in base ${EXTRA_DISTRIBUTIONS} .if defined(NO_ROOT) ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz \ @${DESTDIR}/${DISTDIR}/${dist}.meta .else ${_+_}cd ${DESTDIR}/${DISTDIR}/${dist}; \ tar cvJf ${DESTDIR}/${DISTDIR}/${dist}.txz . .endif .endfor # # reinstall # # If you have a build server, you can NFS mount the source and obj directories # and do a 'make reinstall' on the *client* to install new binaries from the # most recent server build. # reinstall: @echo "--------------------------------------------------------------" @echo ">>> Making hierarchy" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 \ LOCAL_MTREE=${LOCAL_MTREE} hierarchy @echo @echo "--------------------------------------------------------------" @echo ">>> Installing everything" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install .if defined(LIB32TMP) && ${MK_LIB32} != "no" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 install32 .endif redistribute: @echo "--------------------------------------------------------------" @echo ">>> Distributing everything" @echo "--------------------------------------------------------------" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute .if defined(LIB32TMP) && ${MK_LIB32} != "no" ${_+_}cd ${.CURDIR}; ${MAKE} -f Makefile.inc1 distribute32 \ DISTRIBUTION=lib32 .endif distrib-dirs distribution: cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ ${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET} # # buildkernel and installkernel # # Which kernels to build and/or install is specified by setting # KERNCONF. If not defined a GENERIC kernel is built/installed. # Only the existing (depending TARGET) config files are used # for building kernels and only the first of these is designated # as the one being installed. # # Note that we have to use TARGET instead of TARGET_ARCH when # we're in kernel-land. Since only TARGET_ARCH is (expected) to # be set to cross-build, we have to make sure TARGET is set # properly. .if defined(KERNFAST) NO_KERNELCLEAN= t NO_KERNELCONFIG= t NO_KERNELDEPEND= t NO_KERNELOBJ= t # Shortcut for KERNCONF=Blah -DKERNFAST is now KERNFAST=Blah .if !defined(KERNCONF) && ${KERNFAST} != "1" KERNCONF=${KERNFAST} .endif .endif .if !defined(KERNCONF) && defined(KERNEL) KERNCONF= ${KERNEL} KERNWARN= .else .if ${TARGET_ARCH} == "powerpc64" KERNCONF?= GENERIC64 .else KERNCONF?= GENERIC .endif .endif INSTKERNNAME?= kernel KERNSRCDIR?= ${.CURDIR}/sys KRNLCONFDIR= ${KERNSRCDIR}/${TARGET}/conf KRNLOBJDIR= ${OBJTREE}${KERNSRCDIR} KERNCONFDIR?= ${KRNLCONFDIR} BUILDKERNELS= INSTALLKERNEL= .for _kernel in ${KERNCONF} .if exists(${KERNCONFDIR}/${_kernel}) BUILDKERNELS+= ${_kernel} .if empty(INSTALLKERNEL) INSTALLKERNEL= ${_kernel} .endif .endif .endfor # # buildkernel # # Builds all kernels defined by BUILDKERNELS. # buildkernel: .if empty(BUILDKERNELS) @echo "ERROR: Missing kernel configuration file(s) (${KERNCONF})."; \ false .endif .if defined(KERNWARN) @echo "--------------------------------------------------------------" @echo ">>> WARNING: KERNEL= setting should be changed to KERNCONF=" @echo "--------------------------------------------------------------" @sleep 3 .endif @echo .for _kernel in ${BUILDKERNELS} @echo "--------------------------------------------------------------" @echo ">>> Kernel build for ${_kernel} started on `LC_ALL=C date`" @echo "--------------------------------------------------------------" @echo "===> ${_kernel}" mkdir -p ${KRNLOBJDIR} .if !defined(NO_KERNELCONFIG) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 1: configuring the kernel" @echo "--------------------------------------------------------------" cd ${KRNLCONFDIR}; \ PATH=${TMPPATH} \ config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \ ${KERNCONFDIR}/${_kernel} .endif .if !defined(NO_CLEAN) && !defined(NO_KERNELCLEAN) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.1: cleaning up the object tree" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} ${CLEANDIR} .endif .if !defined(NO_KERNELOBJ) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.2: rebuilding the object tree" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} obj .endif @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2.3: build tools" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${_kernel}; \ PATH=${BPATH}:${PATH} \ MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \ ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD \ -f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile # XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case. .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules) .for target in obj depend all cd ${KERNSRCDIR}/modules/aic7xxx/aicasm; \ PATH=${BPATH}:${PATH} \ MAKEOBJDIRPREFIX=${KRNLOBJDIR}/${_kernel}/modules \ ${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF -DEARLY_BUILD ${target} .endfor .endif .if !defined(NO_KERNELDEPEND) @echo @echo "--------------------------------------------------------------" @echo ">>> stage 3.1: making dependencies" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} depend -DNO_MODULES_OBJ .endif @echo @echo "--------------------------------------------------------------" @echo ">>> stage 3.2: building everything" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${_kernel}; ${KMAKE} all -DNO_MODULES_OBJ @echo "--------------------------------------------------------------" @echo ">>> Kernel build for ${_kernel} completed on `LC_ALL=C date`" @echo "--------------------------------------------------------------" .endfor # # installkernel, etc. # # Install the kernel defined by INSTALLKERNEL # installkernel installkernel.debug \ reinstallkernel reinstallkernel.debug: installcheck .if empty(INSTALLKERNEL) @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ false .endif @echo "--------------------------------------------------------------" @echo ">>> Installing kernel ${INSTALLKERNEL}" @echo "--------------------------------------------------------------" cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ ${CROSSENV} PATH=${TMPPATH} \ ${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//} distributekernel distributekernel.debug: .if empty(INSTALLKERNEL) @echo "ERROR: No kernel \"${KERNCONF}\" to install."; \ false .endif cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \ ${CROSSENV} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \ DESTDIR=${DESTDIR}/${DISTDIR}/kernel \ ${.TARGET:S/distributekernel/install/} .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} cd ${KRNLOBJDIR}/${_kernel}; \ ${CROSSENV} PATH=${TMPPATH} ${MAKE} \ KERNEL=${INSTKERNNAME}.${_kernel} \ DESTDIR=${DESTDIR}/${DISTDIR}/kernel.${_kernel} \ ${.TARGET:S/distributekernel/install/} .endfor packagekernel: cd ${DESTDIR}/${DISTDIR}/kernel; \ tar cvJf ${DESTDIR}/${DISTDIR}/kernel.txz . .for _kernel in ${BUILDKERNELS:S/${INSTALLKERNEL}//} cd ${DESTDIR}/${DISTDIR}/kernel.${_kernel}; \ tar cvJf ${DESTDIR}/${DISTDIR}/kernel.${_kernel}.txz . .endfor # # doxygen # # Build the API documentation with doxygen # doxygen: @if [ ! -x `/usr/bin/which doxygen` ]; then \ echo "You need doxygen (devel/doxygen) to generate the API documentation of the kernel." | /usr/bin/fmt; \ exit 1; \ fi cd ${.CURDIR}/tools/kerneldoc/subsys && ${MAKE} obj all # # update # # Update the source tree(s), by running cvsup/cvs/svn to update to the # latest copy. # update: .if defined(SUP_UPDATE) @echo "--------------------------------------------------------------" @echo ">>> Running ${SUP}" @echo "--------------------------------------------------------------" @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" @echo "!! Update methods with ${SUP} are deprecated." @echo "!! Please see http://www.freebsd.org/handbook/svn.html" @echo "!! and convert your update method to SVN_UPDATE or" @echo "!! freebsd-update(8)." @echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" @sleep 5 .if defined(SUPFILE) @${SUP} ${SUPFLAGS} ${SUPFILE} .endif .if defined(SUPFILE1) @${SUP} ${SUPFLAGS} ${SUPFILE1} .endif .if defined(SUPFILE2) @${SUP} ${SUPFLAGS} ${SUPFILE2} .endif .if defined(PORTSSUPFILE) && !defined(NO_PORTSUPDATE) @${SUP} ${SUPFLAGS} ${PORTSSUPFILE} .endif .if defined(DOCSUPFILE) && !defined(NO_DOCUPDATE) @${SUP} ${SUPFLAGS} ${DOCSUPFILE} .endif .endif .if defined(CVS_UPDATE) @cd ${.CURDIR} ; \ if [ -d CVS ] ; then \ echo "--------------------------------------------------------------" ; \ echo ">>> Updating ${.CURDIR} from CVS repository" ${CVSROOT} ; \ echo "--------------------------------------------------------------" ; \ echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \ echo "!! Update methods with CVS are deprecated." ; \ echo "!! Please see http://www.freebsd.org/handbook/svn.html" ; \ echo "!! and convert your update method to SVN_UPDATE or" ; \ echo "!! freebsd-update(8)." ; \ echo "!! WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!" ; \ sleep 5 ; \ echo ${CVS} -R -q update ${CVSFLAGS} ; \ ${CVS} -R -q update ${CVSFLAGS} ; \ fi .endif .if defined(SVN_UPDATE) @cd ${.CURDIR} ; \ if [ -d .svn ] ; then \ echo "--------------------------------------------------------------" ; \ echo ">>> Updating ${.CURDIR} using Subversion" ; \ echo "--------------------------------------------------------------" ; \ echo ${SVN} update ${SVNFLAGS} ; \ ${SVN} update ${SVNFLAGS} ; \ fi .endif # # ------------------------------------------------------------------------ # # From here onwards are utility targets used by the 'make world' and # related targets. If your 'world' breaks, you may like to try to fix # the problem and manually run the following targets to attempt to # complete the build. Beware, this is *not* guaranteed to work, you # need to have a pretty good grip on the current state of the system # to attempt to manually finish it. If in doubt, 'make world' again. # # # legacy: Build compatibility shims for the next three targets # legacy: .if ${BOOTSTRAPPING} < 700055 && ${BOOTSTRAPPING} != 0 @echo "ERROR: Source upgrades from versions prior to 7.0 not supported."; \ false .endif .for _tool in tools/build ${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,depend,all,install)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \ ${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install .endfor # # bootstrap-tools: Build tools needed for compatibility # .if ${MK_GAMES} != "no" _strfile= games/fortune/strfile .endif .if ${MK_CXX} != "no" _gperf= gnu/usr.bin/gperf .endif .if ${MK_GROFF} != "no" _groff= gnu/usr.bin/groff .endif .if ${BOOTSTRAPPING} < 800022 _ar= usr.bin/ar .endif .if ${BOOTSTRAPPING} < 800013 _mklocale= usr.bin/mklocale .endif .if ${BOOTSTRAPPING} < 900002 _sed= usr.bin/sed .endif .if ${BOOTSTRAPPING} < 900006 _lex= usr.bin/lex .endif .if ${BOOTSTRAPPING} < 1000013 _yacc= lib/liby \ usr.bin/yacc .endif .if ${BOOTSTRAPPING} < 1000026 _nmtree= lib/libnetbsd \ usr.sbin/nmtree .endif .if ${BOOTSTRAPPING} < 1000027 _cat= bin/cat .endif .if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041 _awk= usr.bin/awk .endif .if ${MK_BSNMP} != "no" && !exists(/usr/sbin/gensnmptree) _gensnmptree= usr.sbin/bsnmpd/gensnmptree .endif .if ${MK_CLANG} != "no" _clang_tblgen= \ lib/clang/libllvmsupport \ lib/clang/libllvmtablegen \ usr.bin/clang/tblgen \ usr.bin/clang/clang-tblgen .endif # dtrace tools are required for older bootstrap env and cross-build .if ${MK_CDDL} != "no" && \ ((${BOOTSTRAPPING} < 800038 && \ !(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)) \ || (${MACHINE} != ${TARGET} || ${MACHINE_ARCH} != ${TARGET_ARCH})) _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \ lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge .endif # Default to building the BSDL DTC, but build the GPL one if users explicitly # request it. _dtc= usr.bin/dtc .if ${MK_GPL_DTC} != "no" _dtc= gnu/usr.bin/dtc .endif .if ${MK_KERBEROS} != "no" _kerberos5_bootstrap_tools= \ kerberos5/tools/make-roken \ kerberos5/lib/libroken \ kerberos5/lib/libvers \ kerberos5/tools/asn1_compile \ kerberos5/tools/slc .endif # Please document (add comment) why something is in 'bootstrap-tools'. # Try to bound the building of the bootstrap-tool to just the # FreeBSD versions that need the tool built at this stage of the build. bootstrap-tools: .for _tool in \ ${_clang_tblgen} \ ${_kerberos5_bootstrap_tools} \ ${_dtrace_tools} \ ${_strfile} \ ${_gperf} \ ${_groff} \ ${_ar} \ ${_dtc} \ ${_awk} \ ${_cat} \ usr.bin/lorder \ usr.bin/makewhatis \ ${_mklocale} \ usr.bin/rpcgen \ ${_sed} \ ${_yacc} \ ${_lex} \ lib/libmd \ usr.bin/xinstall \ ${_gensnmptree} \ usr.sbin/config \ ${_nmtree} ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install .endfor # # build-tools: Build special purpose build tools # .if defined(MODULES_WITH_WORLD) && exists(${KERNSRCDIR}/modules) _aicasm= sys/modules/aic7xxx/aicasm .endif .if !defined(NO_SHARE) _share= share/syscons/scrnmaps .endif .if ${MK_GCC} != "no" _gcc_tools= gnu/usr.bin/cc/cc_tools .endif .if ${MK_RESCUE} != "no" _rescue= rescue/rescue .endif build-tools: .for _tool in \ bin/csh \ bin/sh \ ${_rescue} \ ${LOCAL_TOOL_DIRS} \ lib/ncurses/ncurses \ lib/ncurses/ncursesw \ ${_share} \ ${_aicasm} \ usr.bin/awk \ lib/libmagic \ usr.bin/mkesdb_static \ usr.bin/mkcsmapper_static ${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ build-tools .endfor .for _tool in \ ${_gcc_tools} ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ all .endfor # # cross-tools: Build cross-building tools # .if ${TARGET_ARCH} != ${MACHINE_ARCH} || ${BOOTSTRAPPING} < 800035 .if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" _btxld= usr.sbin/btxld .endif .endif .if ${TARGET_ARCH} != ${MACHINE_ARCH} .if ${MK_RESCUE} != "no" || defined(RELEASEDIR) _crunchide= usr.sbin/crunch/crunchide .endif .if ${TARGET_ARCH} == "i386" && defined(RELEASEDIR) _kgzip= usr.sbin/kgzip .endif .endif .if ${MK_BINUTILS} != "no" _binutils= gnu/usr.bin/binutils .endif .if ${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") _clang= usr.bin/clang _clang_libs= lib/clang .endif .if ${MK_GCC} != "no" && (${MK_CLANG_IS_CC} == "no" || ${TARGET} == "pc98") _cc= gnu/usr.bin/cc .endif cross-tools: .for _tool in \ ${_clang_libs} \ ${_clang} \ ${_binutils} \ ${_cc} \ usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \ ${_btxld} \ ${_crunchide} \ ${_kgzip} ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ cd ${.CURDIR}/${_tool}; \ ${MAKE} DIRPRFX=${_tool}/ obj; \ ${MAKE} DIRPRFX=${_tool}/ depend; \ ${MAKE} DIRPRFX=${_tool}/ all; \ ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install .endfor # # hierarchy - ensure that all the needed directories are present # hierarchy hier: .if defined(NO_ROOT) cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} \ -DNO_ROOT METALOG=${METALOG} distrib-dirs .else cd ${.CURDIR}/etc; ${MAKE} LOCAL_MTREE=${LOCAL_MTREE} distrib-dirs .endif # # libraries - build all libraries, and install them under ${DESTDIR}. # # The list of libraries with dependents (${_prebuild_libs}) and their # interdependencies (__L) are built automatically by the # ${.CURDIR}/tools/make_libdeps.sh script. # libraries: cd ${.CURDIR}; \ ${MAKE} -f Makefile.inc1 _prereq_libs; \ ${MAKE} -f Makefile.inc1 _startup_libs; \ ${MAKE} -f Makefile.inc1 _prebuild_libs; \ ${MAKE} -f Makefile.inc1 _generic_libs; # # static libgcc.a prerequisite for shared libc # _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt # These dependencies are not automatically generated: # # gnu/lib/csu, gnu/lib/libgcc, lib/csu and lib/libc must be built before # all shared libraries for ELF. # _startup_libs= gnu/lib/csu .if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf) _startup_libs+= lib/csu/${MACHINE_ARCH}-elf .elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}) _startup_libs+= lib/csu/${MACHINE_ARCH} .else _startup_libs+= lib/csu/${MACHINE_CPUARCH} .endif _startup_libs+= gnu/lib/libgcc _startup_libs+= lib/libcompiler_rt _startup_libs+= lib/libc .if ${MK_LIBCPLUSPLUS} != "no" _startup_libs+= lib/libcxxrt .endif gnu/lib/libgcc__L: lib/libc__L .if ${MK_LIBCPLUSPLUS} != "no" lib/libcxxrt__L: gnu/lib/libgcc__L .endif _prebuild_libs= ${_kerberos5_lib_libasn1} \ ${_kerberos5_lib_libhdb} \ ${_kerberos5_lib_libheimbase} \ ${_kerberos5_lib_libheimntlm} \ ${_kerberos5_lib_libheimsqlite} \ ${_kerberos5_lib_libheimipcc} \ ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ ${_kerberos5_lib_libwind} \ ${_lib_atf_libatf_c} \ lib/libbz2 ${_libcom_err} lib/libcrypt \ - lib/libexpat \ + lib/libelf lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/libopie lib/libpam ${_lib_libthr} \ lib/libradius lib/libsbuf lib/libtacplus \ ${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \ ${_cddl_lib_libzfs_core} \ lib/libutil ${_lib_libypclnt} lib/libz lib/msun \ ${_secure_lib_libcrypto} ${_secure_lib_libssh} \ ${_secure_lib_libssl} .if ${MK_ATF} != "no" _lib_atf_libatf_c= lib/atf/libatf-c .endif .if ${MK_LIBTHR} != "no" _lib_libthr= lib/libthr .endif .if ${MK_OFED} != "no" _ofed_lib= contrib/ofed/usr.lib/ .endif _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib} .for _DIR in ${LOCAL_LIB_DIRS} .if exists(${.CURDIR}/${_DIR}/Makefile) _generic_libs+= ${_DIR} .endif .endfor lib/libopie__L lib/libtacplus__L: lib/libmd__L .if ${MK_CDDL} != "no" _cddl_lib_libumem= cddl/lib/libumem _cddl_lib_libnvpair= cddl/lib/libnvpair _cddl_lib_libzfs_core= cddl/lib/libzfs_core _cddl_lib= cddl/lib cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L .endif .if ${MK_CRYPT} != "no" .if ${MK_OPENSSL} != "no" _secure_lib_libcrypto= secure/lib/libcrypto _secure_lib_libssl= secure/lib/libssl lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L .if ${MK_OPENSSH} != "no" _secure_lib_libssh= secure/lib/libssh secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L .if ${MK_KERBEROS_SUPPORT} != "no" secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \ kerberos5/lib/libhx509__L kerberos5/lib/libasn1__L lib/libcom_err__L \ lib/libmd__L kerberos5/lib/libroken__L .endif .endif .endif _secure_lib= secure/lib .endif .if ${MK_KERBEROS} != "no" kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \ kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \ kerberos5/lib/libroken__L lib/libcom_err__L kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ secure/lib/libcrypto__L kerberos5/lib/libroken__L kerberos5/lib/libwind__L kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \ kerberos5/lib/libroken__L kerberos5/lib/libwind__L \ kerberos5/lib/libheimbase__L kerberos5/lib/libheimipcc__L kerberos5/lib/libroken__L: lib/libcrypt__L kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L kerberos5/lib/libheimbase__L: lib/libthr__L kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L kerberos5/lib/libheimsqlite__L: lib/libthr__L .endif .if ${MK_GSSAPI} != "no" _lib_libgssapi= lib/libgssapi .endif .if ${MK_IPX} != "no" _lib_libipx= lib/libipx .endif .if ${MK_KERBEROS} != "no" _kerberos5_lib= kerberos5/lib _kerberos5_lib_libasn1= kerberos5/lib/libasn1 _kerberos5_lib_libhdb= kerberos5/lib/libhdb _kerberos5_lib_libheimbase= kerberos5/lib/libheimbase _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5 _kerberos5_lib_libhx509= kerberos5/lib/libhx509 _kerberos5_lib_libroken= kerberos5/lib/libroken _kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm _kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite _kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc _kerberos5_lib_libwind= kerberos5/lib/libwind _libcom_err= lib/libcom_err .endif .if ${MK_NIS} != "no" _lib_libypclnt= lib/libypclnt .endif .if ${MK_OPENSSL} == "no" lib/libradius__L: lib/libmd__L .endif .for _lib in ${_prereq_libs} ${_lib}__PL: .PHONY .if exists(${.CURDIR}/${_lib}) ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ cd ${.CURDIR}/${_lib}; \ ${MAKE} DIRPRFX=${_lib}/ obj; \ ${MAKE} DIRPRFX=${_lib}/ depend; \ ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ all; \ ${MAKE} -DNO_PROFILE -DNO_PIC DIRPRFX=${_lib}/ install .endif .endfor .for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs} ${_lib}__L: .PHONY .if exists(${.CURDIR}/${_lib}) ${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \ cd ${.CURDIR}/${_lib}; \ ${MAKE} DIRPRFX=${_lib}/ obj; \ ${MAKE} DIRPRFX=${_lib}/ depend; \ ${MAKE} DIRPRFX=${_lib}/ all; \ ${MAKE} DIRPRFX=${_lib}/ install .endif .endfor # libpam is special: we need to build static PAM modules before # static PAM library, and dynamic PAM library before dynamic PAM # modules. lib/libpam__L: .PHONY ${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \ cd ${.CURDIR}/lib/libpam; \ ${MAKE} DIRPRFX=lib/libpam/ obj; \ ${MAKE} DIRPRFX=lib/libpam/ depend; \ ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \ ${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install _prereq_libs: ${_prereq_libs:S/$/__PL/} _startup_libs: ${_startup_libs:S/$/__L/} _prebuild_libs: ${_prebuild_libs:S/$/__L/} _generic_libs: ${_generic_libs:S/$/__L/} .for __target in all clean cleandepend cleandir depend includes obj .for entry in ${SUBDIR} ${entry}.${__target}__D: .PHONY ${_+_}@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \ ${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \ edir=${entry}.${MACHINE_ARCH}; \ cd ${.CURDIR}/$${edir}; \ else \ ${ECHODIR} "===> ${DIRPRFX}${entry} (${__target})"; \ edir=${entry}; \ cd ${.CURDIR}/$${edir}; \ fi; \ ${MAKE} ${__target} DIRPRFX=${DIRPRFX}$${edir}/ .endfor par-${__target}: ${SUBDIR:S/$/.${__target}__D/} .endfor .include .if make(check-old) || make(check-old-dirs) || \ make(check-old-files) || make(check-old-libs) || \ make(delete-old) || make(delete-old-dirs) || \ make(delete-old-files) || make(delete-old-libs) # # check for / delete old files section # .include "ObsoleteFiles.inc" OLD_LIBS_MESSAGE="Please be sure no application still uses those libraries, \ else you can not start such an application. Consult UPDATING for more \ information regarding how to cope with the removal/revision bump of a \ specific library." .if !defined(BATCH_DELETE_OLD_FILES) RM_I=-i .else RM_I=-v .endif delete-old-files: @echo ">>> Removing old files (only deletes safe to delete libs)" # Ask for every old file if the user really wants to remove it. # It's annoying, but better safe than sorry. # NB: We cannot pass the list of OLD_FILES as a parameter because the # argument list will get too long. Using .for/.endfor make "loops" will make # the Makefile parser segfault. @exec 3<&0; \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done # Remove catpages without corresponding manpages. @exec 3<&0; \ find ${DESTDIR}/usr/share/man/cat* ! -type d | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ rm ${RM_I} $${catpage} <&3; \ fi; \ done @echo ">>> Old files removed" check-old-files: @echo ">>> Checking for old files" @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" | xargs -n1 | \ while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ done # Check for catpages without corresponding manpages. @find ${DESTDIR}/usr/share/man/cat* ! -type d | \ sed -ep -e's:${DESTDIR}/usr/share/man/cat:${DESTDIR}/usr/share/man/man:' | \ while read catpage; do \ read manpage; \ if [ ! -e "$${manpage}" ]; then \ echo $${catpage}; \ fi; \ done delete-old-libs: @echo ">>> Removing old libraries" @echo "${OLD_LIBS_MESSAGE}" | fmt @exec 3<&0; \ ${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_LIBS | xargs -n1 | \ while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ chflags noschg "${DESTDIR}/$${file}" 2>/dev/null || true; \ rm ${RM_I} "${DESTDIR}/$${file}" <&3; \ fi; \ done @echo ">>> Old libraries removed" check-old-libs: @echo ">>> Checking for old libraries" @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_LIBS | xargs -n1 | \ while read file; do \ if [ -f "${DESTDIR}/$${file}" -o -L "${DESTDIR}/$${file}" ]; then \ echo "${DESTDIR}/$${file}"; \ fi; \ done delete-old-dirs: @echo ">>> Removing old directories" @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_DIRS | xargs -n1 | \ while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ rmdir -v "${DESTDIR}/$${dir}" || true; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ fi; \ done @echo ">>> Old directories removed" check-old-dirs: @echo ">>> Checking for old directories" @${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \ -V OLD_DIRS | xargs -n1 | \ while read dir; do \ if [ -d "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir}"; \ elif [ -L "${DESTDIR}/$${dir}" ]; then \ echo "${DESTDIR}/$${dir} is a link, please remove everything manually."; \ fi; \ done delete-old: delete-old-files delete-old-dirs @echo "To remove old libraries run '${MAKE} delete-old-libs'." check-old: check-old-files check-old-libs check-old-dirs @echo "To remove old files and directories run '${MAKE} delete-old'." @echo "To remove old libraries run '${MAKE} delete-old-libs'." .endif # # showconfig - show build configuration. # showconfig: @${MAKE} -n -f bsd.own.mk -V dummy -dg1 2>&1 | grep ^MK_ | sort .if !empty(KRNLOBJDIR) && !empty(KERNCONF) DTBOUTPUTPATH= ${KRNLOBJDIR}/${KERNCONF}/ .if !defined(FDT_DTS_FILE) || empty(FDT_DTS_FILE) .if exists(${KERNCONFDIR}/${KERNCONF}) FDT_DTS_FILE!= awk 'BEGIN {FS="="} /^makeoptions[[:space:]]+FDT_DTS_FILE/ {print $$2}' \ ${KERNCONFDIR}/${KERNCONF} ; echo .endif .endif .endif .if !defined(DTBOUTPUTPATH) || !exists(${DTBOUTPUTPATH}) DTBOUTPUTPATH= ${.CURDIR} .endif # # Build 'standalone' Device Tree Blob # builddtb: @if [ "${FDT_DTS_FILE}" = "" ]; then \ echo "ERROR: FDT_DTS_FILE must be specified!"; \ exit 1; \ fi; \ if [ ! -f ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ]; then \ echo "ERROR: Specified DTS file (${FDT_DTS_FILE}) does not \ exist!"; \ exit 1; \ fi; \ if [ "${DTBOUTPUTPATH}" = "${.CURDIR}" ]; then \ echo "WARNING: DTB will be placed in the current working \ directory"; \ fi @PATH=${TMPPATH} \ dtc -O dtb -o \ ${DTBOUTPUTPATH}/`echo ${FDT_DTS_FILE} | cut -d. -f1`.dtb -b 0 \ -p 1024 ${.CURDIR}/sys/boot/fdt/dts/${FDT_DTS_FILE} ############### .if defined(XDEV) && defined(XDEV_ARCH) .if ${XDEV} == ${MACHINE} && ${XDEV_ARCH} == ${MACHINE_ARCH} XDEV_CPUTYPE?=${CPUTYPE} .else XDEV_CPUTYPE?=${TARGET_CPUTYPE} .endif NOFUN=-DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT \ -DWITHOUT_MAN -DWITHOUT_NLS -DNO_PROFILE \ -DWITHOUT_KERBEROS -DWITHOUT_RESCUE -DNO_WARNS \ TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \ CPUTYPE=${XDEV_CPUTYPE} XDDIR=${XDEV_ARCH}-freebsd XDTP=/usr/${XDDIR} CDBENV=MAKEOBJDIRPREFIX=${MAKEOBJDIRPREFIX}/${XDDIR} \ INSTALL="sh ${.CURDIR}/tools/install.sh" CDENV= ${CDBENV} \ _SHLIBDIRPREFIX=${XDDESTDIR} \ TOOLS_PREFIX=${XDDESTDIR} CD2CFLAGS=-isystem ${XDDESTDIR}/usr/include -L${XDDESTDIR}/usr/lib \ -B${XDDESTDIR}/usr/lib CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" \ MACHINE=${XDEV} MACHINE_ARCH=${XDEV_ARCH} CDTMP= ${MAKEOBJDIRPREFIX}/${XDDIR}/${.CURDIR}/tmp CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${NOFUN} CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDTP}/usr/bin:${PATH} ${MAKE} ${NOFUN} XDDESTDIR=${DESTDIR}${XDTP} .if !defined(OSREL) OSREL!= uname -r | sed -e 's/[-(].*//' .endif .ORDER: xdev-build xdev-install xdev: xdev-build xdev-install .ORDER: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools xdev-build: _xb-worldtmp _xb-bootstrap-tools _xb-build-tools _xb-cross-tools _xb-worldtmp: mkdir -p ${CDTMP}/usr mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${CDTMP}/usr >/dev/null _xb-bootstrap-tools: .for _tool in \ ${_clang_tblgen} ${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ obj; \ ${CDMAKE} DIRPRFX=${_tool}/ depend; \ ${CDMAKE} DIRPRFX=${_tool}/ all; \ ${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install .endfor _xb-build-tools: ${_+_}@cd ${.CURDIR}; \ ${CDBENV} ${MAKE} -f Makefile.inc1 ${NOFUN} build-tools _xb-cross-tools: .for _tool in \ gnu/usr.bin/binutils \ gnu/usr.bin/cc \ usr.bin/ar \ ${_clang_libs} \ ${_clang} ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ obj; \ ${CDMAKE} DIRPRFX=${_tool}/ depend; \ ${CDMAKE} DIRPRFX=${_tool}/ all .endfor _xi-mtree: ${_+_}@${ECHODIR} "mtree populating ${XDDESTDIR}" mkdir -p ${XDDESTDIR} mtree -deU -f ${.CURDIR}/etc/mtree/BSD.root.dist \ -p ${XDDESTDIR} >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ -p ${XDDESTDIR}/usr >/dev/null mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${XDDESTDIR}/usr/include >/dev/null .ORDER: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links xdev-install: xdev-build _xi-mtree _xi-cross-tools _xi-includes _xi-libraries _xi-links _xi-cross-tools: @echo "_xi-cross-tools" .for _tool in \ gnu/usr.bin/binutils \ gnu/usr.bin/cc \ usr.bin/ar \ ${_clang} ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} .endfor _xi-includes: ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 par-includes \ DESTDIR=${XDDESTDIR} _xi-libraries: ${_+_}cd ${.CURDIR}; ${CD2MAKE} -f Makefile.inc1 libraries \ DESTDIR=${XDDESTDIR} _xi-links: ${_+_}cd ${XDDESTDIR}/usr/bin; \ for i in *; do \ ln -sf ../../${XDTP}/usr/bin/$$i \ ../../../../usr/bin/${XDDIR}-$$i; \ ln -sf ../../${XDTP}/usr/bin/$$i \ ../../../../usr/bin/${XDDIR}${OSREL}-$$i; \ done .else xdev xdev-build xdev-install: @echo "*** Error: Both XDEV and XDEV_ARCH must be defined for \"${.TARGET}\" target" .endif Index: user/attilio/vmcontention/UPDATING =================================================================== --- user/attilio/vmcontention/UPDATING (revision 249698) +++ user/attilio/vmcontention/UPDATING (revision 249699) @@ -1,1805 +1,1810 @@ Updating Information for FreeBSD current users This file is maintained and copyrighted by M. Warner Losh . See end of file for further details. For commonly done items, please see the COMMON ITEMS: section later in the file. These instructions assume that you basically know what you are doing. If not, then please consult the FreeBSD handbook: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +NOTE: FreeBSD has switched from gcc to clang. If you have trouble bootstrapping +from older versions of FreeBSD, try WITHOUT_CLANG and WITHOUT_CLANG_IS_CC to +bootstrap to tip of head, and then rebuild without those options. The bootstrap +process from older version of current is a bit fragile. + NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW: FreeBSD 10.x has many debugging features turned on, in both the kernel and userland. These features attempt to detect incorrect use of system primitives, and encourage loud failure through extra sanity checking and fail stop semantics. They also substantially impact system performance. If you want to do performance measurement, benchmarking, and optimization, you'll want to turn them off. This includes various WITNESS- related kernel options, INVARIANTS, malloc debugging flags in userland, and various verbose features in the kernel. Many developers choose to disable these features on build machines to maximize performance. (To completely disable malloc debugging, define MALLOC_PRODUCTION in /etc/make.conf, or to merely disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) 20130404: Legacy ATA stack, disabled and replaced by new CAM-based one since FreeBSD 9.0, completely removed from the sources. Kernel modules atadisk and atapi*, user-level tools atacontrol and burncd are removed. Kernel option `options ATA_CAM` is now permanently enabled and removed. 20130319: SOCK_CLOEXEC and SOCK_NONBLOCK flags have been added to socket(2) and socketpair(2). Software, in particular Kerberos, may automatically detect and use these during building. The resulting binaries will not work on older kernels. 20130308: CTL_DISABLE has also been added to the sparc64 GENERIC (for further information, see the respective 20130304 entry). 20130304: Recent commits to callout(9) changed the size of struct callout, so the KBI is probably heavily disturbed. Also, some functions in callout(9)/sleep(9)/sleepqueue(9)/condvar(9) KPIs were replaced by macros. Every kernel module using it won't load, so rebuild is requested. The ctl device has been re-enabled in GENERIC for i386 and amd64, but does not initialize by default (because of the new CTL_DISABLE option) to save memory. To re-enable it, remove the CTL_DISABLE option from the kernel config file or set kern.cam.ctl.disable=0 in /boot/loader.conf. 20130301: The ctl device has been disabled in GENERIC for i386 and amd64. This was done due to the extra memory being allocated at system initialisation time by the ctl driver which was only used if a CAM target device was created. This makes a FreeBSD system unusable on 128MB or less of RAM. 20130208: A new compression method (lz4) has been merged to -HEAD. Please refer to zpool-features(7) for more information. Please refer to the "ZFS notes" section of this file for information on upgrading boot ZFS pools. 20130129: A BSD-licensed patch(1) variant has been added and is installed as bsdpatch, being the GNU version the default patch. To inverse the logic and use the BSD-licensed one as default, while having the GNU version installed as gnupatch, rebuild and install world with the WITH_BSD_PATCH knob set. 20130118: The install(1) option -M has changed meaning and now takes an argument that is a file or path to append logs to. In the unlikely event that -M was the last option on the command line and the command line contained at least two files and a target directory the first file will have logs appended to it. The -M option served little practical purpose in the last decade so its use is expected to be extremely rare. 20121223: After switching to Clang as the default compiler some users of ZFS on i386 systems started to experience stack overflow kernel panics. Please consider using 'options KSTACK_PAGES=4' in such configurations. 20121222: GEOM_LABEL now mangles label names read from file system metadata. Mangling affect labels containing spaces, non-printable characters, '%' or '"'. Device names in /etc/fstab and other places may need to be updated. 20121217: By default, only the 10 most recent kernel dumps will be saved. To restore the previous behaviour (no limit on the number of kernel dumps stored in the dump directory) add the following line to /etc/rc.conf: savecore_flags="" 20121201: With the addition of auditdistd(8), a new auditdistd user is now depended on during installworld. "mergemaster -p" can be used to add the user prior to installworld, as documented in the handbook. 20121117: The sin6_scope_id member variable in struct sockaddr_in6 is now filled by the kernel before passing the structure to the userland via sysctl or routing socket. This means the KAME-specific embedded scope id in sin6_addr.s6_addr[2] is always cleared in userland application. This behavior can be controlled by net.inet6.ip6.deembed_scopeid. __FreeBSD_version is bumped to 1000025. 20121105: On i386 and amd64 systems WITH_CLANG_IS_CC is now the default. This means that the world and kernel will be compiled with clang and that clang will be installed as /usr/bin/cc, /usr/bin/c++, and /usr/bin/cpp. To disable this behavior and revert to building with gcc, compile with WITHOUT_CLANG_IS_CC. 20121102: The IPFIREWALL_FORWARD kernel option has been removed. Its functionality now turned on by default. 20121023: The ZERO_COPY_SOCKET kernel option has been removed and split into SOCKET_SEND_COW and SOCKET_RECV_PFLIP. NB: SOCKET_SEND_COW uses the VM page based copy-on-write mechanism which is not safe and may result in kernel crashes. NB: The SOCKET_RECV_PFLIP mechanism is useless as no current driver supports disposeable external page sized mbuf storage. Proper replacements for both zero-copy mechanisms are under consideration and will eventually lead to complete removal of the two kernel options. 20121023: The IPv4 network stack has been converted to network byte order. The following modules need to be recompiled together with kernel: carp(4), divert(4), gif(4), siftr(4), gre(4), pf(4), ipfw(4), ng_ipfw(4), stf(4). 20121022: Support for non-MPSAFE filesystems was removed from VFS. The VFS_VERSION was bumped, all filesystem modules shall be recompiled. 20121018: All the non-MPSAFE filesystems have been disconnected from the build. The full list includes: codafs, hpfs, ntfs, nwfs, portalfs, smbfs, xfs. 20121016: The interface cloning API and ABI has changed. The following modules need to be recompiled together with kernel: ipfw(4), pfsync(4), pflog(4), usb(4), wlan(4), stf(4), vlan(4), disc(4), edsc(4), if_bridge(4), gif(4), tap(4), faith(4), epair(4), enc(4), tun(4), if_lagg(4), gre(4). 20121015: The sdhci driver was split in two parts: sdhci (generic SD Host Controller logic) and sdhci_pci (actual hardware driver). No kernel config modifications are required, but if you load sdhc as a module you must switch to sdhci_pci instead. 20121014: Import the FUSE kernel and userland support into base system. 20121013: The GNU sort(1) program has been removed since the BSD-licensed sort(1) has been the default for quite some time and no serious problems have been reported. The corresponding WITH_GNU_SORT knob has also gone. 20121006: The pfil(9) API/ABI for AF_INET family has been changed. Packet filtering modules: pf(4), ipfw(4), ipfilter(4) need to be recompiled with new kernel. 20121001: The net80211(4) ABI has been changed to allow for improved driver PS-POLL and power-save support. All wireless drivers need to be recompiled to work with the new kernel. 20120913: The random(4) support for the VIA hardware random number generator (`PADLOCK') is no longer enabled unconditionally. Add the PADLOCK_RNG option in the custom kernel config if needed. The GENERIC kernels on i386 and amd64 do include the option, so the change only affects the custom kernel configurations. 20120908: The pf(4) packet filter ABI has been changed. pfctl(8) and snmp_pf module need to be recompiled to work with new kernel. 20120828: A new ZFS feature flag "com.delphix:empty_bpobj" has been merged to -HEAD. Pools that have empty_bpobj in active state can not be imported read-write with ZFS implementations that do not support this feature. For more information read the zpool-features(5) manual page. 20120727: The sparc64 ZFS loader has been changed to no longer try to auto- detect ZFS providers based on diskN aliases but now requires these to be explicitly listed in the OFW boot-device environment variable. 20120712: The OpenSSL has been upgraded to 1.0.1c. Any binaries requiring libcrypto.so.6 or libssl.so.6 must be recompiled. Also, there are configuration changes. Make sure to merge /etc/ssl/openssl.cnf. 20120712: The following sysctls and tunables have been renamed for consistency with other variables: kern.cam.da.da_send_ordered -> kern.cam.da.send_ordered kern.cam.ada.ada_send_ordered -> kern.cam.ada.send_ordered 20120628: The sort utility has been replaced with BSD sort. For now, GNU sort is also available as "gnusort" or the default can be set back to GNU sort by setting WITH_GNU_SORT. In this case, BSD sort will be installed as "bsdsort". 20120611: A new version of ZFS (pool version 5000) has been merged to -HEAD. Starting with this version the old system of ZFS pool versioning is superseded by "feature flags". This concept enables forward compatibility against certain future changes in functionality of ZFS pools. The first read-only compatible "feature flag" for ZFS pools is named "com.delphix:async_destroy". For more information read the new zpool-features(5) manual page. Please refer to the "ZFS notes" section of this file for information on upgrading boot ZFS pools. 20120417: The malloc(3) implementation embedded in libc now uses sources imported as contrib/jemalloc. The most disruptive API change is to /etc/malloc.conf. If your system has an old-style /etc/malloc.conf, delete it prior to installworld, and optionally re-create it using the new format after rebooting. See malloc.conf(5) for details (specifically the TUNING section and the "opt.*" entries in the MALLCTL NAMESPACE section). 20120328: Big-endian MIPS TARGET_ARCH values no longer end in "eb". mips64eb is now spelled mips64. mipsn32eb is now spelled mipsn32. mipseb is now spelled mips. This is to aid compatibility with third-party software that expects this naming scheme in uname(3). Little-endian settings are unchanged. 20120306: Disable by default the option VFS_ALLOW_NONMPSAFE for all supported platforms. 20120229: Now unix domain sockets behave "as expected" on nullfs(5). Previously nullfs(5) did not pass through all behaviours to the underlying layer, as a result if we bound to a socket on the lower layer we could connect only to the lower path; if we bound to the upper layer we could connect only to the upper path. The new behavior is one can connect to both the lower and the upper paths regardless what layer path one binds to. 20120211: The getifaddrs upgrade path broken with 20111215 has been restored. If you have upgraded in between 20111215 and 20120209 you need to recompile libc again with your kernel. You still need to recompile world to be able to configure CARP but this restriction already comes from 20111215. 20120114: The set_rcvar() function has been removed from /etc/rc.subr. All base and ports rc.d scripts have been updated, so if you have a port installed with a script in /usr/local/etc/rc.d you can either hand-edit the rcvar= line, or reinstall the port. An easy way to handle the mass-update of /etc/rc.d: rm /etc/rc.d/* && mergemaster -i 20120109: panic(9) now stops other CPUs in the SMP systems, disables interrupts on the current CPU and prevents other threads from running. This behavior can be reverted using the kern.stop_scheduler_on_panic tunable/sysctl. The new behavior can be incompatible with kern.sync_on_panic. 20111215: The carp(4) facility has been changed significantly. Configuration of the CARP protocol via ifconfig(8) has changed, as well as format of CARP events submitted to devd(8) has changed. See manual pages for more information. The arpbalance feature of carp(4) is currently not supported anymore. Size of struct in_aliasreq, struct in6_aliasreq has changed. User utilities using SIOCAIFADDR, SIOCAIFADDR_IN6, e.g. ifconfig(8), need to be recompiled. 20111122: The acpi_wmi(4) status device /dev/wmistat has been renamed to /dev/wmistat0. 20111108: The option VFS_ALLOW_NONMPSAFE option has been added in order to explicitely support non-MPSAFE filesystems. It is on by default for all supported platform at this present time. 20111101: The broken amd(4) driver has been replaced with esp(4) in the amd64, i386 and pc98 GENERIC kernel configuration files. 20110930: sysinstall has been removed 20110923: The stable/9 branch created in subversion. This corresponds to the RELENG_9 branch in CVS. 20110913: This commit modifies vfs_register() so that it uses a hash calculation to set vfc_typenum, which is enabled by default. The first time a system is booted after this change, the vfc_typenum values will change for all file systems. The main effect of this is a change to the NFS server file handles for file systems that use vfc_typenum in their fsid, such as ZFS. It will, however, prevent vfc_typenum from changing when file systems are loaded in a different order for subsequent reboots. To disable this, you can set vfs.typenumhash=0 in /boot/loader.conf until you are ready to remount all NFS clients after a reboot. 20110828: Bump the shared library version numbers for libraries that do not use symbol versioning, have changed the ABI compared to stable/8 and which shared library version was not bumped. Done as part of 9.0-RELEASE cycle. 20110815: During the merge of Capsicum features, the fget(9) KPI was modified. This may require the rebuilding of out-of-tree device drivers -- issues have been reported specifically with the nVidia device driver. __FreeBSD_version is bumped to 900041. Also, there is a period between 20110811 and 20110814 where the special devices /dev/{stdin,stdout,stderr} did not work correctly. Building world from a kernel during that window may not work. 20110628: The packet filter (pf) code has been updated to OpenBSD 4.5. You need to update userland tools to be in sync with kernel. This update breaks backward compatibility with earlier pfsync(4) versions. Care must be taken when updating redundant firewall setups. 20110608: The following sysctls and tunables are retired on x86 platforms: machdep.hlt_cpus machdep.hlt_logical_cpus The following sysctl is retired: machdep.hyperthreading_allowed The sysctls were supposed to provide a way to dynamically offline and online selected CPUs on x86 platforms, but the implementation has not been reliable especially with SCHED_ULE scheduler. machdep.hyperthreading_allowed tunable is still available to ignore hyperthreading CPUs at OS level. Individual CPUs can be disabled using hint.lapic.X.disabled tunable, where X is an APIC ID of a CPU. Be advised, though, that disabling CPUs in non-uniform fashion will result in non-uniform topology and may lead to sub-optimal system performance with SCHED_ULE, which is a default scheduler. 20110607: cpumask_t type is retired and cpuset_t is used in order to describe a mask of CPUs. 20110531: Changes to ifconfig(8) for dynamic address family detection mandate that you are running a kernel of 20110525 or later. Make sure to follow the update procedure to boot a new kernel before installing world. 20110513: Support for sun4v architecture is officially dropped 20110503: Several KPI breaking changes have been committed to the mii(4) layer, the PHY drivers and consequently some Ethernet drivers using mii(4). This means that miibus.ko and the modules of the affected Ethernet drivers need to be recompiled. Note to kernel developers: Given that the OUI bit reversion problem was fixed as part of these changes all mii(4) commits related to OUIs, i.e. to sys/dev/mii/miidevs, PHY driver probing and vendor specific handling, no longer can be merged verbatim to stable/8 and previous branches. 20110430: Users of the Atheros AR71xx SoC code now need to add 'device ar71xx_pci' into their kernel configurations along with 'device pci'. 20110427: The default NFS client is now the new NFS client, so fstype "newnfs" is now "nfs" and the regular/old NFS client is now fstype "oldnfs". Although mounts via fstype "nfs" will usually work without userland changes, it is recommended that the mount(8) and mount_nfs(8) commands be rebuilt from sources and that a link to mount_nfs called mount_oldnfs be created. The new client is compiled into the kernel with "options NFSCL" and this is needed for diskless root file systems. The GENERIC kernel configs have been changed to use NFSCL and NFSD (the new server) instead of NFSCLIENT and NFSSERVER. To use the regular/old client, you can "mount -t oldnfs ...". For a diskless root file system, you must also include a line like: vfs.root.mountfrom="oldnfs:" in the boot/loader.conf on the root fs on the NFS server to make a diskless root fs use the old client. 20110424: The GENERIC kernels for all architectures now default to the new CAM-based ATA stack. It means that all legacy ATA drivers were removed and replaced by respective CAM drivers. If you are using ATA device names in /etc/fstab or other places, make sure to update them respectively (adX -> adaY, acdX -> cdY, afdX -> daY, astX -> saY, where 'Y's are the sequential numbers starting from zero for each type in order of detection, unless configured otherwise with tunables, see cam(4)). There will be symbolic links created in /dev/ to map old adX devices to the respective adaY. They should provide basic compatibility for file systems mounting in most cases, but they do not support old user-level APIs and do not have respective providers in GEOM. Consider using updated management tools with new device names. It is possible to load devices ahci, ata, siis and mvs as modules, but option ATA_CAM should remain in kernel configuration to make ata module work as CAM driver supporting legacy ATA controllers. Device ata still can be used in modular fashion (atacore + ...). Modules atadisk and atapi* are not used and won't affect operation in ATA_CAM mode. Note that to use CAM-based ATA kernel should include CAM devices scbus, pass, da (or explicitly ada), cd and optionally others. All of them are parts of the cam module. ataraid(4) functionality is now supported by the RAID GEOM class. To use it you can load geom_raid kernel module and use graid(8) tool for management. Instead of /dev/arX device names, use /dev/raid/rX. No kernel config options or code have been removed, so if a problem arises, please report it and optionally revert to the old ATA stack. In order to do it you can remove from the kernel config: options ATA_CAM device ahci device mvs device siis , and instead add back: device atadisk # ATA disk drives device ataraid # ATA RAID drives device atapicd # ATAPI CDROM drives device atapifd # ATAPI floppy drives device atapist # ATAPI tape drives 20110423: The default NFS server has been changed to the new server, which was referred to as the experimental server. If you need to switch back to the old NFS server, you must now put the "-o" option on both the mountd and nfsd commands. This can be done using the mountd_flags and nfs_server_flags rc.conf variables until an update to the rc scripts is committed, which is coming soon. 20110418: The GNU Objective-C runtime library (libobjc), and other Objective-C related components have been removed from the base system. If you require an Objective-C library, please use one of the available ports. 20110331: ath(4) has been split into bus- and device- modules. if_ath contains the HAL, the TX rate control and the network device code. if_ath_pci contains the PCI bus glue. For Atheros MIPS embedded systems, if_ath_ahb contains the AHB glue. Users need to load both if_ath_pci and if_ath in order to use ath on everything else. TO REPEAT: if_ath_ahb is not needed for normal users. Normal users only need to load if_ath and if_ath_pci for ath(4) operation. 20110314: As part of the replacement of sysinstall, the process of building release media has changed significantly. For details, please re-read release(7), which has been updated to reflect the new build process. 20110218: GNU binutils 2.17.50 (as of 2007-07-03) has been merged to -HEAD. This is the last available version under GPLv2. It brings a number of new features, such as support for newer x86 CPU's (with SSE-3, SSSE-3, SSE 4.1 and SSE 4.2), better support for powerpc64, a number of new directives, and lots of other small improvements. See the ChangeLog file in contrib/binutils for the full details. 20110218: IPsec's HMAC_SHA256-512 support has been fixed to be RFC4868 compliant, and will now use half of hash for authentication. This will break interoperability with all stacks (including all actual FreeBSD versions) who implement draft-ietf-ipsec-ciph-sha-256-00 (they use 96 bits of hash for authentication). The only workaround with such peers is to use another HMAC algorithm for IPsec ("phase 2") authentication. 20110207: Remove the uio_yield prototype and symbol. This function has been misnamed since it was introduced and should not be globally exposed with this name. The equivalent functionality is now available using kern_yield(curthread->td_user_pri). The function remains undocumented. 20110112: A SYSCTL_[ADD_]UQUAD was added for unsigned uint64_t pointers, symmetric with the existing SYSCTL_[ADD_]QUAD. Type checking for scalar sysctls is defined but disabled. Code that needs UQUAD to pass the type checking that must compile on older systems where the define is not present can check against __FreeBSD_version >= 900030. The system dialog(1) has been replaced with a new version previously in ports as devel/cdialog. dialog(1) is mostly command-line compatible with the previous version, but the libdialog associated with it has a largely incompatible API. As such, the original version of libdialog will be kept temporarily as libodialog, until its base system consumers are replaced or updated. Bump __FreeBSD_version to 900030. 20110103: If you are trying to run make universe on a -stable system, and you get the following warning: "Makefile", line 356: "Target architecture for i386/conf/GENERIC unknown. config(8) likely too old." or something similar to it, then you must upgrade your -stable system to 8.2-Release or newer (really, any time after r210146 7/15/2010 in stable/8) or build the config from the latest stable/8 branch and install it on your system. Prior to this date, building a current universe on 8-stable system from between 7/15/2010 and 1/2/2011 would result in a weird shell parsing error in the first kernel build phase. A new config on those old systems will fix that problem for older versions of -current. 20101228: The TCP stack has been modified to allow Khelp modules to interact with it via helper hook points and store per-connection data in the TCP control block. Bump __FreeBSD_version to 900029. User space tools that rely on the size of struct tcpcb in tcp_var.h (e.g. sockstat) need to be recompiled. 20101114: Generic IEEE 802.3 annex 31B full duplex flow control support has been added to mii(4) and bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4), e1000phy(4) as well as ip1000phy() have been converted to take advantage of it instead of using custom implementations. This means that these drivers now no longer unconditionally advertise support for flow control but only do so if flow control is a selected media option. This was implemented in the generic support that way in order to allow flow control to be switched on and off via ifconfig(8) with the PHY specific default to typically off in order to protect from unwanted effects. Consequently, if you used flow control with one of the above mentioned drivers you now need to explicitly enable it, for example via: ifconfig bge0 media auto mediaopt flowcontrol Along with the above mentioned changes generic support for setting 1000baseT master mode also has been added and brgphy(4), ciphy(4), e1000phy(4) as well as ip1000phy(4) have been converted to take advantage of it. This means that these drivers now no longer take the link0 parameter for selecting master mode but the master media option has to be used instead, for example like in the following: ifconfig bge0 media 1000baseT mediaopt full-duplex,master Selection of master mode now is also available with all other PHY drivers supporting 1000baseT. 20101111: The TCP stack has received a significant update to add support for modularised congestion control and generally improve the clarity of congestion control decisions. Bump __FreeBSD_version to 900025. User space tools that rely on the size of struct tcpcb in tcp_var.h (e.g. sockstat) need to be recompiled. 20101002: The man(1) utility has been replaced by a new version that no longer uses /etc/manpath.config. Please consult man.conf(5) for how to migrate local entries to the new format. 20100928: The copyright strings printed by login(1) and sshd(8) at the time of a new connection have been removed to follow other operating systems and upstream sshd. 20100915: A workaround for a fixed ld bug has been removed in kernel code, so make sure that your system ld is built from sources after revision 210245 from 2010-07-19 (r211583 if building head kernel on stable/8, r211584 for stable/7; both from 2010-08-21). A symptom of incorrect ld version is different addresses for set_pcpu section and __start_set_pcpu symbol in kernel and/or modules. 20100913: The $ipv6_prefer variable in rc.conf(5) has been split into $ip6addrctl_policy and $ipv6_activate_all_interfaces. The $ip6addrctl_policy is a variable to choose a pre-defined address selection policy set by ip6addrctl(8). A value "ipv4_prefer", "ipv6_prefer" or "AUTO" can be specified. The default is "AUTO". The $ipv6_activate_all_interfaces specifies whether IFDISABLED flag (see an entry of 20090926) is set on an interface with no corresponding $ifconfig_IF_ipv6 line. The default is "NO" for security reason. If you want IPv6 link-local address on all interfaces by default, set this to "YES". The old ipv6_prefer="YES" is equivalent to ipv6_activate_all_interfaces="YES" and ip6addrctl_policy="ipv6_prefer". 20100913: DTrace has grown support for userland tracing. Due to this, DTrace is now i386 and amd64 only. dtruss(1) is now installed by default on those systems and a new kernel module is needed for userland tracing: fasttrap. No changes to your kernel config file are necessary to enable userland tracing, but you might consider adding 'STRIP=' and 'CFLAGS+=-fno-omit-frame-pointer' to your make.conf if you want to have informative userland stack traces in DTrace (ustack). 20100725: The acpi_aiboost(4) driver has been removed in favor of the new aibs(4) driver. You should update your kernel configuration file. 20100722: BSD grep has been imported to the base system and it is built by default. It is completely BSD licensed, highly GNU-compatible, uses less memory than its GNU counterpart and has a small codebase. However, it is slower than its GNU counterpart, which is mostly noticeable for larger searches, for smaller ones it is measurable but not significant. The reason is complex, the most important factor is that we lack a modern and efficient regex library and GNU overcomes this by optimizing the searches internally. Future work on improving the regex performance is planned, for the meantime, users that need better performance, can build GNU grep instead by setting the WITH_GNU_GREP knob. 20100713: Due to the import of powerpc64 support, all existing powerpc kernel configuration files must be updated with a machine directive like this: machine powerpc powerpc In addition, an updated config(8) is required to build powerpc kernels after this change. 20100713: A new version of ZFS (version 15) has been merged to -HEAD. This version uses a python library for the following subcommands: zfs allow, zfs unallow, zfs groupspace, zfs userspace. For full functionality of these commands the following port must be installed: sysutils/py-zfs 20100429: 'vm_page's are now hashed by physical address to an array of mutexes. Currently this is only used to serialize access to hold_count. Over time the page queue mutex will be peeled away. This changes the size of pmap on every architecture. And requires all callers of vm_page_hold and vm_page_unhold to be updated. 20100402: WITH_CTF can now be specified in src.conf (not recommended, there are some problems with static executables), make.conf (would also affect ports which do not use GNU make and do not override the compile targets) or in the kernel config (via "makeoptions WITH_CTF=yes"). When WITH_CTF was specified there before this was silently ignored, so make sure that WITH_CTF is not used in places which could lead to unwanted behavior. 20100311: The kernel option COMPAT_IA32 has been replaced with COMPAT_FREEBSD32 to allow 32-bit compatibility on non-x86 platforms. All kernel configurations on amd64 and ia64 platforms using these options must be modified accordingly. 20100113: The utmp user accounting database has been replaced with utmpx, the user accounting interface standardized by POSIX. Unfortunately the semantics of utmp and utmpx don't match, making it practically impossible to support both interfaces. The user accounting database is used by tools like finger(1), last(1), talk(1), w(1) and ac(8). All applications in the base system use utmpx. This means only local binaries (e.g. from the ports tree) may still use these utmp database files. These applications must be rebuilt to make use of utmpx. After the system has been upgraded, it is safe to remove the old log files (/var/run/utmp, /var/log/lastlog and /var/log/wtmp*), assuming their contents is of no importance anymore. Old wtmp databases can only be used by last(1) and ac(8) after they have been converted to the new format using wtmpcvt(1). 20100108: Introduce the kernel thread "deadlock resolver" (which can be enabled via the DEADLKRES option, see NOTES for more details) and the sleepq_type() function for sleepqueues. 20091202: The rc.firewall and rc.firewall6 were unified, and rc.firewall6 and rc.d/ip6fw were removed. According to the removal of rc.d/ip6fw, ipv6_firewall_* rc variables are obsoleted. Instead, the following new rc variables are added to rc.d/ipfw: firewall_client_net_ipv6, firewall_simple_iif_ipv6, firewall_simple_inet_ipv6, firewall_simple_oif_ipv6, firewall_simple_onet_ipv6, firewall_trusted_ipv6 The meanings correspond to the relevant IPv4 variables. 20091125: 8.0-RELEASE. 20091113: The default terminal emulation for syscons(4) has been changed from cons25 to xterm on all platforms except pc98. This means that the /etc/ttys file needs to be updated to ensure correct operation of applications on the console. The terminal emulation style can be toggled per window by using vidcontrol(1)'s -T flag. The TEKEN_CONS25 kernel configuration options can be used to change the compile-time default back to cons25. To prevent graphical artifacts, make sure the TERM environment variable is set to match the terminal emulation that is being performed by syscons(4). 20091109: The layout of the structure ieee80211req_scan_result has changed. Applications that require wireless scan results (e.g. ifconfig(8)) from net80211 need to be recompiled. Applications such as wpa_supplicant(8) may require a full world build without using NO_CLEAN in order to get synchronized with the new structure. 20091025: The iwn(4) driver has been updated to support the 5000 and 5150 series. There's one kernel module for each firmware. Adding "device iwnfw" to the kernel configuration file means including all three firmware images inside the kernel. If you want to include just the one for your wireless card, use the devices iwn4965fw, iwn5000fw or iwn5150fw. 20090926: The rc.d/network_ipv6, IPv6 configuration script has been integrated into rc.d/netif. The changes are the following: 1. To use IPv6, simply define $ifconfig_IF_ipv6 like $ifconfig_IF for IPv4. For aliases, $ifconfig_IF_aliasN should be used. Note that both variables need the "inet6" keyword at the head. Do not set $ipv6_network_interfaces manually if you do not understand what you are doing. It is not needed in most cases. $ipv6_ifconfig_IF and $ipv6_ifconfig_IF_aliasN still work, but they are obsolete. 2. $ipv6_enable is obsolete. Use $ipv6_prefer and "inet6 accept_rtadv" keyword in ifconfig(8) instead. If you define $ipv6_enable=YES, it means $ipv6_prefer=YES and all configured interfaces have "inet6 accept_rtadv" in the $ifconfig_IF_ipv6. These are for backward compatibility. 3. A new variable $ipv6_prefer has been added. If NO, IPv6 functionality of interfaces with no corresponding $ifconfig_IF_ipv6 is disabled by using "inet6 ifdisabled" flag, and the default address selection policy of ip6addrctl(8) is the IPv4-preferred one (see rc.d/ip6addrctl for more details). Note that if you want to configure IPv6 functionality on the disabled interfaces after boot, first you need to clear the flag by using ifconfig(8) like: ifconfig em0 inet6 -ifdisabled If YES, the default address selection policy is set as IPv6-preferred. The default value of $ipv6_prefer is NO. 4. If your system need to receive Router Advertisement messages, define "inet6 accept_rtadv" in $ifconfig_IF_ipv6. The rc(8) scripts automatically invoke rtsol(8) when the interface becomes UP. The Router Advertisement messages are used for SLAAC (State-Less Address AutoConfiguration). 20090922: 802.11s D3.03 support was committed. This is incompatible with the previous code, which was based on D3.0. 20090912: A sysctl variable net.inet6.ip6.accept_rtadv now sets the default value of a per-interface flag ND6_IFF_ACCEPT_RTADV, not a global knob to control whether accepting Router Advertisement messages or not. Also, a per-interface flag ND6_IFF_AUTO_LINKLOCAL has been added and a sysctl variable net.inet6.ip6.auto_linklocal is its default value. The ifconfig(8) utility now supports these flags. 20090910: ZFS snapshots are now mounted with MNT_IGNORE flag. Use -v option for mount(8) and -a option for df(1) to see them. 20090825: The old tunable hw.bus.devctl_disable has been superseded by hw.bus.devctl_queue. hw.bus.devctl_disable=1 in loader.conf should be replaced by hw.bus.devctl_queue=0. The default for this new tunable is 1000. 20090813: Remove the option STOP_NMI. The default action is now to use NMI only for KDB via the newly introduced function stop_cpus_hard() and maintain stop_cpus() to just use a normal IPI_STOP on ia32 and amd64. 20090803: The stable/8 branch created in subversion. This corresponds to the RELENG_8 branch in CVS. 20090719: Bump the shared library version numbers for all libraries that do not use symbol versioning as part of the 8.0-RELEASE cycle. Bump __FreeBSD_version to 800105. 20090714: Due to changes in the implementation of virtual network stack support, all network-related kernel modules must be recompiled. As this change breaks the ABI, bump __FreeBSD_version to 800104. 20090713: The TOE interface to the TCP syncache has been modified to remove struct tcpopt () from the ABI of the network stack. The cxgb driver is the only TOE consumer affected by this change, and needs to be recompiled along with the kernel. As this change breaks the ABI, bump __FreeBSD_version to 800103. 20090712: Padding has been added to struct tcpcb, sackhint and tcpstat in to facilitate future MFCs and bug fixes whilst maintaining the ABI. However, this change breaks the ABI, so bump __FreeBSD_version to 800102. User space tools that rely on the size of any of these structs (e.g. sockstat) need to be recompiled. 20090630: The NFS_LEGACYRPC option has been removed along with the old kernel RPC implementation that this option selected. Kernel configurations may need to be adjusted. 20090629: The network interface device nodes at /dev/net/ have been removed. All ioctl operations can be performed the normal way using routing sockets. The kqueue functionality can generally be replaced with routing sockets. 20090628: The documentation from the FreeBSD Documentation Project (Handbook, FAQ, etc.) is now installed via packages by sysinstall(8) and under the /usr/local/share/doc/freebsd directory instead of /usr/share/doc. 20090624: The ABI of various structures related to the SYSV IPC API have been changed. As a result, the COMPAT_FREEBSD[456] and COMPAT_43 kernel options now all require COMPAT_FREEBSD7. Bump __FreeBSD_version to 800100. 20090622: Layout of struct vnet has changed as routing related variables were moved to their own Vimage module. Modules need to be recompiled. Bump __FreeBSD_version to 800099. 20090619: NGROUPS_MAX and NGROUPS have been increased from 16 to 1023 and 1024 respectively. As long as no more than 16 groups per process are used, no changes should be visible. When more than 16 groups are used, old binaries may fail if they call getgroups() or getgrouplist() with statically sized storage. Recompiling will work around this, but applications should be modified to use dynamically allocated storage for group arrays as POSIX.1-2008 does not cap an implementation's number of supported groups at NGROUPS_MAX+1 as previous versions did. NFS and portalfs mounts may also be affected as the list of groups is truncated to 16. Users of NFS who use more than 16 groups, should take care that negative group permissions are not used on the exported file systems as they will not be reliable unless a GSSAPI based authentication method is used. 20090616: The compiling option ADAPTIVE_LOCKMGRS has been introduced. This option compiles in the support for adaptive spinning for lockmgrs which want to enable it. The lockinit() function now accepts the flag LK_ADAPTIVE in order to make the lock object subject to adaptive spinning when both held in write and read mode. 20090613: The layout of the structure returned by IEEE80211_IOC_STA_INFO has changed. User applications that use this ioctl need to be rebuilt. 20090611: The layout of struct thread has changed. Kernel and modules need to be rebuilt. 20090608: The layout of structs ifnet, domain, protosw and vnet_net has changed. Kernel modules need to be rebuilt. Bump __FreeBSD_version to 800097. 20090602: window(1) has been removed from the base system. It can now be installed from ports. The port is called misc/window. 20090601: The way we are storing and accessing `routing table' entries has changed. Programs reading the FIB, like netstat, need to be re-compiled. 20090601: A new netisr implementation has been added for FreeBSD 8. Network file system modules, such as igmp, ipdivert, and others, should be rebuilt. Bump __FreeBSD_version to 800096. 20090530: Remove the tunable/sysctl debug.mpsafevfs as its initial purpose is no more valid. 20090530: Add VOP_ACCESSX(9). File system modules need to be rebuilt. Bump __FreeBSD_version to 800094. 20090529: Add mnt_xflag field to 'struct mount'. File system modules need to be rebuilt. Bump __FreeBSD_version to 800093. 20090528: The compiling option ADAPTIVE_SX has been retired while it has been introduced the option NO_ADAPTIVE_SX which handles the reversed logic. The KPI for sx_init_flags() changes as accepting flags: SX_ADAPTIVESPIN flag has been retired while the SX_NOADAPTIVE flag has been introduced in order to handle the reversed logic. Bump __FreeBSD_version to 800092. 20090527: Add support for hierarchical jails. Remove global securelevel. Bump __FreeBSD_version to 800091. 20090523: The layout of struct vnet_net has changed, therefore modules need to be rebuilt. Bump __FreeBSD_version to 800090. 20090523: The newly imported zic(8) produces a new format in the output. Please run tzsetup(8) to install the newly created data to /etc/localtime. 20090520: The sysctl tree for the usb stack has renamed from hw.usb2.* to hw.usb.* and is now consistent again with previous releases. 20090520: 802.11 monitor mode support was revised and driver api's were changed. Drivers dependent on net80211 now support DLT_IEEE802_11_RADIO instead of DLT_IEEE802_11. No user-visible data structures were changed but applications that use DLT_IEEE802_11 may require changes. Bump __FreeBSD_version to 800088. 20090430: The layout of the following structs has changed: sysctl_oid, socket, ifnet, inpcbinfo, tcpcb, syncache_head, vnet_inet, vnet_inet6 and vnet_ipfw. Most modules need to be rebuild or panics may be experienced. World rebuild is required for correctly checking networking state from userland. Bump __FreeBSD_version to 800085. 20090429: MLDv2 and Source-Specific Multicast (SSM) have been merged to the IPv6 stack. VIMAGE hooks are in but not yet used. The implementation of SSM within FreeBSD's IPv6 stack closely follows the IPv4 implementation. For kernel developers: * The most important changes are that the ip6_output() and ip6_input() paths no longer take the IN6_MULTI_LOCK, and this lock has been downgraded to a non-recursive mutex. * As with the changes to the IPv4 stack to support SSM, filtering of inbound multicast traffic must now be performed by transport protocols within the IPv6 stack. This does not apply to TCP and SCTP, however, it does apply to UDP in IPv6 and raw IPv6. * The KPIs used by IPv6 multicast are similar to those used by the IPv4 stack, with the following differences: * im6o_mc_filter() is analogous to imo_multicast_filter(). * The legacy KAME entry points in6_joingroup and in6_leavegroup() are shimmed to in6_mc_join() and in6_mc_leave() respectively. * IN6_LOOKUP_MULTI() has been deprecated and removed. * IPv6 relies on MLD for the DAD mechanism. KAME's internal KPIs for MLDv1 have an additional 'timer' argument which is used to jitter the initial membership report for the solicited-node multicast membership on-link. * This is not strictly needed for MLDv2, which already jitters its report transmissions. However, the 'timer' argument is preserved in case MLDv1 is active on the interface. * The KAME linked-list based IPv6 membership implementation has been refactored to use a vector similar to that used by the IPv4 stack. Code which maintains a list of its own multicast memberships internally, e.g. carp, has been updated to reflect the new semantics. * There is a known Lock Order Reversal (LOR) due to in6_setscope() acquiring the IF_AFDATA_LOCK and being called within ip6_output(). Whilst MLDv2 tries to avoid this otherwise benign LOR, it is an implementation constraint which needs to be addressed in HEAD. For application developers: * The changes are broadly similar to those made for the IPv4 stack. * The use of IPv4 and IPv6 multicast socket options on the same socket, using mapped addresses, HAS NOT been tested or supported. * There are a number of issues with the implementation of various IPv6 multicast APIs which need to be resolved in the API surface before the implementation is fully compatible with KAME userland use, and these are mostly to do with interface index treatment. * The literature available discusses the use of either the delta / ASM API with setsockopt(2)/getsockopt(2), or the full-state / ASM API using setsourcefilter(3)/getsourcefilter(3). For more information please refer to RFC 3768, 'Socket Interface Extensions for Multicast Source Filters'. * Applications which use the published RFC 3678 APIs should be fine. For systems administrators: * The mtest(8) utility has been refactored to support IPv6, in addition to IPv4. Interface addresses are no longer accepted as arguments, their names must be used instead. The utility will map the interface name to its first IPv4 address as returned by getifaddrs(3). * The ifmcstat(8) utility has also been updated to print the MLDv2 endpoint state and source filter lists via sysctl(3). * The net.inet6.ip6.mcast.loop sysctl may be tuned to 0 to disable loopback of IPv6 multicast datagrams by default; it defaults to 1 to preserve the existing behaviour. Disabling multicast loopback is recommended for optimal system performance. * The IPv6 MROUTING code has been changed to examine this sysctl instead of attempting to perform a group lookup before looping back forwarded datagrams. Bump __FreeBSD_version to 800084. 20090422: Implement low-level Bluetooth HCI API. Bump __FreeBSD_version to 800083. 20090419: The layout of struct malloc_type, used by modules to register new memory allocation types, has changed. Most modules will need to be rebuilt or panics may be experienced. Bump __FreeBSD_version to 800081. 20090415: Anticipate overflowing inp_flags - add inp_flags2. This changes most offsets in inpcb, so checking v4 connection state will require a world rebuild. Bump __FreeBSD_version to 800080. 20090415: Add an llentry to struct route and struct route_in6. Modules embedding a struct route will need to be recompiled. Bump __FreeBSD_version to 800079. 20090414: The size of rt_metrics_lite and by extension rtentry has changed. Networking administration apps will need to be recompiled. The route command now supports show as an alias for get, weighting of routes, sticky and nostick flags to alter the behavior of stateful load balancing. Bump __FreeBSD_version to 800078. 20090408: Do not use Giant for kbdmux(4) locking. This is wrong and apparently causing more problems than it solves. This will re-open the issue where interrupt handlers may race with kbdmux(4) in polling mode. Typical symptoms include (but not limited to) duplicated and/or missing characters when low level console functions (such as gets) are used while interrupts are enabled (for example geli password prompt, mountroot prompt etc.). Disabling kbdmux(4) may help. 20090407: The size of structs vnet_net, vnet_inet and vnet_ipfw has changed; kernel modules referencing any of the above need to be recompiled. Bump __FreeBSD_version to 800075. 20090320: GEOM_PART has become the default partition slicer for storage devices, replacing GEOM_MBR, GEOM_BSD, GEOM_PC98 and GEOM_GPT slicers. It introduces some changes: MSDOS/EBR: the devices created from MSDOS extended partition entries (EBR) can be named differently than with GEOM_MBR and are now symlinks to devices with offset-based names. fstabs may need to be modified. BSD: the "geometry does not match label" warning is harmless in most cases but it points to problems in file system misalignment with disk geometry. The "c" partition is now implicit, covers the whole top-level drive and cannot be (mis)used by users. General: Kernel dumps are now not allowed to be written to devices whose partition types indicate they are meant to be used for file systems (or, in case of MSDOS partitions, as something else than the "386BSD" type). Most of these changes date approximately from 200812. 20090319: The uscanner(4) driver has been removed from the kernel. This follows Linux removing theirs in 2.6 and making libusb the default interface (supported by sane). 20090319: The multicast forwarding code has been cleaned up. netstat(1) only relies on KVM now for printing bandwidth upcall meters. The IPv4 and IPv6 modules are split into ip_mroute_mod and ip6_mroute_mod respectively. The config(5) options for statically compiling this code remain the same, i.e. 'options MROUTING'. 20090315: Support for the IFF_NEEDSGIANT network interface flag has been removed, which means that non-MPSAFE network device drivers are no longer supported. In particular, if_ar, if_sr, and network device drivers from the old (legacy) USB stack can no longer be built or used. 20090313: POSIX.1 Native Language Support (NLS) has been enabled in libc and a bunch of new language catalog files have also been added. This means that some common libc messages are now localized and they depend on the LC_MESSAGES environmental variable. 20090313: The k8temp(4) driver has been renamed to amdtemp(4) since support for Family 10 and Family 11 CPU families was added. 20090309: IGMPv3 and Source-Specific Multicast (SSM) have been merged to the IPv4 stack. VIMAGE hooks are in but not yet used. For kernel developers, the most important changes are that the ip_output() and ip_input() paths no longer take the IN_MULTI_LOCK(), and this lock has been downgraded to a non-recursive mutex. Transport protocols (UDP, Raw IP) are now responsible for filtering inbound multicast traffic according to group membership and source filters. The imo_multicast_filter() KPI exists for this purpose. Transports which do not use multicast (SCTP, TCP) already reject multicast by default. Forwarding and receive performance may improve as a mutex acquisition is no longer needed in the ip_input() low-level input path. in_addmulti() and in_delmulti() are shimmed to new KPIs which exist to support SSM in-kernel. For application developers, it is recommended that loopback of multicast datagrams be disabled for best performance, as this will still cause the lock to be taken for each looped-back datagram transmission. The net.inet.ip.mcast.loop sysctl may be tuned to 0 to disable loopback by default; it defaults to 1 to preserve the existing behaviour. For systems administrators, to obtain best performance with multicast reception and multiple groups, it is always recommended that a card with a suitably precise hash filter is used. Hash collisions will still result in the lock being taken within the transport protocol input path to check group membership. If deploying FreeBSD in an environment with IGMP snooping switches, it is recommended that the net.inet.igmp.sendlocal sysctl remain enabled; this forces 224.0.0.0/24 group membership to be announced via IGMP. The size of 'struct igmpstat' has changed; netstat needs to be recompiled to reflect this. Bump __FreeBSD_version to 800070. 20090309: libusb20.so.1 is now installed as libusb.so.1 and the ports system updated to use it. This requires a buildworld/installworld in order to update the library and dependencies (usbconfig, etc). Its advisable to rebuild all ports which uses libusb. More specific directions are given in the ports collection UPDATING file. Any /etc/libmap.conf entries for libusb are no longer required and can be removed. 20090302: A workaround is committed to allow the creation of System V shared memory segment of size > 2 GB on the 64-bit architectures. Due to a limitation of the existing ABI, the shm_segsz member of the struct shmid_ds, returned by shmctl(IPC_STAT) call is wrong for large segments. Note that limits must be explicitly raised to allow such segments to be created. 20090301: The layout of struct ifnet has changed, requiring a rebuild of all network device driver modules. 20090227: The /dev handling for the new USB stack has changed, a buildworld/installworld is required for libusb20. 20090223: The new USB2 stack has now been permanently moved in and all kernel and module names reverted to their previous values (eg, usb, ehci, ohci, ums, ...). The old usb stack can be compiled in by prefixing the name with the letter 'o', the old usb modules have been removed. Updating entry 20090216 for xorg and 20090215 for libmap may still apply. 20090217: The rc.conf(5) option if_up_delay has been renamed to defaultroute_delay to better reflect its purpose. If you have customized this setting in /etc/rc.conf you need to update it to use the new name. 20090216: xorg 7.4 wants to configure its input devices via hald which does not yet work with USB2. If the keyboard/mouse does not work in xorg then add Option "AllowEmptyInput" "off" to your ServerLayout section. This will cause X to use the configured kbd and mouse sections from your xorg.conf. 20090215: The GENERIC kernels for all architectures now default to the new USB2 stack. No kernel config options or code have been removed so if a problem arises please report it and optionally revert to the old USB stack. If you are loading USB kernel modules or have a custom kernel that includes GENERIC then ensure that usb names are also changed over, eg uftdi -> usb2_serial_ftdi. Older programs linked against the ports libusb 0.1 need to be redirected to the new stack's libusb20. /etc/libmap.conf can be used for this: # Map old usb library to new one for usb2 stack libusb-0.1.so.8 libusb20.so.1 20090209: All USB ethernet devices now attach as interfaces under the name ueN (eg. ue0). This is to provide a predictable name as vendors often change usb chipsets in a product without notice. 20090203: The ichsmb(4) driver has been changed to require SMBus slave addresses be left-justified (xxxxxxx0b) rather than right-justified. All of the other SMBus controller drivers require left-justified slave addresses, so this change makes all the drivers provide the same interface. 20090201: INET6 statistics (struct ip6stat) was updated. netstat(1) needs to be recompiled. 20090119: NTFS has been removed from GENERIC kernel on amd64 to match GENERIC on i386. Should not cause any issues since mount_ntfs(8) will load ntfs.ko module automatically when NTFS support is actually needed, unless ntfs.ko is not installed or security level prohibits loading kernel modules. If either is the case, "options NTFS" has to be added into kernel config. 20090115: TCP Appropriate Byte Counting (RFC 3465) support added to kernel. New field in struct tcpcb breaks ABI, so bump __FreeBSD_version to 800061. User space tools that rely on the size of struct tcpcb in tcp_var.h (e.g. sockstat) need to be recompiled. 20081225: ng_tty(4) module updated to match the new TTY subsystem. Due to API change, user-level applications must be updated. New API support added to mpd5 CVS and expected to be present in next mpd5.3 release. 20081219: With __FreeBSD_version 800060 the makefs tool is part of the base system (it was a port). 20081216: The afdata and ifnet locks have been changed from mutexes to rwlocks, network modules will need to be re-compiled. 20081214: __FreeBSD_version 800059 incorporates the new arp-v2 rewrite. RTF_CLONING, RTF_LLINFO and RTF_WASCLONED flags are eliminated. The new code reduced struct rtentry{} by 16 bytes on 32-bit architecture and 40 bytes on 64-bit architecture. The userland applications "arp" and "ndp" have been updated accordingly. The output from "netstat -r" shows only routing entries and none of the L2 information. 20081130: __FreeBSD_version 800057 marks the switchover from the binary ath hal to source code. Users must add the line: options AH_SUPPORT_AR5416 to their kernel config files when specifying: device ath_hal The ath_hal module no longer exists; the code is now compiled together with the driver in the ath module. It is now possible to tailor chip support (i.e. reduce the set of chips and thereby the code size); consult ath_hal(4) for details. 20081121: __FreeBSD_version 800054 adds memory barriers to , new interfaces to ifnet to facilitate multiple hardware transmit queues for cards that support them, and a lock-less ring-buffer implementation to enable drivers to more efficiently manage queueing of packets. 20081117: A new version of ZFS (version 13) has been merged to -HEAD. This version has zpool attribute "listsnapshots" off by default, which means "zfs list" does not show snapshots, and is the same as Solaris behavior. 20081028: dummynet(4) ABI has changed. ipfw(8) needs to be recompiled. 20081009: The uhci, ohci, ehci and slhci USB Host controller drivers have been put into separate modules. If you load the usb module separately through loader.conf you will need to load the appropriate *hci module as well. E.g. for a UHCI-based USB 2.0 controller add the following to loader.conf: uhci_load="YES" ehci_load="YES" 20081009: The ABI used by the PMC toolset has changed. Please keep userland (libpmc(3)) and the kernel module (hwpmc(4)) in sync. 20081009: atapci kernel module now includes only generic PCI ATA driver. AHCI driver moved to ataahci kernel module. All vendor-specific code moved into separate kernel modules: ataacard, ataacerlabs, ataadaptec, ataamd, ataati, atacenatek, atacypress, atacyrix, atahighpoint, ataintel, ataite, atajmicron, atamarvell, atamicron, atanational, atanetcell, atanvidia, atapromise, ataserverworks, atasiliconimage, atasis, atavia 20080820: The TTY subsystem of the kernel has been replaced by a new implementation, which provides better scalability and an improved driver model. Most common drivers have been migrated to the new TTY subsystem, while others have not. The following drivers have not yet been ported to the new TTY layer: PCI/ISA: cy, digi, rc, rp, sio USB: ubser, ucycom Line disciplines: ng_h4, ng_tty, ppp, sl, snp Adding these drivers to your kernel configuration file shall cause compilation to fail. 20080818: ntpd has been upgraded to 4.2.4p5. 20080801: OpenSSH has been upgraded to 5.1p1. For many years, FreeBSD's version of OpenSSH preferred DSA over RSA for host and user authentication keys. With this upgrade, we've switched to the vendor's default of RSA over DSA. This may cause upgraded clients to warn about unknown host keys even for previously known hosts. Users should follow the usual procedure for verifying host keys before accepting the RSA key. This can be circumvented by setting the "HostKeyAlgorithms" option to "ssh-dss,ssh-rsa" in ~/.ssh/config or on the ssh command line. Please note that the sequence of keys offered for authentication has been changed as well. You may want to specify IdentityFile in a different order to revert this behavior. 20080713: The sio(4) driver has been removed from the i386 and amd64 kernel configuration files. This means uart(4) is now the default serial port driver on those platforms as well. To prevent collisions with the sio(4) driver, the uart(4) driver uses different names for its device nodes. This means the onboard serial port will now most likely be called "ttyu0" instead of "ttyd0". You may need to reconfigure applications to use the new device names. When using the serial port as a boot console, be sure to update /boot/device.hints and /etc/ttys before booting the new kernel. If you forget to do so, you can still manually specify the hints at the loader prompt: set hint.uart.0.at="isa" set hint.uart.0.port="0x3F8" set hint.uart.0.flags="0x10" set hint.uart.0.irq="4" boot -s 20080609: The gpt(8) utility has been removed. Use gpart(8) to partition disks instead. 20080603: The version that Linuxulator emulates was changed from 2.4.2 to 2.6.16. If you experience any problems with Linux binaries please try to set sysctl compat.linux.osrelease to 2.4.2 and if it fixes the problem contact emulation mailing list. 20080525: ISDN4BSD (I4B) was removed from the src tree. You may need to update a your kernel configuration and remove relevant entries. 20080509: I have checked in code to support multiple routing tables. See the man pages setfib(1) and setfib(2). This is a hopefully backwards compatible version, but to make use of it you need to compile your kernel with options ROUTETABLES=2 (or more up to 16). 20080420: The 802.11 wireless support was redone to enable multi-bss operation on devices that are capable. The underlying device is no longer used directly but instead wlanX devices are cloned with ifconfig. This requires changes to rc.conf files. For example, change: ifconfig_ath0="WPA DHCP" to wlans_ath0=wlan0 ifconfig_wlan0="WPA DHCP" see rc.conf(5) for more details. In addition, mergemaster of /etc/rc.d is highly recommended. Simultaneous update of userland and kernel wouldn't hurt either. As part of the multi-bss changes the wlan_scan_ap and wlan_scan_sta modules were merged into the base wlan module. All references to these modules (e.g. in kernel config files) must be removed. 20080408: psm(4) has gained write(2) support in native operation level. Arbitrary commands can be written to /dev/psm%d and status can be read back from it. Therefore, an application is responsible for status validation and error recovery. It is a no-op in other operation levels. 20080312: Support for KSE threading has been removed from the kernel. To run legacy applications linked against KSE libmap.conf may be used. The following libmap.conf may be used to ensure compatibility with any prior release: libpthread.so.1 libthr.so.1 libpthread.so.2 libthr.so.2 libkse.so.3 libthr.so.3 20080301: The layout of struct vmspace has changed. This affects libkvm and any executables that link against libkvm and use the kvm_getprocs() function. In particular, but not exclusively, it affects ps(1), fstat(1), pkill(1), systat(1), top(1) and w(1). The effects are minimal, but it's advisable to upgrade world nonetheless. 20080229: The latest em driver no longer has support in it for the 82575 adapter, this is now moved to the igb driver. The split was done to make new features that are incompatible with older hardware easier to do. 20080220: The new geom_lvm(4) geom class has been renamed to geom_linux_lvm(4), likewise the kernel option is now GEOM_LINUX_LVM. 20080211: The default NFS mount mode has changed from UDP to TCP for increased reliability. If you rely on (insecurely) NFS mounting across a firewall you may need to update your firewall rules. 20080208: Belatedly note the addition of m_collapse for compacting mbuf chains. 20080126: The fts(3) structures have been changed to use adequate integer types for their members and so to be able to cope with huge file trees. The old fts(3) ABI is preserved through symbol versioning in libc, so third-party binaries using fts(3) should still work, although they will not take advantage of the extended types. At the same time, some third-party software might fail to build after this change due to unportable assumptions made in its source code about fts(3) structure members. Such software should be fixed by its vendor or, in the worst case, in the ports tree. FreeBSD_version 800015 marks this change for the unlikely case that a portable fix is impossible. 20080123: To upgrade to -current after this date, you must be running FreeBSD not older than 6.0-RELEASE. Upgrading to -current from 5.x now requires a stop over at RELENG_6 or RELENG_7 systems. 20071128: The ADAPTIVE_GIANT kernel option has been retired because its functionality is the default now. 20071118: The AT keyboard emulation of sunkbd(4) has been turned on by default. In order to make the special symbols of the Sun keyboards driven by sunkbd(4) work under X these now have to be configured the same way as Sun USB keyboards driven by ukbd(4) (which also does AT keyboard emulation), f.e.: Option "XkbLayout" "us" Option "XkbRules" "xorg" Option "XkbSymbols" "pc(pc105)+sun_vndr/usb(sun_usb)+us" 20071024: It has been decided that it is desirable to provide ABI backwards compatibility to the FreeBSD 4/5/6 versions of the PCIOCGETCONF, PCIOCREAD and PCIOCWRITE IOCTLs, which was broken with the introduction of PCI domain support (see the 20070930 entry). Unfortunately, this required the ABI of PCIOCGETCONF to be broken again in order to be able to provide backwards compatibility to the old version of that IOCTL. Thus consumers of PCIOCGETCONF have to be recompiled again. As for prominent ports this affects neither pciutils nor xorg-server this time, the hal port needs to be rebuilt however. 20071020: The misnamed kthread_create() and friends have been renamed to kproc_create() etc. Many of the callers already used kproc_start().. I will return kthread_create() and friends in a while with implementations that actually create threads, not procs. Renaming corresponds with version 800002. 20071010: RELENG_7 branched. COMMON ITEMS: General Notes ------------- Avoid using make -j when upgrading. While generally safe, there are sometimes problems using -j to upgrade. If your upgrade fails with -j, please try again without -j. From time to time in the past there have been problems using -j with buildworld and/or installworld. This is especially true when upgrading between "distant" versions (eg one that cross a major release boundary or several minor releases, or when several months have passed on the -current branch). Sometimes, obscure build problems are the result of environment poisoning. This can happen because the make utility reads its environment when searching for values for global variables. To run your build attempts in an "environmental clean room", prefix all make commands with 'env -i '. See the env(1) manual page for more details. When upgrading from one major version to another it is generally best to upgrade to the latest code in the currently installed branch first, then do an upgrade to the new branch. This is the best-tested upgrade path, and has the highest probability of being successful. Please try this approach before reporting problems with a major version upgrade. ZFS notes --------- When upgrading the boot ZFS pool to a new version, always follow these two steps: 1.) recompile and reinstall the ZFS boot loader and boot block (this is part of "make buildworld" and "make installworld") 2.) update the ZFS boot block on your boot drive The following example updates the ZFS boot block on the first partition (freebsd-boot) of a GPT partitioned drive ad0: "gpart bootcode -p /boot/gptzfsboot -i 1 ad0" Non-boot pools do not need these updates. To build a kernel ----------------- If you are updating from a prior version of FreeBSD (even one just a few days old), you should follow this procedure. It is the most failsafe as it uses a /usr/obj tree with a fresh mini-buildworld, make kernel-toolchain make -DALWAYS_CHECK_MAKE buildkernel KERNCONF=YOUR_KERNEL_HERE make -DALWAYS_CHECK_MAKE installkernel KERNCONF=YOUR_KERNEL_HERE To test a kernel once --------------------- If you just want to boot a kernel once (because you are not sure if it works, or if you want to boot a known bad kernel to provide debugging information) run make installkernel KERNCONF=YOUR_KERNEL_HERE KODIR=/boot/testkernel nextboot -k testkernel To just build a kernel when you know that it won't mess you up -------------------------------------------------------------- This assumes you are already running a CURRENT system. Replace ${arch} with the architecture of your machine (e.g. "i386", "arm", "amd64", "ia64", "pc98", "sparc64", "powerpc", "mips", etc). cd src/sys/${arch}/conf config KERNEL_NAME_HERE cd ../compile/KERNEL_NAME_HERE make depend make make install If this fails, go to the "To build a kernel" section. To rebuild everything and install it on the current system. ----------------------------------------------------------- # Note: sometimes if you are running current you gotta do more than # is listed here if you are upgrading from a really old current. make buildworld make kernel KERNCONF=YOUR_KERNEL_HERE [1] [3] mergemaster -p [5] make installworld mergemaster -i [4] make delete-old [6] To cross-install current onto a separate partition -------------------------------------------------- # In this approach we use a separate partition to hold # current's root, 'usr', and 'var' directories. A partition # holding "/", "/usr" and "/var" should be about 2GB in # size. make buildworld make buildkernel KERNCONF=YOUR_KERNEL_HERE make installworld DESTDIR=${CURRENT_ROOT} make distribution DESTDIR=${CURRENT_ROOT} # if newfs'd make installkernel KERNCONF=YOUR_KERNEL_HERE DESTDIR=${CURRENT_ROOT} cp /etc/fstab ${CURRENT_ROOT}/etc/fstab # if newfs'd To upgrade in-place from stable to current ---------------------------------------------- make buildworld [9] make kernel KERNCONF=YOUR_KERNEL_HERE [8] [1] [3] mergemaster -p [5] make installworld mergemaster -i [4] make delete-old [6] Make sure that you've read the UPDATING file to understand the tweaks to various things you need. At this point in the life cycle of current, things change often and you are on your own to cope. The defaults can also change, so please read ALL of the UPDATING entries. Also, if you are tracking -current, you must be subscribed to freebsd-current@freebsd.org. Make sure that before you update your sources that you have read and understood all the recent messages there. If in doubt, please track -stable which has much fewer pitfalls. [1] If you have third party modules, such as vmware, you should disable them at this point so they don't crash your system on reboot. [3] From the bootblocks, boot -s, and then do fsck -p mount -u / mount -a cd src adjkerntz -i # if CMOS is wall time Also, when doing a major release upgrade, it is required that you boot into single user mode to do the installworld. [4] Note: This step is non-optional. Failure to do this step can result in a significant reduction in the functionality of the system. Attempting to do it by hand is not recommended and those that pursue this avenue should read this file carefully, as well as the archives of freebsd-current and freebsd-hackers mailing lists for potential gotchas. The -U option is also useful to consider. See mergemaster(8) for more information. [5] Usually this step is a noop. However, from time to time you may need to do this if you get unknown user in the following step. It never hurts to do it all the time. You may need to install a new mergemaster (cd src/usr.sbin/mergemaster && make install) after the buildworld before this step if you last updated from current before 20020224 or from -stable before 20020408. [6] This only deletes old files and directories. Old libraries can be deleted by "make delete-old-libs", but you have to make sure that no program is using those libraries anymore. [8] In order to have a kernel that can run the 4.x binaries needed to do an installworld, you must include the COMPAT_FREEBSD4 option in your kernel. Failure to do so may leave you with a system that is hard to boot to recover. A similar kernel option COMPAT_FREEBSD5 is required to run the 5.x binaries on more recent kernels. And so on for COMPAT_FREEBSD6 and COMPAT_FREEBSD7. Make sure that you merge any new devices from GENERIC since the last time you updated your kernel config file. [9] When checking out sources, you must include the -P flag to have cvs prune empty directories. If CPUTYPE is defined in your /etc/make.conf, make sure to use the "?=" instead of the "=" assignment operator, so that buildworld can override the CPUTYPE if it needs to. MAKEOBJDIRPREFIX must be defined in an environment variable, and not on the command line, or in /etc/make.conf. buildworld will warn if it is improperly defined. FORMAT: This file contains a list, in reverse chronological order, of major breakages in tracking -current. It is not guaranteed to be a complete list of such breakages, and only contains entries since October 10, 2007. If you need to see UPDATING entries from before that date, you will need to fetch an UPDATING file from an older FreeBSD release. Copyright information: Copyright 1998-2009 M. Warner Losh. All Rights Reserved. Redistribution, publication, translation and use, with or without modification, in full or in part, in any form or format of this document are permitted without further permission from the author. THIS DOCUMENT IS PROVIDED BY WARNER LOSH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WARNER LOSH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Contact Warner Losh if you have any questions about your use of this document. $FreeBSD$ Index: user/attilio/vmcontention/bin/chio/chio.c =================================================================== --- user/attilio/vmcontention/bin/chio/chio.c (revision 249698) +++ user/attilio/vmcontention/bin/chio/chio.c (revision 249699) @@ -1,1179 +1,1249 @@ /* $NetBSD: chio.c,v 1.6 1998/01/04 23:53:58 thorpej Exp $ */ /*- * Copyright (c) 1996 Jason R. Thorpe * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgements: * This product includes software developed by Jason R. Thorpe * for And Communications, http://www.and.com/ * 4. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Additional Copyright (c) 1997, by Matthew Jacob, for NASA/Ames Research Ctr. * Addidional Copyright (c) 2000, by C. Stephen Gunn, Waterspout Communications */ #if 0 #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1996 Jason R. Thorpe. All rights reserved."; #endif /* not lint */ #endif #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include +#include +#include #include "defs.h" #include "pathnames.h" static void usage(void); static void cleanup(void); static u_int16_t parse_element_type(char *); static u_int16_t parse_element_unit(char *); static const char * element_type_name(int et); static int parse_special(char *); static int is_special(char *); static const char *bits_to_string(ces_status_flags, const char *); static void find_element(char *, uint16_t *, uint16_t *); static struct changer_element_status *get_element_status (unsigned int, unsigned int, int); static int do_move(const char *, int, char **); static int do_exchange(const char *, int, char **); static int do_position(const char *, int, char **); static int do_params(const char *, int, char **); static int do_getpicker(const char *, int, char **); static int do_setpicker(const char *, int, char **); static int do_status(const char *, int, char **); static int do_ielem(const char *, int, char **); static int do_return(const char *, int, char **); static int do_voltag(const char *, int, char **); +static void print_designator(const char *, u_int8_t, u_int8_t); #ifndef CHET_VT #define CHET_VT 10 /* Completely Arbitrary */ #endif /* Valid changer element types. */ static const struct element_type elements[] = { { "drive", CHET_DT }, { "picker", CHET_MT }, { "portal", CHET_IE }, { "slot", CHET_ST }, { "voltag", CHET_VT }, /* Select tapes by barcode */ { NULL, 0 }, }; /* Valid commands. */ static const struct changer_command commands[] = { { "exchange", do_exchange }, { "getpicker", do_getpicker }, { "ielem", do_ielem }, { "move", do_move }, { "params", do_params }, { "position", do_position }, { "setpicker", do_setpicker }, { "status", do_status }, { "return", do_return }, { "voltag", do_voltag }, { NULL, 0 }, }; /* Valid special words. */ static const struct special_word specials[] = { { "inv", SW_INVERT }, { "inv1", SW_INVERT1 }, { "inv2", SW_INVERT2 }, { NULL, 0 }, }; static int changer_fd; static const char *changer_name; int main(int argc, char **argv) { int ch, i; while ((ch = getopt(argc, argv, "f:")) != -1) { switch (ch) { case 'f': changer_name = optarg; break; default: usage(); } } argc -= optind; argv += optind; if (argc == 0) usage(); /* Get the default changer if not already specified. */ if (changer_name == NULL) if ((changer_name = getenv(CHANGER_ENV_VAR)) == NULL) changer_name = _PATH_CH; /* Open the changer device. */ if ((changer_fd = open(changer_name, O_RDWR, 0600)) == -1) err(1, "%s: open", changer_name); /* Register cleanup function. */ if (atexit(cleanup)) err(1, "can't register cleanup function"); /* Find the specified command. */ for (i = 0; commands[i].cc_name != NULL; ++i) if (strcmp(*argv, commands[i].cc_name) == 0) break; if (commands[i].cc_name == NULL) { /* look for abbreviation */ for (i = 0; commands[i].cc_name != NULL; ++i) if (strncmp(*argv, commands[i].cc_name, strlen(*argv)) == 0) break; } if (commands[i].cc_name == NULL) errx(1, "unknown command: %s", *argv); exit ((*commands[i].cc_handler)(commands[i].cc_name, argc, argv)); /* NOTREACHED */ } static int do_move(const char *cname, int argc, char **argv) { struct changer_move cmd; int val; /* * On a move command, we expect the following: * * [inv] * * where ET == element type and EU == element unit. */ ++argv; --argc; if (argc < 4) { warnx("%s: too few arguments", cname); goto usage; } else if (argc > 5) { warnx("%s: too many arguments", cname); goto usage; } (void) memset(&cmd, 0, sizeof(cmd)); /* */ cmd.cm_fromtype = parse_element_type(*argv); ++argv; --argc; /* Check for voltag virtual type */ if (CHET_VT == cmd.cm_fromtype) { find_element(*argv, &cmd.cm_fromtype, &cmd.cm_fromunit); } else { /* */ cmd.cm_fromunit = parse_element_unit(*argv); } ++argv; --argc; /* */ cmd.cm_totype = parse_element_type(*argv); ++argv; --argc; /* Check for voltag virtual type, and report error */ if (CHET_VT == cmd.cm_totype) errx(1,"%s: voltag only makes sense as an element source", cname); /* */ cmd.cm_tounit = parse_element_unit(*argv); ++argv; --argc; /* Deal with optional command modifier. */ if (argc) { val = parse_special(*argv); switch (val) { case SW_INVERT: cmd.cm_flags |= CM_INVERT; break; default: errx(1, "%s: inappropriate modifier `%s'", cname, *argv); /* NOTREACHED */ } } /* Send command to changer. */ if (ioctl(changer_fd, CHIOMOVE, &cmd)) err(1, "%s: CHIOMOVE", changer_name); return (0); usage: (void) fprintf(stderr, "usage: %s %s " " [inv]\n", getprogname(), cname); return (1); } static int do_exchange(const char *cname, int argc, char **argv) { struct changer_exchange cmd; int val; /* * On an exchange command, we expect the following: * * [ ] [inv1] [inv2] * * where ET == element type and EU == element unit. */ ++argv; --argc; if (argc < 4) { warnx("%s: too few arguments", cname); goto usage; } else if (argc > 8) { warnx("%s: too many arguments", cname); goto usage; } (void) memset(&cmd, 0, sizeof(cmd)); /* */ cmd.ce_srctype = parse_element_type(*argv); ++argv; --argc; /* Check for voltag virtual type */ if (CHET_VT == cmd.ce_srctype) { find_element(*argv, &cmd.ce_srctype, &cmd.ce_srcunit); } else { /* */ cmd.ce_srcunit = parse_element_unit(*argv); } ++argv; --argc; /* */ cmd.ce_fdsttype = parse_element_type(*argv); ++argv; --argc; /* Check for voltag virtual type */ if (CHET_VT == cmd.ce_fdsttype) { find_element(*argv, &cmd.ce_fdsttype, &cmd.ce_fdstunit); } else { /* */ cmd.ce_fdstunit = parse_element_unit(*argv); } ++argv; --argc; /* * If the next token is a special word or there are no more * arguments, then this is a case of simple exchange. * dst2 == src. */ if ((argc == 0) || is_special(*argv)) { cmd.ce_sdsttype = cmd.ce_srctype; cmd.ce_sdstunit = cmd.ce_srcunit; goto do_special; } /* */ cmd.ce_sdsttype = parse_element_type(*argv); ++argv; --argc; if (CHET_VT == cmd.ce_sdsttype) errx(1,"%s %s: voltag only makes sense as an element source", cname, *argv); /* */ cmd.ce_sdstunit = parse_element_unit(*argv); ++argv; --argc; do_special: /* Deal with optional command modifiers. */ while (argc) { val = parse_special(*argv); ++argv; --argc; switch (val) { case SW_INVERT1: cmd.ce_flags |= CE_INVERT1; break; case SW_INVERT2: cmd.ce_flags |= CE_INVERT2; break; default: errx(1, "%s: inappropriate modifier `%s'", cname, *argv); /* NOTREACHED */ } } /* Send command to changer. */ if (ioctl(changer_fd, CHIOEXCHANGE, &cmd)) err(1, "%s: CHIOEXCHANGE", changer_name); return (0); usage: (void) fprintf(stderr, "usage: %s %s \n" " [ ] [inv1] [inv2]\n", getprogname(), cname); return (1); } static int do_position(const char *cname, int argc, char **argv) { struct changer_position cmd; int val; /* * On a position command, we expect the following: * * [inv] * * where ET == element type and EU == element unit. */ ++argv; --argc; if (argc < 2) { warnx("%s: too few arguments", cname); goto usage; } else if (argc > 3) { warnx("%s: too many arguments", cname); goto usage; } (void) memset(&cmd, 0, sizeof(cmd)); /* */ cmd.cp_type = parse_element_type(*argv); ++argv; --argc; /* */ cmd.cp_unit = parse_element_unit(*argv); ++argv; --argc; /* Deal with optional command modifier. */ if (argc) { val = parse_special(*argv); switch (val) { case SW_INVERT: cmd.cp_flags |= CP_INVERT; break; default: errx(1, "%s: inappropriate modifier `%s'", cname, *argv); /* NOTREACHED */ } } /* Send command to changer. */ if (ioctl(changer_fd, CHIOPOSITION, &cmd)) err(1, "%s: CHIOPOSITION", changer_name); return (0); usage: (void) fprintf(stderr, "usage: %s %s [inv]\n", getprogname(), cname); return (1); } /* ARGSUSED */ static int do_params(const char *cname, int argc, char **argv) { struct changer_params data; int picker; /* No arguments to this command. */ ++argv; --argc; if (argc) { warnx("%s: no arguments expected", cname); goto usage; } /* Get params from changer and display them. */ (void) memset(&data, 0, sizeof(data)); if (ioctl(changer_fd, CHIOGPARAMS, &data)) err(1, "%s: CHIOGPARAMS", changer_name); (void) printf("%s: %d slot%s, %d drive%s, %d picker%s", changer_name, data.cp_nslots, (data.cp_nslots > 1) ? "s" : "", data.cp_ndrives, (data.cp_ndrives > 1) ? "s" : "", data.cp_npickers, (data.cp_npickers > 1) ? "s" : ""); if (data.cp_nportals) (void) printf(", %d portal%s", data.cp_nportals, (data.cp_nportals > 1) ? "s" : ""); /* Get current picker from changer and display it. */ if (ioctl(changer_fd, CHIOGPICKER, &picker)) err(1, "%s: CHIOGPICKER", changer_name); (void) printf("\n%s: current picker: %d\n", changer_name, picker); return (0); usage: (void) fprintf(stderr, "usage: %s %s\n", getprogname(), cname); return (1); } /* ARGSUSED */ static int do_getpicker(const char *cname, int argc, char **argv) { int picker; /* No arguments to this command. */ ++argv; --argc; if (argc) { warnx("%s: no arguments expected", cname); goto usage; } /* Get current picker from changer and display it. */ if (ioctl(changer_fd, CHIOGPICKER, &picker)) err(1, "%s: CHIOGPICKER", changer_name); (void) printf("%s: current picker: %d\n", changer_name, picker); return (0); usage: (void) fprintf(stderr, "usage: %s %s\n", getprogname(), cname); return (1); } static int do_setpicker(const char *cname, int argc, char **argv) { int picker; ++argv; --argc; if (argc < 1) { warnx("%s: too few arguments", cname); goto usage; } else if (argc > 1) { warnx("%s: too many arguments", cname); goto usage; } picker = parse_element_unit(*argv); /* Set the changer picker. */ if (ioctl(changer_fd, CHIOSPICKER, &picker)) err(1, "%s: CHIOSPICKER", changer_name); return (0); usage: (void) fprintf(stderr, "usage: %s %s \n", getprogname(), cname); return (1); } static int do_status(const char *cname, int argc, char **argv) { struct changer_params cp; struct changer_element_status_request cesr; int i; u_int16_t base, count, chet, schet, echet; const char *description; int pvoltag = 0; int avoltag = 0; int sense = 0; int scsi = 0; int source = 0; int intaddr = 0; int c; count = 0; base = 0; description = NULL; optind = optreset = 1; while ((c = getopt(argc, argv, "vVsSbaI")) != -1) { switch (c) { case 'v': pvoltag = 1; break; case 'V': avoltag = 1; break; case 's': sense = 1; break; case 'S': source = 1; break; case 'b': scsi = 1; break; case 'I': intaddr = 1; break; case 'a': pvoltag = avoltag = source = sense = scsi = intaddr = 1; break; default: warnx("%s: bad option", cname); goto usage; } } argc -= optind; argv += optind; /* * On a status command, we expect the following: * * [ [ [] ] ] * * where ET == element type, start == first element to report, * end == number of elements to report * * If we get no arguments, we get the status of all * known element types. */ if (argc > 3) { warnx("%s: too many arguments", cname); goto usage; } /* * Get params from changer. Specifically, we need the element * counts. */ if (ioctl(changer_fd, CHIOGPARAMS, (char *)&cp)) err(1, "%s: CHIOGPARAMS", changer_name); if (argc > 0) schet = echet = parse_element_type(argv[0]); else { schet = CHET_MT; echet = CHET_DT; } if (argc > 1) { base = (u_int16_t)atol(argv[1]); count = 1; } if (argc > 2) count = (u_int16_t)atol(argv[2]) - base + 1; for (chet = schet; chet <= echet; ++chet) { switch (chet) { case CHET_MT: if (count == 0) count = cp.cp_npickers; else if (count > cp.cp_npickers) errx(1, "not that many pickers in device"); description = "picker"; break; case CHET_ST: if (count == 0) count = cp.cp_nslots; else if (count > cp.cp_nslots) errx(1, "not that many slots in device"); description = "slot"; break; case CHET_IE: if (count == 0) count = cp.cp_nportals; else if (count > cp.cp_nportals) errx(1, "not that many portals in device"); description = "portal"; break; case CHET_DT: if (count == 0) count = cp.cp_ndrives; else if (count > cp.cp_ndrives) errx(1, "not that many drives in device"); description = "drive"; break; default: /* To appease gcc -Wuninitialized. */ count = 0; description = NULL; } if (count == 0) { if (argc == 0) continue; else { printf("%s: no %s elements\n", changer_name, description); return (0); } } bzero(&cesr, sizeof(cesr)); cesr.cesr_element_type = chet; cesr.cesr_element_base = base; cesr.cesr_element_count = count; /* Allocate storage for the status structures. */ cesr.cesr_element_status = (struct changer_element_status *) calloc((size_t)count, sizeof(struct changer_element_status)); if (!cesr.cesr_element_status) errx(1, "can't allocate status storage"); if (avoltag || pvoltag) cesr.cesr_flags |= CESR_VOLTAGS; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr)) { free(cesr.cesr_element_status); err(1, "%s: CHIOGSTATUS", changer_name); } /* Dump the status for each reported element. */ for (i = 0; i < count; ++i) { struct changer_element_status *ces = &(cesr.cesr_element_status[i]); printf("%s %d: %s", description, ces->ces_addr, bits_to_string(ces->ces_flags, CESTATUS_BITS)); if (sense) printf(" sense: <0x%02x/0x%02x>", ces->ces_sensecode, ces->ces_sensequal); if (pvoltag) printf(" voltag: <%s:%d>", ces->ces_pvoltag.cv_volid, ces->ces_pvoltag.cv_serial); if (avoltag) printf(" avoltag: <%s:%d>", ces->ces_avoltag.cv_volid, ces->ces_avoltag.cv_serial); if (source) { if (ces->ces_flags & CES_SOURCE_VALID) printf(" source: <%s %d>", element_type_name( ces->ces_source_type), ces->ces_source_addr); else printf(" source: <>"); } if (intaddr) printf(" intaddr: <%d>", ces->ces_int_addr); if (scsi) { printf(" scsi: <"); if (ces->ces_flags & CES_SCSIID_VALID) printf("%d", ces->ces_scsi_id); else putchar('?'); putchar(':'); if (ces->ces_flags & CES_LUN_VALID) printf("%d", ces->ces_scsi_lun); else putchar('?'); putchar('>'); } + if (ces->ces_designator_length > 0) + print_designator(ces->ces_designator, + ces->ces_code_set, + ces->ces_designator_length); putchar('\n'); } free(cesr.cesr_element_status); count = 0; } return (0); usage: (void) fprintf(stderr, "usage: %s %s [-vVsSbaA] [ [ [] ] ]\n", getprogname(), cname); return (1); } static int do_ielem(const char *cname, int argc, char **argv) { int timeout = 0; if (argc == 2) { timeout = atol(argv[1]); } else if (argc > 1) { warnx("%s: too many arguments", cname); goto usage; } if (ioctl(changer_fd, CHIOIELEM, &timeout)) err(1, "%s: CHIOIELEM", changer_name); return (0); usage: (void) fprintf(stderr, "usage: %s %s []\n", getprogname(), cname); return (1); } static int do_voltag(const char *cname, int argc, char **argv) { int force = 0; int clear = 0; int alternate = 0; int c; struct changer_set_voltag_request csvr; bzero(&csvr, sizeof(csvr)); optind = optreset = 1; while ((c = getopt(argc, argv, "fca")) != -1) { switch (c) { case 'f': force = 1; break; case 'c': clear = 1; break; case 'a': alternate = 1; break; default: warnx("%s: bad option", cname); goto usage; } } argc -= optind; argv += optind; if (argc < 2) { warnx("%s: missing element specification", cname); goto usage; } csvr.csvr_type = parse_element_type(argv[0]); csvr.csvr_addr = (u_int16_t)atol(argv[1]); if (!clear) { if (argc < 3 || argc > 4) { warnx("%s: missing argument", cname); goto usage; } if (force) csvr.csvr_flags = CSVR_MODE_REPLACE; else csvr.csvr_flags = CSVR_MODE_SET; if (strlen(argv[2]) > sizeof(csvr.csvr_voltag.cv_volid)) { warnx("%s: volume label too long", cname); goto usage; } strlcpy((char *)csvr.csvr_voltag.cv_volid, argv[2], sizeof(csvr.csvr_voltag.cv_volid)); if (argc == 4) { csvr.csvr_voltag.cv_serial = (u_int16_t)atol(argv[3]); } } else { if (argc != 2) { warnx("%s: unexpected argument", cname); goto usage; } csvr.csvr_flags = CSVR_MODE_CLEAR; } if (alternate) { csvr.csvr_flags |= CSVR_ALTERNATE; } if (ioctl(changer_fd, CHIOSETVOLTAG, &csvr)) err(1, "%s: CHIOSETVOLTAG", changer_name); return 0; usage: (void) fprintf(stderr, "usage: %s %s [-fca] [ [] ]\n", getprogname(), cname); return 1; } static u_int16_t parse_element_type(char *cp) { int i; for (i = 0; elements[i].et_name != NULL; ++i) if (strcmp(elements[i].et_name, cp) == 0) return ((u_int16_t)elements[i].et_type); errx(1, "invalid element type `%s'", cp); /* NOTREACHED */ } static const char * element_type_name(int et) { int i; for (i = 0; elements[i].et_name != NULL; i++) if (elements[i].et_type == et) return elements[i].et_name; return "unknown"; } static u_int16_t parse_element_unit(char *cp) { int i; char *p; i = (int)strtol(cp, &p, 10); if ((i < 0) || (*p != '\0')) errx(1, "invalid unit number `%s'", cp); return ((u_int16_t)i); } static int parse_special(char *cp) { int val; val = is_special(cp); if (val) return (val); errx(1, "invalid modifier `%s'", cp); /* NOTREACHED */ } static int is_special(char *cp) { int i; for (i = 0; specials[i].sw_name != NULL; ++i) if (strcmp(specials[i].sw_name, cp) == 0) return (specials[i].sw_value); return (0); } static const char * bits_to_string(ces_status_flags v, const char *cp) { const char *np; char f, sep, *bp; static char buf[128]; bp = buf; (void) memset(buf, 0, sizeof(buf)); for (sep = '<'; (f = *cp++) != 0; cp = np) { for (np = cp; *np >= ' ';) np++; if (((int)v & (1 << (f - 1))) == 0) continue; (void) snprintf(bp, sizeof(buf) - (size_t)(bp - &buf[0]), "%c%.*s", sep, (int)(long)(np - cp), cp); bp += strlen(bp); sep = ','; } if (sep != '<') *bp = '>'; return (buf); } /* * do_return() * * Given an element reference, ask the changer/picker to move that * element back to its source slot. */ static int do_return(const char *cname, int argc, char **argv) { struct changer_element_status *ces; struct changer_move cmd; uint16_t type, element; ++argv; --argc; if (argc < 2) { warnx("%s: too few arguments", cname); goto usage; } else if (argc > 3) { warnx("%s: too many arguments", cname); goto usage; } type = parse_element_type(*argv); ++argv; --argc; /* Handle voltag virtual Changer Element Type */ if (CHET_VT == type) { find_element(*argv, &type, &element); } else { element = parse_element_unit(*argv); } ++argv; --argc; /* Get the status */ ces = get_element_status((unsigned int)type, (unsigned int)element, CHET_VT == type); if (NULL == ces) errx(1, "%s: null element status pointer", cname); if (!(ces->ces_flags & CES_SOURCE_VALID)) errx(1, "%s: no source information", cname); (void) memset(&cmd, 0, sizeof(cmd)); cmd.cm_fromtype = type; cmd.cm_fromunit = element; cmd.cm_totype = ces->ces_source_type; cmd.cm_tounit = ces->ces_source_addr; if (ioctl(changer_fd, CHIOMOVE, &cmd) == -1) err(1, "%s: CHIOMOVE", changer_name); free(ces); return(0); usage: (void) fprintf(stderr, "usage: %s %s " " \n", getprogname(), cname); return(1); } /* * get_element_status() * * return a *cesr for the specified changer element. This * routing will malloc()/calloc() the memory. The caller * should free() it when done. */ static struct changer_element_status * get_element_status(unsigned int type, unsigned int element, int use_voltags) { struct changer_element_status_request cesr; struct changer_element_status *ces; ces = (struct changer_element_status *) calloc((size_t)1, sizeof(struct changer_element_status)); if (NULL == ces) errx(1, "can't allocate status storage"); (void)memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = (uint16_t)type; cesr.cesr_element_base = (uint16_t)element; cesr.cesr_element_count = 1; /* Only this one element */ if (use_voltags) cesr.cesr_flags |= CESR_VOLTAGS; /* Grab voltags as well */ cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { free(ces); err(1, "%s: CHIOGSTATUS", changer_name); /* NOTREACHED */ } return ces; } /* * find_element() * * Given a find the chager element and unit, or exit * with an error if it isn't found. We grab the changer status * and iterate until we find a match, or crap out. */ static void find_element(char *voltag, uint16_t *et, uint16_t *eu) { struct changer_params cp; struct changer_element_status_request cesr; struct changer_element_status *ch_ces, *ces; int found = 0; size_t elem, total_elem; /* * Get the changer parameters, we're interested in the counts * for all types of elements to perform our search. */ if (ioctl(changer_fd, CHIOGPARAMS, (char *)&cp)) err(1, "%s: CHIOGPARAMS", changer_name); /* Allocate some memory for the results */ total_elem = (cp.cp_nslots + cp.cp_ndrives + cp.cp_npickers + cp.cp_nportals); ch_ces = (struct changer_element_status *) calloc(total_elem, sizeof(struct changer_element_status)); if (NULL == ch_ces) errx(1, "can't allocate status storage"); ces = ch_ces; /* Read in the changer slots */ if (cp.cp_nslots > 0) { (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_ST; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_nslots; cesr.cesr_flags |= CESR_VOLTAGS; cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { free(ch_ces); err(1, "%s: CHIOGSTATUS", changer_name); } ces += cp.cp_nslots; } /* Read in the drive information */ if (cp.cp_ndrives > 0 ) { (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_DT; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_ndrives; cesr.cesr_flags |= CESR_VOLTAGS; cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { free(ch_ces); err(1, "%s: CHIOGSTATUS", changer_name); } ces += cp.cp_ndrives; } /* Read in the portal information */ if (cp.cp_nportals > 0 ) { (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_IE; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_nportals; cesr.cesr_flags |= CESR_VOLTAGS; cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { free(ch_ces); err(1, "%s: CHIOGSTATUS", changer_name); } ces += cp.cp_nportals; } /* Read in the picker information */ if (cp.cp_npickers > 0) { (void) memset(&cesr, 0, sizeof(cesr)); cesr.cesr_element_type = CHET_MT; cesr.cesr_element_base = 0; cesr.cesr_element_count = cp.cp_npickers; cesr.cesr_flags |= CESR_VOLTAGS; cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { free(ch_ces); err(1, "%s: CHIOGSTATUS", changer_name); } } /* * Now search the list the specified */ for (elem = 0; elem <= total_elem; ++elem) { ces = &ch_ces[elem]; /* Make sure we have a tape in this element */ if ((ces->ces_flags & (CES_STATUS_ACCESS|CES_STATUS_FULL)) != (CES_STATUS_ACCESS|CES_STATUS_FULL)) continue; /* Check to see if it is our target */ if (strcasecmp(voltag, (const char *)ces->ces_pvoltag.cv_volid) == 0) { *et = ces->ces_type; *eu = ces->ces_addr; ++found; break; } } if (!found) { errx(1, "%s: unable to locate voltag: %s", changer_name, voltag); } free(ch_ces); return; } static void cleanup(void) { /* Simple enough... */ (void)close(changer_fd); } static void usage(void) { (void)fprintf(stderr, "usage: %s [-f changer] command [-] " "arg1 arg2 [arg3 [...]]\n", getprogname()); exit(1); +} + +#define UTF8CODESET "UTF-8" + +static void +print_designator(const char *designator, u_int8_t code_set, + u_int8_t designator_length) +{ + printf(" serial number: <"); + switch (code_set) { + case CES_CODE_SET_ASCII: { + /* + * The driver insures that the string is always NUL terminated. + */ + printf("%s", designator); + break; + } + case CES_CODE_SET_UTF_8: { + char *cs_native; + + setlocale(LC_ALL, ""); + cs_native = nl_langinfo(CODESET); + + /* See if we can natively print UTF-8 */ + if (strcmp(cs_native, UTF8CODESET) == 0) + cs_native = NULL; + + if (cs_native == NULL) { + /* We can natively print UTF-8, so use printf. */ + printf("%s", designator); + } else { + int i; + + /* + * We can't natively print UTF-8. We should + * convert it to the terminal's codeset, but that + * requires iconv(3) and FreeBSD doesn't have + * iconv(3) in the base system yet. So we use %XX + * notation for non US-ASCII characters instead. + */ + for (i = 0; i < designator_length && + designator[i] != '\0'; i++) { + if ((unsigned char)designator[i] < 0x80) + printf("%c", designator[i]); + else + printf("%%%02x", + (unsigned char)designator[i]); + } + } + break; + } + case CES_CODE_SET_BINARY: { + int i; + + for (i = 0; i < designator_length; i++) + printf("%02X%s", designator[i], + (i == designator_length - 1) ? "" : " "); + break; + } + default: + break; + } + printf(">"); } Index: user/attilio/vmcontention/bin/df/df.c =================================================================== --- user/attilio/vmcontention/bin/df/df.c (revision 249698) +++ user/attilio/vmcontention/bin/df/df.c (revision 249699) @@ -1,637 +1,639 @@ /*- * Copyright (c) 1980, 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if 0 #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1980, 1990, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)df.c 8.9 (Berkeley) 5/8/95"; #endif /* not lint */ #endif #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "extern.h" #define UNITS_SI 1 #define UNITS_2 2 /* Maximum widths of various fields. */ struct maxwidths { int mntfrom; int fstype; int total; int used; int avail; int iused; int ifree; }; static void addstat(struct statfs *, struct statfs *); static char *getmntpt(const char *); static int int64width(int64_t); static char *makenetvfslist(void); static void prthuman(const struct statfs *, int64_t); static void prthumanval(int64_t); static intmax_t fsbtoblk(int64_t, uint64_t, u_long); static void prtstat(struct statfs *, struct maxwidths *); static size_t regetmntinfo(struct statfs **, long, const char **); static void update_maxwidths(struct maxwidths *, const struct statfs *); static void usage(void); static __inline int imax(int a, int b) { return (a > b ? a : b); } static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag, Tflag; static int thousands; static struct ufs_args mdev; int main(int argc, char *argv[]) { struct stat stbuf; struct statfs statfsbuf, totalbuf; struct maxwidths maxwidths; struct statfs *mntbuf; const char *fstype; char *mntpath, *mntpt; const char **vfslist; int i, mntsize; int ch, rv; fstype = "ufs"; (void)setlocale(LC_ALL, ""); + memset(&maxwidths, 0, sizeof(maxwidths)); memset(&totalbuf, 0, sizeof(totalbuf)); totalbuf.f_bsize = DEV_BSIZE; strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); vfslist = NULL; while ((ch = getopt(argc, argv, "abcgHhiklmnPt:T,")) != -1) switch (ch) { case 'a': aflag = 1; break; case 'b': /* FALLTHROUGH */ case 'P': /* * POSIX specifically discusses the behavior of * both -k and -P. It states that the blocksize should * be set to 1024. Thus, if this occurs, simply break * rather than clobbering the old blocksize. */ if (kflag) break; setenv("BLOCKSIZE", "512", 1); hflag = 0; break; case 'c': cflag = 1; break; case 'g': setenv("BLOCKSIZE", "1g", 1); hflag = 0; break; case 'H': hflag = UNITS_SI; break; case 'h': hflag = UNITS_2; break; case 'i': iflag = 1; break; case 'k': kflag++; setenv("BLOCKSIZE", "1024", 1); hflag = 0; break; case 'l': if (vfslist != NULL) errx(1, "-l and -t are mutually exclusive."); vfslist = makevfslist(makenetvfslist()); lflag = 1; break; case 'm': setenv("BLOCKSIZE", "1m", 1); hflag = 0; break; case 'n': nflag = 1; break; case 't': if (lflag) errx(1, "-l and -t are mutually exclusive."); if (vfslist != NULL) errx(1, "only one -t option may be specified"); fstype = optarg; vfslist = makevfslist(optarg); break; case 'T': Tflag = 1; break; case ',': thousands = 1; break; case '?': default: usage(); } argc -= optind; argv += optind; rv = 0; if (!*argv) { /* everything (modulo -t) */ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); mntsize = regetmntinfo(&mntbuf, mntsize, vfslist); } else { /* just the filesystems specified on the command line */ mntbuf = malloc(argc * sizeof(*mntbuf)); - if (mntbuf == 0) + if (mntbuf == NULL) err(1, "malloc()"); mntsize = 0; /* continued in for loop below */ } /* iterate through specified filesystems */ for (; *argv; argv++) { if (stat(*argv, &stbuf) < 0) { - if ((mntpt = getmntpt(*argv)) == 0) { + if ((mntpt = getmntpt(*argv)) == NULL) { warn("%s", *argv); rv = 1; continue; } } else if (S_ISCHR(stbuf.st_mode)) { - if ((mntpt = getmntpt(*argv)) == 0) { + if ((mntpt = getmntpt(*argv)) == NULL) { mdev.fspec = *argv; mntpath = strdup("/tmp/df.XXXXXX"); if (mntpath == NULL) { warn("strdup failed"); rv = 1; continue; } mntpt = mkdtemp(mntpath); if (mntpt == NULL) { warn("mkdtemp(\"%s\") failed", mntpath); rv = 1; free(mntpath); continue; } if (mount(fstype, mntpt, MNT_RDONLY, &mdev) != 0) { warn("%s", *argv); rv = 1; (void)rmdir(mntpt); free(mntpath); continue; } else if (statfs(mntpt, &statfsbuf) == 0) { statfsbuf.f_mntonname[0] = '\0'; prtstat(&statfsbuf, &maxwidths); if (cflag) addstat(&totalbuf, &statfsbuf); } else { warn("%s", *argv); rv = 1; } (void)unmount(mntpt, 0); (void)rmdir(mntpt); free(mntpath); continue; } } else mntpt = *argv; /* * Statfs does not take a `wait' flag, so we cannot * implement nflag here. */ if (statfs(mntpt, &statfsbuf) < 0) { warn("%s", mntpt); rv = 1; continue; } /* * Check to make sure the arguments we've been given are * satisfied. Return an error if we have been asked to * list a mount point that does not match the other args * we've been given (-l, -t, etc.). */ if (checkvfsname(statfsbuf.f_fstypename, vfslist)) { rv = 1; continue; } /* the user asked for it, so ignore the ignore flag */ statfsbuf.f_flags &= ~MNT_IGNORE; /* add to list */ mntbuf[mntsize++] = statfsbuf; } - bzero(&maxwidths, sizeof(maxwidths)); + memset(&maxwidths, 0, sizeof(maxwidths)); for (i = 0; i < mntsize; i++) { if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) { update_maxwidths(&maxwidths, &mntbuf[i]); if (cflag) addstat(&totalbuf, &mntbuf[i]); } } for (i = 0; i < mntsize; i++) if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0) prtstat(&mntbuf[i], &maxwidths); if (cflag) prtstat(&totalbuf, &maxwidths); + free(mntbuf); return (rv); } static char * getmntpt(const char *name) { size_t mntsize, i; struct statfs *mntbuf; mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = 0; i < mntsize; i++) { if (!strcmp(mntbuf[i].f_mntfromname, name)) return (mntbuf[i].f_mntonname); } - return (0); + return (NULL); } /* * Make a pass over the file system info in ``mntbuf'' filtering out * file system types not in vfslist and possibly re-stating to get * current (not cached) info. Returns the new count of valid statfs bufs. */ static size_t regetmntinfo(struct statfs **mntbufp, long mntsize, const char **vfslist) { int error, i, j; struct statfs *mntbuf; if (vfslist == NULL) return (nflag ? mntsize : getmntinfo(mntbufp, MNT_WAIT)); mntbuf = *mntbufp; for (j = 0, i = 0; i < mntsize; i++) { if (checkvfsname(mntbuf[i].f_fstypename, vfslist)) continue; /* * XXX statfs(2) can fail for various reasons. It may be * possible that the user does not have access to the * pathname, if this happens, we will fall back on * "stale" filesystem statistics. */ error = statfs(mntbuf[i].f_mntonname, &mntbuf[j]); if (nflag || error < 0) if (i != j) { if (error < 0) warnx("%s stats possibly stale", mntbuf[i].f_mntonname); mntbuf[j] = mntbuf[i]; } j++; } return (j); } static void prthuman(const struct statfs *sfsp, int64_t used) { prthumanval(sfsp->f_blocks * sfsp->f_bsize); prthumanval(used * sfsp->f_bsize); prthumanval(sfsp->f_bavail * sfsp->f_bsize); } static void prthumanval(int64_t bytes) { char buf[6]; int flags; flags = HN_B | HN_NOSPACE | HN_DECIMAL; if (hflag == UNITS_SI) flags |= HN_DIVISOR_1000; humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, flags); (void)printf(" %6s", buf); } /* * Print an inode count in "human-readable" format. */ static void prthumanvalinode(int64_t bytes) { char buf[6]; int flags; flags = HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000; humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, flags); (void)printf(" %5s", buf); } /* * Convert statfs returned file system size into BLOCKSIZE units. */ static intmax_t fsbtoblk(int64_t num, uint64_t fsbs, u_long bs) { return (num * (intmax_t) fsbs / (int64_t) bs); } /* * Print out status about a file system. */ static void prtstat(struct statfs *sfsp, struct maxwidths *mwp) { static long blocksize; static int headerlen, timesthrough = 0; static const char *header; int64_t used, availblks, inodes; const char *format; if (++timesthrough == 1) { mwp->mntfrom = imax(mwp->mntfrom, (int)strlen("Filesystem")); mwp->fstype = imax(mwp->fstype, (int)strlen("Type")); if (thousands) { /* make space for commas */ mwp->total += (mwp->total - 1) / 3; mwp->used += (mwp->used - 1) / 3; mwp->avail += (mwp->avail - 1) / 3; mwp->iused += (mwp->iused - 1) / 3; mwp->ifree += (mwp->ifree - 1) / 3; } if (hflag) { header = " Size"; mwp->total = mwp->used = mwp->avail = (int)strlen(header); } else { header = getbsize(&headerlen, &blocksize); mwp->total = imax(mwp->total, headerlen); } mwp->used = imax(mwp->used, (int)strlen("Used")); mwp->avail = imax(mwp->avail, (int)strlen("Avail")); (void)printf("%-*s", mwp->mntfrom, "Filesystem"); if (Tflag) (void)printf(" %-*s", mwp->fstype, "Type"); (void)printf(" %*s %*s %*s Capacity", mwp->total, header, mwp->used, "Used", mwp->avail, "Avail"); if (iflag) { mwp->iused = imax(hflag ? 0 : mwp->iused, (int)strlen(" iused")); mwp->ifree = imax(hflag ? 0 : mwp->ifree, (int)strlen("ifree")); (void)printf(" %*s %*s %%iused", mwp->iused - 2, "iused", mwp->ifree, "ifree"); } (void)printf(" Mounted on\n"); } /* Check for 0 block size. Can this happen? */ if (sfsp->f_bsize == 0) { warnx ("File system %s does not have a block size, assuming 512.", sfsp->f_mntonname); sfsp->f_bsize = 512; } (void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname); if (Tflag) (void)printf(" %-*s", mwp->fstype, sfsp->f_fstypename); used = sfsp->f_blocks - sfsp->f_bfree; availblks = sfsp->f_bavail + used; if (hflag) { prthuman(sfsp, used); } else { if (thousands) format = " %*j'd %*j'd %*j'd"; else format = " %*jd %*jd %*jd"; (void)printf(format, mwp->total, fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize), mwp->used, fsbtoblk(used, sfsp->f_bsize, blocksize), mwp->avail, fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize)); } (void)printf(" %5.0f%%", availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0); if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; if (hflag) { (void)printf(" "); prthumanvalinode(used); prthumanvalinode(sfsp->f_ffree); } else { if (thousands) format = " %*j'd %*j'd"; else format = " %*jd %*jd"; (void)printf(format, mwp->iused, (intmax_t)used, mwp->ifree, (intmax_t)sfsp->f_ffree); } (void)printf(" %4.0f%% ", inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0); } else (void)printf(" "); if (strncmp(sfsp->f_mntfromname, "total", MNAMELEN) != 0) (void)printf(" %s", sfsp->f_mntonname); (void)printf("\n"); } static void addstat(struct statfs *totalfsp, struct statfs *statfsp) { uint64_t bsize; bsize = statfsp->f_bsize / totalfsp->f_bsize; totalfsp->f_blocks += statfsp->f_blocks * bsize; totalfsp->f_bfree += statfsp->f_bfree * bsize; totalfsp->f_bavail += statfsp->f_bavail * bsize; totalfsp->f_files += statfsp->f_files; totalfsp->f_ffree += statfsp->f_ffree; } /* * Update the maximum field-width information in `mwp' based on * the file system specified by `sfsp'. */ static void update_maxwidths(struct maxwidths *mwp, const struct statfs *sfsp) { static long blocksize = 0; int dummy; if (blocksize == 0) getbsize(&dummy, &blocksize); mwp->mntfrom = imax(mwp->mntfrom, (int)strlen(sfsp->f_mntfromname)); mwp->fstype = imax(mwp->fstype, (int)strlen(sfsp->f_fstypename)); mwp->total = imax(mwp->total, int64width( fsbtoblk((int64_t)sfsp->f_blocks, sfsp->f_bsize, blocksize))); mwp->used = imax(mwp->used, int64width(fsbtoblk((int64_t)sfsp->f_blocks - (int64_t)sfsp->f_bfree, sfsp->f_bsize, blocksize))); mwp->avail = imax(mwp->avail, int64width(fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize))); mwp->iused = imax(mwp->iused, int64width((int64_t)sfsp->f_files - sfsp->f_ffree)); mwp->ifree = imax(mwp->ifree, int64width(sfsp->f_ffree)); } /* Return the width in characters of the specified value. */ static int int64width(int64_t val) { int len; len = 0; /* Negative or zero values require one extra digit. */ if (val <= 0) { val = -val; len++; } while (val > 0) { len++; val /= 10; } return (len); } static void usage(void) { (void)fprintf(stderr, "usage: df [-b | -g | -H | -h | -k | -m | -P] [-acilnT] [-t type] [-,]\n" " [file | filesystem ...]\n"); exit(EX_USAGE); } static char * makenetvfslist(void) { char *str, *strptr, **listptr; struct xvfsconf *xvfsp, *keep_xvfsp; size_t buflen; int cnt, i, maxvfsconf; if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) { warn("sysctl(vfs.conflist)"); return (NULL); } xvfsp = malloc(buflen); if (xvfsp == NULL) { warnx("malloc failed"); return (NULL); } keep_xvfsp = xvfsp; if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) { warn("sysctl(vfs.conflist)"); free(keep_xvfsp); return (NULL); } maxvfsconf = buflen / sizeof(struct xvfsconf); if ((listptr = malloc(sizeof(char*) * maxvfsconf)) == NULL) { warnx("malloc failed"); free(keep_xvfsp); return (NULL); } for (cnt = 0, i = 0; i < maxvfsconf; i++) { if (xvfsp->vfc_flags & VFCF_NETWORK) { listptr[cnt++] = strdup(xvfsp->vfc_name); if (listptr[cnt-1] == NULL) { warnx("malloc failed"); free(listptr); free(keep_xvfsp); return (NULL); } } xvfsp++; } if (cnt == 0 || (str = malloc(sizeof(char) * (32 * cnt + cnt + 2))) == NULL) { if (cnt > 0) warnx("malloc failed"); free(listptr); free(keep_xvfsp); return (NULL); } *str = 'n'; *(str + 1) = 'o'; for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) { strlcpy(strptr, listptr[i], 32); strptr += strlen(listptr[i]); *strptr = ','; free(listptr[i]); } *(--strptr) = '\0'; free(keep_xvfsp); free(listptr); return (str); } Index: user/attilio/vmcontention/bin/expr/Makefile =================================================================== --- user/attilio/vmcontention/bin/expr/Makefile (revision 249698) +++ user/attilio/vmcontention/bin/expr/Makefile (revision 249699) @@ -1,7 +1,9 @@ # $FreeBSD$ PROG= expr SRCS= expr.y YFLAGS= +NO_WMISSING_VARIABLE_DECLARATIONS= + .include Index: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c =================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c (revision 249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c (revision 249699) @@ -1,1384 +1,1384 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Create and parse buffers containing CTF data. */ #include #include #include #include #include #include #include #include "ctf_headers.h" #include "ctftools.h" #include "strtab.h" #include "memory.h" /* * Name of the file currently being read, used to print error messages. We * assume that only one file will be read at a time, and thus make no attempt * to allow curfile to be used simultaneously by multiple threads. * * The value is only valid during a call to ctf_load. */ -char *curfile; +static char *curfile; #define CTF_BUF_CHUNK_SIZE (64 * 1024) #define RES_BUF_CHUNK_SIZE (64 * 1024) struct ctf_buf { strtab_t ctb_strtab; /* string table */ caddr_t ctb_base; /* pointer to base of buffer */ caddr_t ctb_end; /* pointer to end of buffer */ caddr_t ctb_ptr; /* pointer to empty buffer space */ size_t ctb_size; /* size of buffer */ int nptent; /* number of processed types */ int ntholes; /* number of type holes */ }; /* * Macros to reverse byte order */ #define BSWAP_8(x) ((x) & 0xff) #define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) #define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) #define SWAP_16(x) (x) = BSWAP_16(x) #define SWAP_32(x) (x) = BSWAP_32(x) static int target_requires_swap; /*PRINTFLIKE1*/ static void parseterminate(const char *fmt, ...) { static char msgbuf[1024]; /* sigh */ va_list ap; va_start(ap, fmt); vsnprintf(msgbuf, sizeof (msgbuf), fmt, ap); va_end(ap); terminate("%s: %s\n", curfile, msgbuf); } static void ctf_buf_grow(ctf_buf_t *b) { off_t ptroff = b->ctb_ptr - b->ctb_base; b->ctb_size += CTF_BUF_CHUNK_SIZE; b->ctb_base = xrealloc(b->ctb_base, b->ctb_size); b->ctb_end = b->ctb_base + b->ctb_size; b->ctb_ptr = b->ctb_base + ptroff; } static ctf_buf_t * ctf_buf_new(void) { ctf_buf_t *b = xcalloc(sizeof (ctf_buf_t)); strtab_create(&b->ctb_strtab); ctf_buf_grow(b); return (b); } static void ctf_buf_free(ctf_buf_t *b) { strtab_destroy(&b->ctb_strtab); free(b->ctb_base); free(b); } static uint_t ctf_buf_cur(ctf_buf_t *b) { return (b->ctb_ptr - b->ctb_base); } static void ctf_buf_write(ctf_buf_t *b, void const *p, size_t n) { size_t len; while (n != 0) { if (b->ctb_ptr == b->ctb_end) ctf_buf_grow(b); len = MIN((size_t)(b->ctb_end - b->ctb_ptr), n); bcopy(p, b->ctb_ptr, len); b->ctb_ptr += len; p = (char const *)p + len; n -= len; } } static int write_label(void *arg1, void *arg2) { labelent_t *le = arg1; ctf_buf_t *b = arg2; ctf_lblent_t ctl; ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name); ctl.ctl_typeidx = le->le_idx; if (target_requires_swap) { SWAP_32(ctl.ctl_label); SWAP_32(ctl.ctl_typeidx); } ctf_buf_write(b, &ctl, sizeof (ctl)); return (1); } static void write_objects(iidesc_t *idp, ctf_buf_t *b) { ushort_t id = (idp ? idp->ii_dtype->t_id : 0); ctf_buf_write(b, &id, sizeof (id)); if (target_requires_swap) { SWAP_16(id); } debug(3, "Wrote object %s (%d)\n", (idp ? idp->ii_name : "(null)"), id); } static void write_functions(iidesc_t *idp, ctf_buf_t *b) { ushort_t fdata[2]; ushort_t id; int nargs; int i; if (!idp) { fdata[0] = 0; ctf_buf_write(b, &fdata[0], sizeof (fdata[0])); debug(3, "Wrote function (null)\n"); return; } nargs = idp->ii_nargs + (idp->ii_vargs != 0); if (nargs > CTF_MAX_VLEN) { terminate("function %s has too many args: %d > %d\n", idp->ii_name, nargs, CTF_MAX_VLEN); } fdata[0] = CTF_TYPE_INFO(CTF_K_FUNCTION, 1, nargs); fdata[1] = idp->ii_dtype->t_id; if (target_requires_swap) { SWAP_16(fdata[0]); SWAP_16(fdata[1]); } ctf_buf_write(b, fdata, sizeof (fdata)); for (i = 0; i < idp->ii_nargs; i++) { id = idp->ii_args[i]->t_id; if (target_requires_swap) { SWAP_16(id); } ctf_buf_write(b, &id, sizeof (id)); } if (idp->ii_vargs) { id = 0; ctf_buf_write(b, &id, sizeof (id)); } debug(3, "Wrote function %s (%d args)\n", idp->ii_name, nargs); } /* * Depending on the size of the type being described, either a ctf_stype_t (for * types with size < CTF_LSTRUCT_THRESH) or a ctf_type_t (all others) will be * written. We isolate the determination here so the rest of the writer code * doesn't need to care. */ static void write_sized_type_rec(ctf_buf_t *b, ctf_type_t *ctt, size_t size) { if (size > CTF_MAX_SIZE) { ctt->ctt_size = CTF_LSIZE_SENT; ctt->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size); ctt->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size); if (target_requires_swap) { SWAP_32(ctt->ctt_name); SWAP_16(ctt->ctt_info); SWAP_16(ctt->ctt_size); SWAP_32(ctt->ctt_lsizehi); SWAP_32(ctt->ctt_lsizelo); } ctf_buf_write(b, ctt, sizeof (*ctt)); } else { ctf_stype_t *cts = (ctf_stype_t *)ctt; cts->ctt_size = (ushort_t)size; if (target_requires_swap) { SWAP_32(cts->ctt_name); SWAP_16(cts->ctt_info); SWAP_16(cts->ctt_size); } ctf_buf_write(b, cts, sizeof (*cts)); } } static void write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt) { ctf_stype_t *cts = (ctf_stype_t *)ctt; if (target_requires_swap) { SWAP_32(cts->ctt_name); SWAP_16(cts->ctt_info); SWAP_16(cts->ctt_size); } ctf_buf_write(b, cts, sizeof (*cts)); } static int write_type(void *arg1, void *arg2) { tdesc_t *tp = arg1; ctf_buf_t *b = arg2; elist_t *ep; mlist_t *mp; intr_t *ip; size_t offset; uint_t encoding; uint_t data; int isroot = tp->t_flags & TDESC_F_ISROOT; int i; ctf_type_t ctt; ctf_array_t cta; ctf_member_t ctm; ctf_lmember_t ctlm; ctf_enum_t cte; ushort_t id; ctlm.ctlm_pad = 0; /* * There shouldn't be any holes in the type list (where a hole is * defined as two consecutive tdescs without consecutive ids), but * check for them just in case. If we do find holes, we need to make * fake entries to fill the holes, or we won't be able to reconstruct * the tree from the written data. */ if (++b->nptent < CTF_TYPE_TO_INDEX(tp->t_id)) { debug(2, "genctf: type hole from %d < x < %d\n", b->nptent - 1, CTF_TYPE_TO_INDEX(tp->t_id)); ctt.ctt_name = CTF_TYPE_NAME(CTF_STRTAB_0, 0); ctt.ctt_info = CTF_TYPE_INFO(0, 0, 0); while (b->nptent < CTF_TYPE_TO_INDEX(tp->t_id)) { write_sized_type_rec(b, &ctt, 0); b->nptent++; } } offset = strtab_insert(&b->ctb_strtab, tp->t_name); ctt.ctt_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset); switch (tp->t_type) { case INTRINSIC: ip = tp->t_intr; if (ip->intr_type == INTR_INT) ctt.ctt_info = CTF_TYPE_INFO(CTF_K_INTEGER, isroot, 1); else ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FLOAT, isroot, 1); write_sized_type_rec(b, &ctt, tp->t_size); encoding = 0; if (ip->intr_type == INTR_INT) { if (ip->intr_signed) encoding |= CTF_INT_SIGNED; if (ip->intr_iformat == 'c') encoding |= CTF_INT_CHAR; else if (ip->intr_iformat == 'b') encoding |= CTF_INT_BOOL; else if (ip->intr_iformat == 'v') encoding |= CTF_INT_VARARGS; } else encoding = ip->intr_fformat; data = CTF_INT_DATA(encoding, ip->intr_offset, ip->intr_nbits); if (target_requires_swap) { SWAP_32(data); } ctf_buf_write(b, &data, sizeof (data)); break; case POINTER: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_POINTER, isroot, 0); ctt.ctt_type = tp->t_tdesc->t_id; write_unsized_type_rec(b, &ctt); break; case ARRAY: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_ARRAY, isroot, 1); write_sized_type_rec(b, &ctt, tp->t_size); cta.cta_contents = tp->t_ardef->ad_contents->t_id; cta.cta_index = tp->t_ardef->ad_idxtype->t_id; cta.cta_nelems = tp->t_ardef->ad_nelems; if (target_requires_swap) { SWAP_16(cta.cta_contents); SWAP_16(cta.cta_index); SWAP_32(cta.cta_nelems); } ctf_buf_write(b, &cta, sizeof (cta)); break; case STRUCT: case UNION: for (i = 0, mp = tp->t_members; mp != NULL; mp = mp->ml_next) i++; /* count up struct or union members */ if (i > CTF_MAX_VLEN) { terminate("sou %s has too many members: %d > %d\n", tdesc_name(tp), i, CTF_MAX_VLEN); } if (tp->t_type == STRUCT) ctt.ctt_info = CTF_TYPE_INFO(CTF_K_STRUCT, isroot, i); else ctt.ctt_info = CTF_TYPE_INFO(CTF_K_UNION, isroot, i); write_sized_type_rec(b, &ctt, tp->t_size); if (tp->t_size < CTF_LSTRUCT_THRESH) { for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) { offset = strtab_insert(&b->ctb_strtab, mp->ml_name); ctm.ctm_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset); ctm.ctm_type = mp->ml_type->t_id; ctm.ctm_offset = mp->ml_offset; if (target_requires_swap) { SWAP_32(ctm.ctm_name); SWAP_16(ctm.ctm_type); SWAP_16(ctm.ctm_offset); } ctf_buf_write(b, &ctm, sizeof (ctm)); } } else { for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) { offset = strtab_insert(&b->ctb_strtab, mp->ml_name); ctlm.ctlm_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset); ctlm.ctlm_type = mp->ml_type->t_id; ctlm.ctlm_offsethi = CTF_OFFSET_TO_LMEMHI(mp->ml_offset); ctlm.ctlm_offsetlo = CTF_OFFSET_TO_LMEMLO(mp->ml_offset); if (target_requires_swap) { SWAP_32(ctlm.ctlm_name); SWAP_16(ctlm.ctlm_type); SWAP_32(ctlm.ctlm_offsethi); SWAP_32(ctlm.ctlm_offsetlo); } ctf_buf_write(b, &ctlm, sizeof (ctlm)); } } break; case ENUM: for (i = 0, ep = tp->t_emem; ep != NULL; ep = ep->el_next) i++; /* count up enum members */ if (i > CTF_MAX_VLEN) { warning("enum %s has too many values: %d > %d\n", tdesc_name(tp), i, CTF_MAX_VLEN); i = CTF_MAX_VLEN; } ctt.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, isroot, i); write_sized_type_rec(b, &ctt, tp->t_size); for (ep = tp->t_emem; ep != NULL && i > 0; ep = ep->el_next) { offset = strtab_insert(&b->ctb_strtab, ep->el_name); cte.cte_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset); cte.cte_value = ep->el_number; if (target_requires_swap) { SWAP_32(cte.cte_name); SWAP_32(cte.cte_value); } ctf_buf_write(b, &cte, sizeof (cte)); i--; } break; case FORWARD: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FORWARD, isroot, 0); ctt.ctt_type = 0; write_unsized_type_rec(b, &ctt); break; case TYPEDEF: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_TYPEDEF, isroot, 0); ctt.ctt_type = tp->t_tdesc->t_id; write_unsized_type_rec(b, &ctt); break; case VOLATILE: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_VOLATILE, isroot, 0); ctt.ctt_type = tp->t_tdesc->t_id; write_unsized_type_rec(b, &ctt); break; case CONST: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_CONST, isroot, 0); ctt.ctt_type = tp->t_tdesc->t_id; write_unsized_type_rec(b, &ctt); break; case FUNCTION: i = tp->t_fndef->fn_nargs + tp->t_fndef->fn_vargs; if (i > CTF_MAX_VLEN) { terminate("function %s has too many args: %d > %d\n", i, CTF_MAX_VLEN); } ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, isroot, i); ctt.ctt_type = tp->t_fndef->fn_ret->t_id; write_unsized_type_rec(b, &ctt); for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) { id = tp->t_fndef->fn_args[i]->t_id; if (target_requires_swap) { SWAP_16(id); } ctf_buf_write(b, &id, sizeof (id)); } if (tp->t_fndef->fn_vargs) { id = 0; ctf_buf_write(b, &id, sizeof (id)); i++; } if (i & 1) { id = 0; ctf_buf_write(b, &id, sizeof (id)); } break; case RESTRICT: ctt.ctt_info = CTF_TYPE_INFO(CTF_K_RESTRICT, isroot, 0); ctt.ctt_type = tp->t_tdesc->t_id; write_unsized_type_rec(b, &ctt); break; default: warning("Can't write unknown type %d\n", tp->t_type); } debug(3, "Wrote type %d %s\n", tp->t_id, tdesc_name(tp)); return (1); } typedef struct resbuf { caddr_t rb_base; caddr_t rb_ptr; size_t rb_size; z_stream rb_zstr; } resbuf_t; static void rbzs_grow(resbuf_t *rb) { off_t ptroff = (caddr_t)rb->rb_zstr.next_out - rb->rb_base; rb->rb_size += RES_BUF_CHUNK_SIZE; rb->rb_base = xrealloc(rb->rb_base, rb->rb_size); rb->rb_ptr = rb->rb_base + ptroff; rb->rb_zstr.next_out = (Bytef *)(rb->rb_ptr); rb->rb_zstr.avail_out += RES_BUF_CHUNK_SIZE; } static void compress_start(resbuf_t *rb) { int rc; rb->rb_zstr.zalloc = (alloc_func)0; rb->rb_zstr.zfree = (free_func)0; rb->rb_zstr.opaque = (voidpf)0; if ((rc = deflateInit(&rb->rb_zstr, Z_BEST_COMPRESSION)) != Z_OK) parseterminate("zlib start failed: %s", zError(rc)); } static ssize_t compress_buffer(void *buf, size_t n, void *data) { resbuf_t *rb = (resbuf_t *)data; int rc; rb->rb_zstr.next_out = (Bytef *)rb->rb_ptr; rb->rb_zstr.avail_out = rb->rb_size - (rb->rb_ptr - rb->rb_base); rb->rb_zstr.next_in = buf; rb->rb_zstr.avail_in = n; while (rb->rb_zstr.avail_in) { if (rb->rb_zstr.avail_out == 0) rbzs_grow(rb); if ((rc = deflate(&rb->rb_zstr, Z_NO_FLUSH)) != Z_OK) parseterminate("zlib deflate failed: %s", zError(rc)); } rb->rb_ptr = (caddr_t)rb->rb_zstr.next_out; return (n); } static void compress_flush(resbuf_t *rb, int type) { int rc; for (;;) { if (rb->rb_zstr.avail_out == 0) rbzs_grow(rb); rc = deflate(&rb->rb_zstr, type); if ((type == Z_FULL_FLUSH && rc == Z_BUF_ERROR) || (type == Z_FINISH && rc == Z_STREAM_END)) break; else if (rc != Z_OK) parseterminate("zlib finish failed: %s", zError(rc)); } rb->rb_ptr = (caddr_t)rb->rb_zstr.next_out; } static void compress_end(resbuf_t *rb) { int rc; compress_flush(rb, Z_FINISH); if ((rc = deflateEnd(&rb->rb_zstr)) != Z_OK) parseterminate("zlib end failed: %s", zError(rc)); } /* * Pad the buffer to a power-of-2 boundary */ static void pad_buffer(ctf_buf_t *buf, int align) { uint_t cur = ctf_buf_cur(buf); ssize_t topad = (align - (cur % align)) % align; static const char pad[8] = { 0 }; while (topad > 0) { ctf_buf_write(buf, pad, (topad > 8 ? 8 : topad)); topad -= 8; } } static ssize_t bcopy_data(void *buf, size_t n, void *data) { caddr_t *posp = (caddr_t *)data; bcopy(buf, *posp, n); *posp += n; return (n); } static caddr_t write_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp) { caddr_t outbuf; caddr_t bufpos; outbuf = xmalloc(sizeof (ctf_header_t) + (buf->ctb_ptr - buf->ctb_base) + buf->ctb_strtab.str_size); bufpos = outbuf; (void) bcopy_data(h, sizeof (ctf_header_t), &bufpos); (void) bcopy_data(buf->ctb_base, buf->ctb_ptr - buf->ctb_base, &bufpos); (void) strtab_write(&buf->ctb_strtab, bcopy_data, &bufpos); *resszp = bufpos - outbuf; return (outbuf); } /* * Create the compression buffer, and fill it with the CTF and string * table data. We flush the compression state between the two so the * dictionary used for the string tables won't be polluted with values * that made sense for the CTF data. */ static caddr_t write_compressed_buffer(ctf_header_t *h, ctf_buf_t *buf, size_t *resszp) { resbuf_t resbuf; resbuf.rb_size = RES_BUF_CHUNK_SIZE; resbuf.rb_base = xmalloc(resbuf.rb_size); bcopy(h, resbuf.rb_base, sizeof (ctf_header_t)); resbuf.rb_ptr = resbuf.rb_base + sizeof (ctf_header_t); compress_start(&resbuf); (void) compress_buffer(buf->ctb_base, buf->ctb_ptr - buf->ctb_base, &resbuf); compress_flush(&resbuf, Z_FULL_FLUSH); (void) strtab_write(&buf->ctb_strtab, compress_buffer, &resbuf); compress_end(&resbuf); *resszp = (resbuf.rb_ptr - resbuf.rb_base); return (resbuf.rb_base); } caddr_t ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress) { ctf_buf_t *buf = ctf_buf_new(); ctf_header_t h; caddr_t outbuf; int i; target_requires_swap = do_compress & CTF_SWAP_BYTES; do_compress &= ~CTF_SWAP_BYTES; /* * Prepare the header, and create the CTF output buffers. The data * object section and function section are both lists of 2-byte * integers; we pad these out to the next 4-byte boundary if needed. */ h.cth_magic = CTF_MAGIC; h.cth_version = CTF_VERSION; h.cth_flags = do_compress ? CTF_F_COMPRESS : 0; h.cth_parlabel = strtab_insert(&buf->ctb_strtab, iiburst->iib_td->td_parlabel); h.cth_parname = strtab_insert(&buf->ctb_strtab, iiburst->iib_td->td_parname); h.cth_lbloff = 0; (void) list_iter(iiburst->iib_td->td_labels, write_label, buf); pad_buffer(buf, 2); h.cth_objtoff = ctf_buf_cur(buf); for (i = 0; i < iiburst->iib_nobjts; i++) write_objects(iiburst->iib_objts[i], buf); pad_buffer(buf, 2); h.cth_funcoff = ctf_buf_cur(buf); for (i = 0; i < iiburst->iib_nfuncs; i++) write_functions(iiburst->iib_funcs[i], buf); pad_buffer(buf, 4); h.cth_typeoff = ctf_buf_cur(buf); (void) list_iter(iiburst->iib_types, write_type, buf); debug(2, "CTF wrote %d types\n", list_count(iiburst->iib_types)); h.cth_stroff = ctf_buf_cur(buf); h.cth_strlen = strtab_size(&buf->ctb_strtab); if (target_requires_swap) { SWAP_16(h.cth_preamble.ctp_magic); SWAP_32(h.cth_parlabel); SWAP_32(h.cth_parname); SWAP_32(h.cth_lbloff); SWAP_32(h.cth_objtoff); SWAP_32(h.cth_funcoff); SWAP_32(h.cth_typeoff); SWAP_32(h.cth_stroff); SWAP_32(h.cth_strlen); } /* * We only do compression for ctfmerge, as ctfconvert is only * supposed to be used on intermediary build objects. This is * significantly faster. */ if (do_compress) outbuf = write_compressed_buffer(&h, buf, resszp); else outbuf = write_buffer(&h, buf, resszp); ctf_buf_free(buf); return (outbuf); } static void get_ctt_size(ctf_type_t *ctt, size_t *sizep, size_t *incrementp) { if (ctt->ctt_size == CTF_LSIZE_SENT) { *sizep = (size_t)CTF_TYPE_LSIZE(ctt); *incrementp = sizeof (ctf_type_t); } else { *sizep = ctt->ctt_size; *incrementp = sizeof (ctf_stype_t); } } static int count_types(ctf_header_t *h, caddr_t data) { caddr_t dptr = data + h->cth_typeoff; int count = 0; dptr = data + h->cth_typeoff; while (dptr < data + h->cth_stroff) { void *v = (void *) dptr; ctf_type_t *ctt = v; size_t vlen = CTF_INFO_VLEN(ctt->ctt_info); size_t size, increment; get_ctt_size(ctt, &size, &increment); switch (CTF_INFO_KIND(ctt->ctt_info)) { case CTF_K_INTEGER: case CTF_K_FLOAT: dptr += 4; break; case CTF_K_POINTER: case CTF_K_FORWARD: case CTF_K_TYPEDEF: case CTF_K_VOLATILE: case CTF_K_CONST: case CTF_K_RESTRICT: case CTF_K_FUNCTION: dptr += sizeof (ushort_t) * (vlen + (vlen & 1)); break; case CTF_K_ARRAY: dptr += sizeof (ctf_array_t); break; case CTF_K_STRUCT: case CTF_K_UNION: if (size < CTF_LSTRUCT_THRESH) dptr += sizeof (ctf_member_t) * vlen; else dptr += sizeof (ctf_lmember_t) * vlen; break; case CTF_K_ENUM: dptr += sizeof (ctf_enum_t) * vlen; break; case CTF_K_UNKNOWN: break; default: parseterminate("Unknown CTF type %d (#%d) at %#x", CTF_INFO_KIND(ctt->ctt_info), count, dptr - data); } dptr += increment; count++; } debug(3, "CTF read %d types\n", count); return (count); } /* * Resurrect the labels stored in the CTF data, returning the index associated * with a label provided by the caller. There are several cases, outlined * below. Note that, given two labels, the one associated with the lesser type * index is considered to be older than the other. * * 1. matchlbl == NULL - return the index of the most recent label. * 2. matchlbl == "BASE" - return the index of the oldest label. * 3. matchlbl != NULL, but doesn't match any labels in the section - warn * the user, and proceed as if matchlbl == "BASE" (for safety). * 4. matchlbl != NULL, and matches one of the labels in the section - return * the type index associated with the label. */ static int resurrect_labels(ctf_header_t *h, tdata_t *td, caddr_t ctfdata, char *matchlbl) { caddr_t buf = ctfdata + h->cth_lbloff; caddr_t sbuf = ctfdata + h->cth_stroff; size_t bufsz = h->cth_objtoff - h->cth_lbloff; int lastidx = 0, baseidx = -1; char *baselabel = NULL; ctf_lblent_t *ctl; void *v = (void *) buf; for (ctl = v; (caddr_t)ctl < buf + bufsz; ctl++) { char *label = sbuf + ctl->ctl_label; lastidx = ctl->ctl_typeidx; debug(3, "Resurrected label %s type idx %d\n", label, lastidx); tdata_label_add(td, label, lastidx); if (baseidx == -1) { baseidx = lastidx; baselabel = label; if (matchlbl != NULL && streq(matchlbl, "BASE")) return (lastidx); } if (matchlbl != NULL && streq(label, matchlbl)) return (lastidx); } if (matchlbl != NULL) { /* User provided a label that didn't match */ warning("%s: Cannot find label `%s' - using base (%s)\n", curfile, matchlbl, (baselabel ? baselabel : "NONE")); tdata_label_free(td); tdata_label_add(td, baselabel, baseidx); return (baseidx); } return (lastidx); } static void resurrect_objects(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize, caddr_t ctfdata, symit_data_t *si) { caddr_t buf = ctfdata + h->cth_objtoff; size_t bufsz = h->cth_funcoff - h->cth_objtoff; caddr_t dptr; symit_reset(si); for (dptr = buf; dptr < buf + bufsz; dptr += 2) { void *v = (void *) dptr; ushort_t id = *((ushort_t *)v); iidesc_t *ii; GElf_Sym *sym; if (!(sym = symit_next(si, STT_OBJECT)) && id != 0) { parseterminate( "Unexpected end of object symbols at %x of %x", dptr - buf, bufsz); } if (id == 0) { debug(3, "Skipping null object\n"); continue; } else if (id >= tdsize) { parseterminate("Reference to invalid type %d", id); } ii = iidesc_new(symit_name(si)); ii->ii_dtype = tdarr[id]; if (GELF_ST_BIND(sym->st_info) == STB_LOCAL) { ii->ii_type = II_SVAR; ii->ii_owner = xstrdup(symit_curfile(si)); } else ii->ii_type = II_GVAR; hash_add(td->td_iihash, ii); debug(3, "Resurrected %s object %s (%d) from %s\n", (ii->ii_type == II_GVAR ? "global" : "static"), ii->ii_name, id, (ii->ii_owner ? ii->ii_owner : "(none)")); } } static void resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize, caddr_t ctfdata, symit_data_t *si) { caddr_t buf = ctfdata + h->cth_funcoff; size_t bufsz = h->cth_typeoff - h->cth_funcoff; caddr_t dptr = buf; iidesc_t *ii; ushort_t info; ushort_t retid; GElf_Sym *sym; int i; symit_reset(si); while (dptr < buf + bufsz) { void *v = (void *) dptr; info = *((ushort_t *)v); dptr += 2; if (!(sym = symit_next(si, STT_FUNC)) && info != 0) parseterminate("Unexpected end of function symbols"); if (info == 0) { debug(3, "Skipping null function (%s)\n", symit_name(si)); continue; } v = (void *) dptr; retid = *((ushort_t *)v); dptr += 2; if (retid >= tdsize) parseterminate("Reference to invalid type %d", retid); ii = iidesc_new(symit_name(si)); ii->ii_dtype = tdarr[retid]; if (GELF_ST_BIND(sym->st_info) == STB_LOCAL) { ii->ii_type = II_SFUN; ii->ii_owner = xstrdup(symit_curfile(si)); } else ii->ii_type = II_GFUN; ii->ii_nargs = CTF_INFO_VLEN(info); if (ii->ii_nargs) ii->ii_args = xmalloc(sizeof (tdesc_t *) * ii->ii_nargs); for (i = 0; i < ii->ii_nargs; i++, dptr += 2) { v = (void *) dptr; ushort_t id = *((ushort_t *)v); if (id >= tdsize) parseterminate("Reference to invalid type %d", id); ii->ii_args[i] = tdarr[id]; } if (ii->ii_nargs && ii->ii_args[ii->ii_nargs - 1] == NULL) { ii->ii_nargs--; ii->ii_vargs = 1; } hash_add(td->td_iihash, ii); debug(3, "Resurrected %s function %s (%d, %d args)\n", (ii->ii_type == II_GFUN ? "global" : "static"), ii->ii_name, retid, ii->ii_nargs); } } static void resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize, caddr_t ctfdata, int maxid) { caddr_t buf = ctfdata + h->cth_typeoff; size_t bufsz = h->cth_stroff - h->cth_typeoff; caddr_t sbuf = ctfdata + h->cth_stroff; caddr_t dptr = buf; tdesc_t *tdp; uint_t data; uint_t encoding; size_t size, increment; int tcnt; int iicnt = 0; tid_t tid, argid; int kind, vlen; int i; elist_t **epp; mlist_t **mpp; intr_t *ip; ctf_type_t *ctt; ctf_array_t *cta; ctf_enum_t *cte; /* * A maxid of zero indicates a request to resurrect all types, so reset * maxid to the maximum type id. */ if (maxid == 0) maxid = CTF_MAX_TYPE; for (dptr = buf, tcnt = 0, tid = 1; dptr < buf + bufsz; tcnt++, tid++) { if (tid > maxid) break; if (tid >= tdsize) parseterminate("Reference to invalid type %d", tid); void *v = (void *) dptr; ctt = v; get_ctt_size(ctt, &size, &increment); dptr += increment; tdp = tdarr[tid]; if (CTF_NAME_STID(ctt->ctt_name) != CTF_STRTAB_0) parseterminate( "Unable to cope with non-zero strtab id"); if (CTF_NAME_OFFSET(ctt->ctt_name) != 0) { tdp->t_name = xstrdup(sbuf + CTF_NAME_OFFSET(ctt->ctt_name)); } else tdp->t_name = NULL; kind = CTF_INFO_KIND(ctt->ctt_info); vlen = CTF_INFO_VLEN(ctt->ctt_info); switch (kind) { case CTF_K_INTEGER: tdp->t_type = INTRINSIC; tdp->t_size = size; v = (void *) dptr; data = *((uint_t *)v); dptr += sizeof (uint_t); encoding = CTF_INT_ENCODING(data); ip = xmalloc(sizeof (intr_t)); ip->intr_type = INTR_INT; ip->intr_signed = (encoding & CTF_INT_SIGNED) ? 1 : 0; if (encoding & CTF_INT_CHAR) ip->intr_iformat = 'c'; else if (encoding & CTF_INT_BOOL) ip->intr_iformat = 'b'; else if (encoding & CTF_INT_VARARGS) ip->intr_iformat = 'v'; else ip->intr_iformat = '\0'; ip->intr_offset = CTF_INT_OFFSET(data); ip->intr_nbits = CTF_INT_BITS(data); tdp->t_intr = ip; break; case CTF_K_FLOAT: tdp->t_type = INTRINSIC; tdp->t_size = size; v = (void *) dptr; data = *((uint_t *)v); dptr += sizeof (uint_t); ip = xcalloc(sizeof (intr_t)); ip->intr_type = INTR_REAL; ip->intr_fformat = CTF_FP_ENCODING(data); ip->intr_offset = CTF_FP_OFFSET(data); ip->intr_nbits = CTF_FP_BITS(data); tdp->t_intr = ip; break; case CTF_K_POINTER: tdp->t_type = POINTER; tdp->t_tdesc = tdarr[ctt->ctt_type]; break; case CTF_K_ARRAY: tdp->t_type = ARRAY; tdp->t_size = size; v = (void *) dptr; cta = v; dptr += sizeof (ctf_array_t); tdp->t_ardef = xmalloc(sizeof (ardef_t)); tdp->t_ardef->ad_contents = tdarr[cta->cta_contents]; tdp->t_ardef->ad_idxtype = tdarr[cta->cta_index]; tdp->t_ardef->ad_nelems = cta->cta_nelems; break; case CTF_K_STRUCT: case CTF_K_UNION: tdp->t_type = (kind == CTF_K_STRUCT ? STRUCT : UNION); tdp->t_size = size; if (size < CTF_LSTRUCT_THRESH) { for (i = 0, mpp = &tdp->t_members; i < vlen; i++, mpp = &((*mpp)->ml_next)) { v = (void *) dptr; ctf_member_t *ctm = v; dptr += sizeof (ctf_member_t); *mpp = xmalloc(sizeof (mlist_t)); (*mpp)->ml_name = xstrdup(sbuf + ctm->ctm_name); (*mpp)->ml_type = tdarr[ctm->ctm_type]; (*mpp)->ml_offset = ctm->ctm_offset; (*mpp)->ml_size = 0; } } else { for (i = 0, mpp = &tdp->t_members; i < vlen; i++, mpp = &((*mpp)->ml_next)) { v = (void *) dptr; ctf_lmember_t *ctlm = v; dptr += sizeof (ctf_lmember_t); *mpp = xmalloc(sizeof (mlist_t)); (*mpp)->ml_name = xstrdup(sbuf + ctlm->ctlm_name); (*mpp)->ml_type = tdarr[ctlm->ctlm_type]; (*mpp)->ml_offset = (int)CTF_LMEM_OFFSET(ctlm); (*mpp)->ml_size = 0; } } *mpp = NULL; break; case CTF_K_ENUM: tdp->t_type = ENUM; tdp->t_size = size; for (i = 0, epp = &tdp->t_emem; i < vlen; i++, epp = &((*epp)->el_next)) { v = (void *) dptr; cte = v; dptr += sizeof (ctf_enum_t); *epp = xmalloc(sizeof (elist_t)); (*epp)->el_name = xstrdup(sbuf + cte->cte_name); (*epp)->el_number = cte->cte_value; } *epp = NULL; break; case CTF_K_FORWARD: tdp->t_type = FORWARD; list_add(&td->td_fwdlist, tdp); break; case CTF_K_TYPEDEF: tdp->t_type = TYPEDEF; tdp->t_tdesc = tdarr[ctt->ctt_type]; break; case CTF_K_VOLATILE: tdp->t_type = VOLATILE; tdp->t_tdesc = tdarr[ctt->ctt_type]; break; case CTF_K_CONST: tdp->t_type = CONST; tdp->t_tdesc = tdarr[ctt->ctt_type]; break; case CTF_K_FUNCTION: tdp->t_type = FUNCTION; tdp->t_fndef = xcalloc(sizeof (fndef_t)); tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type]; v = (void *) (dptr + (sizeof (ushort_t) * (vlen - 1))); if (vlen > 0 && *(ushort_t *)v == 0) tdp->t_fndef->fn_vargs = 1; tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs; tdp->t_fndef->fn_args = xcalloc(sizeof (tdesc_t) * vlen - tdp->t_fndef->fn_vargs); for (i = 0; i < vlen; i++) { v = (void *) dptr; argid = *(ushort_t *)v; dptr += sizeof (ushort_t); if (argid != 0) tdp->t_fndef->fn_args[i] = tdarr[argid]; } if (vlen & 1) dptr += sizeof (ushort_t); break; case CTF_K_RESTRICT: tdp->t_type = RESTRICT; tdp->t_tdesc = tdarr[ctt->ctt_type]; break; case CTF_K_UNKNOWN: break; default: warning("Can't parse unknown CTF type %d\n", kind); } if (CTF_INFO_ISROOT(ctt->ctt_info)) { iidesc_t *ii = iidesc_new(tdp->t_name); if (tdp->t_type == STRUCT || tdp->t_type == UNION || tdp->t_type == ENUM) ii->ii_type = II_SOU; else ii->ii_type = II_TYPE; ii->ii_dtype = tdp; hash_add(td->td_iihash, ii); iicnt++; } debug(3, "Resurrected %d %stype %s (%d)\n", tdp->t_type, (CTF_INFO_ISROOT(ctt->ctt_info) ? "root " : ""), tdesc_name(tdp), tdp->t_id); } debug(3, "Resurrected %d types (%d were roots)\n", tcnt, iicnt); } /* * For lack of other inspiration, we're going to take the boring route. We * count the number of types. This lets us malloc that many tdesc structs * before we start filling them in. This has the advantage of allowing us to * avoid a merge-esque remap step. */ static tdata_t * ctf_parse(ctf_header_t *h, caddr_t buf, symit_data_t *si, char *label) { tdata_t *td = tdata_new(); tdesc_t **tdarr; int ntypes = count_types(h, buf); int idx, i; /* shudder */ tdarr = xcalloc(sizeof (tdesc_t *) * (ntypes + 1)); tdarr[0] = NULL; for (i = 1; i <= ntypes; i++) { tdarr[i] = xcalloc(sizeof (tdesc_t)); tdarr[i]->t_id = i; } td->td_parlabel = xstrdup(buf + h->cth_stroff + h->cth_parlabel); /* we have the technology - we can rebuild them */ idx = resurrect_labels(h, td, buf, label); resurrect_objects(h, td, tdarr, ntypes + 1, buf, si); resurrect_functions(h, td, tdarr, ntypes + 1, buf, si); resurrect_types(h, td, tdarr, ntypes + 1, buf, idx); free(tdarr); td->td_nextid = ntypes + 1; return (td); } static size_t decompress_ctf(caddr_t cbuf, size_t cbufsz, caddr_t dbuf, size_t dbufsz) { z_stream zstr; int rc; zstr.zalloc = (alloc_func)0; zstr.zfree = (free_func)0; zstr.opaque = (voidpf)0; zstr.next_in = (Bytef *)cbuf; zstr.avail_in = cbufsz; zstr.next_out = (Bytef *)dbuf; zstr.avail_out = dbufsz; if ((rc = inflateInit(&zstr)) != Z_OK || (rc = inflate(&zstr, Z_NO_FLUSH)) != Z_STREAM_END || (rc = inflateEnd(&zstr)) != Z_OK) { warning("CTF decompress zlib error %s\n", zError(rc)); return (0); } debug(3, "reflated %lu bytes to %lu, pointer at %d\n", zstr.total_in, zstr.total_out, (caddr_t)zstr.next_in - cbuf); return (zstr.total_out); } /* * Reconstruct the type tree from a given buffer of CTF data. Only the types * up to the type associated with the provided label, inclusive, will be * reconstructed. If a NULL label is provided, all types will be reconstructed. * * This function won't work on files that have been uniquified. */ tdata_t * ctf_load(char *file, caddr_t buf, size_t bufsz, symit_data_t *si, char *label) { ctf_header_t *h; caddr_t ctfdata; size_t ctfdatasz; tdata_t *td; curfile = file; if (bufsz < sizeof (ctf_header_t)) parseterminate("Corrupt CTF - short header"); void *v = (void *) buf; h = v; buf += sizeof (ctf_header_t); bufsz -= sizeof (ctf_header_t); if (h->cth_magic != CTF_MAGIC) parseterminate("Corrupt CTF - bad magic 0x%x", h->cth_magic); if (h->cth_version != CTF_VERSION) parseterminate("Unknown CTF version %d", h->cth_version); ctfdatasz = h->cth_stroff + h->cth_strlen; if (h->cth_flags & CTF_F_COMPRESS) { size_t actual; ctfdata = xmalloc(ctfdatasz); if ((actual = decompress_ctf(buf, bufsz, ctfdata, ctfdatasz)) != ctfdatasz) { parseterminate("Corrupt CTF - short decompression " "(was %d, expecting %d)", actual, ctfdatasz); } } else { ctfdata = buf; ctfdatasz = bufsz; } td = ctf_parse(h, ctfdata, si, label); if (h->cth_flags & CTF_F_COMPRESS) free(ctfdata); curfile = NULL; return (td); } Index: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c =================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c (revision 249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c (revision 249699) @@ -1,1210 +1,1210 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. */ /* * This file is a sewer. */ #include #include #include #include #include #include #include #include #include "ctftools.h" #include "memory.h" #include "list.h" #define HASH(NUM) ((int)(NUM & (BUCKETS - 1))) #define BUCKETS 128 #define TYPEPAIRMULT 10000 #define MAKETYPEID(file, num) ((file) * TYPEPAIRMULT + num) #define TYPEFILE(tid) ((tid) / TYPEPAIRMULT) #define TYPENUM(tid) ((tid) % TYPEPAIRMULT) #define expected(a, b, c) _expected(a, b, c, __LINE__) static int faketypenumber = 100000000; static tdesc_t *hash_table[BUCKETS]; static tdesc_t *name_table[BUCKETS]; -list_t *typedbitfldmems; +static list_t *typedbitfldmems; static void reset(void); static jmp_buf resetbuf; static char *soudef(char *cp, stabtype_t type, tdesc_t **rtdp); static void enumdef(char *cp, tdesc_t **rtdp); static int compute_sum(const char *w); static char *number(char *cp, int *n); static char *name(char *cp, char **w); static char *id(char *cp, int *h); static char *whitesp(char *cp); static void addhash(tdesc_t *tdp, int num); static int tagadd(char *w, int h, tdesc_t *tdp); static char *tdefdecl(char *cp, int h, tdesc_t **rtdp); static char *intrinsic(char *cp, tdesc_t **rtdp); static char *arraydef(char *cp, tdesc_t **rtdp); int debug_parse = DEBUG_PARSE; /*PRINTFLIKE3*/ static void parse_debug(int level, char *cp, const char *fmt, ...) { va_list ap; char buf[1024]; char tmp[32]; int i; if (level > debug_level || !debug_parse) return; if (cp != NULL) { for (i = 0; i < 30; i++) { if (cp[i] == '\0') break; if (!iscntrl(cp[i])) tmp[i] = cp[i]; } tmp[i] = '\0'; (void) snprintf(buf, sizeof (buf), "%s [cp='%s']\n", fmt, tmp); } else { strcpy(buf, fmt); strcat(buf, "\n"); } va_start(ap, fmt); vadebug(level, buf, ap); va_end(ap); } /* Report unexpected syntax in stabs. */ static void _expected( const char *who, /* what function, or part thereof, is reporting */ const char *what, /* what was expected */ const char *where, /* where we were in the line of input */ int line) { fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where); fprintf(stderr, "code line: %d, file %s\n", line, (curhdr ? curhdr : "NO FILE")); reset(); } /*ARGSUSED*/ void parse_init(tdata_t *td __unused) { int i; for (i = 0; i < BUCKETS; i++) { hash_table[i] = NULL; name_table[i] = NULL; } if (typedbitfldmems != NULL) { list_free(typedbitfldmems, NULL, NULL); typedbitfldmems = NULL; } } void parse_finish(tdata_t *td) { td->td_nextid = ++faketypenumber; } static tdesc_t * unres_new(int tid) { tdesc_t *tdp; tdp = xcalloc(sizeof (*tdp)); tdp->t_type = TYPEDEF_UNRES; tdp->t_id = tid; return (tdp); } static char * read_tid(char *cp, tdesc_t **tdpp) { tdesc_t *tdp; int tid; cp = id(cp, &tid); assert(tid != 0); if (*cp == '=') { if (!(cp = tdefdecl(cp + 1, tid, &tdp))) return (NULL); if (tdp->t_id && tdp->t_id != tid) { tdesc_t *ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = tdp; tdp = ntdp; } addhash(tdp, tid); } else if ((tdp = lookup(tid)) == NULL) tdp = unres_new(tid); *tdpp = tdp; return (cp); } static iitype_t parse_fun(char *cp, iidesc_t *ii) { iitype_t iitype = 0; tdesc_t *tdp; tdesc_t **args = NULL; int nargs = 0; int va = 0; /* * name:P prototype * name:F global function * name:f static function */ switch (*cp++) { case 'P': iitype = II_NOT; /* not interesting */ break; case 'F': iitype = II_GFUN; break; case 'f': iitype = II_SFUN; break; default: expected("parse_nfun", "[PfF]", cp - 1); } if (!(cp = read_tid(cp, &tdp))) return (-1); if (*cp) args = xmalloc(sizeof (tdesc_t *) * FUNCARG_DEF); while (*cp && *++cp) { if (*cp == '0') { va = 1; continue; } nargs++; if (nargs > FUNCARG_DEF) args = xrealloc(args, sizeof (tdesc_t *) * nargs); if (!(cp = read_tid(cp, &args[nargs - 1]))) return (-1); } ii->ii_type = iitype; ii->ii_dtype = tdp; ii->ii_nargs = nargs; ii->ii_args = args; ii->ii_vargs = va; return (iitype); } static iitype_t parse_sym(char *cp, iidesc_t *ii) { tdesc_t *tdp; iitype_t iitype = 0; /* * name:G global variable * name:S static variable */ switch (*cp++) { case 'G': iitype = II_GVAR; break; case 'S': iitype = II_SVAR; break; case 'p': iitype = II_PSYM; break; case '(': cp--; /*FALLTHROUGH*/ case 'r': case 'V': iitype = II_NOT; /* not interesting */ break; default: expected("parse_sym", "[GprSV(]", cp - 1); } if (!(cp = read_tid(cp, &tdp))) return (-1); ii->ii_type = iitype; ii->ii_dtype = tdp; return (iitype); } static iitype_t parse_type(char *cp, iidesc_t *ii) { tdesc_t *tdp, *ntdp; int tid; if (*cp++ != 't') expected("parse_type", "t (type)", cp - 1); cp = id(cp, &tid); if ((tdp = lookup(tid)) == NULL) { if (*cp++ != '=') expected("parse_type", "= (definition)", cp - 1); (void) tdefdecl(cp, tid, &tdp); if (tdp->t_id == tid) { assert(tdp->t_type != TYPEDEF); assert(!lookup(tdp->t_id)); if (!streq(tdp->t_name, ii->ii_name)) { ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_name = xstrdup(ii->ii_name); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = tdp; tdp->t_id = faketypenumber++; tdp = ntdp; } } else if (tdp->t_id == 0) { assert(tdp->t_type == FORWARD || tdp->t_type == INTRINSIC); if (tdp->t_name && !streq(tdp->t_name, ii->ii_name)) { ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_name = xstrdup(ii->ii_name); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = tdp; tdp->t_id = faketypenumber++; tdp = ntdp; } } else if (tdp->t_id != tid) { ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_name = xstrdup(ii->ii_name); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = tdp; tdp = ntdp; } if (tagadd(ii->ii_name, tid, tdp) < 0) return (-1); } ii->ii_type = II_TYPE; ii->ii_dtype = tdp; return (II_TYPE); } static iitype_t parse_sou(char *cp, iidesc_t *idp) { tdesc_t *rtdp; int tid; if (*cp++ != 'T') expected("parse_sou", "T (sou)", cp - 1); cp = id(cp, &tid); if (*cp++ != '=') expected("parse_sou", "= (definition)", cp - 1); parse_debug(1, NULL, "parse_sou: declaring '%s'", idp->ii_name ? idp->ii_name : "(anon)"); if ((rtdp = lookup(tid)) != NULL) { if (idp->ii_name != NULL) { if (rtdp->t_name != NULL && strcmp(rtdp->t_name, idp->ii_name) != 0) { tdesc_t *tdp; tdp = xcalloc(sizeof (*tdp)); tdp->t_name = xstrdup(idp->ii_name); tdp->t_type = TYPEDEF; tdp->t_tdesc = rtdp; addhash(tdp, tid); /* for *(x,y) types */ parse_debug(3, NULL, " %s defined as %s(%d)", idp->ii_name, tdesc_name(rtdp), tid); } else if (rtdp->t_name == NULL) { rtdp->t_name = xstrdup(idp->ii_name); addhash(rtdp, tid); } } } else { rtdp = xcalloc(sizeof (*rtdp)); rtdp->t_name = idp->ii_name ? xstrdup(idp->ii_name) : NULL; addhash(rtdp, tid); } switch (*cp++) { case 's': (void) soudef(cp, STRUCT, &rtdp); break; case 'u': (void) soudef(cp, UNION, &rtdp); break; case 'e': enumdef(cp, &rtdp); break; default: expected("parse_sou", "", cp - 1); break; } idp->ii_type = II_SOU; idp->ii_dtype = rtdp; return (II_SOU); } int parse_stab(stab_t *stab, char *cp, iidesc_t **iidescp) { iidesc_t *ii = NULL; iitype_t (*parse)(char *, iidesc_t *); int rc; /* * set up for reset() */ if (setjmp(resetbuf)) return (-1); cp = whitesp(cp); ii = iidesc_new(NULL); cp = name(cp, &ii->ii_name); switch (stab->n_type) { case N_FUN: parse = parse_fun; break; case N_LSYM: if (*cp == 't') parse = parse_type; else if (*cp == 'T') parse = parse_sou; else parse = parse_sym; break; case N_GSYM: case N_LCSYM: case N_PSYM: case N_ROSYM: case N_RSYM: case N_STSYM: parse = parse_sym; break; default: parse_debug(1, cp, "Unknown stab type %#x", stab->n_type); bzero(&resetbuf, sizeof (resetbuf)); return (-1); } rc = parse(cp, ii); bzero(&resetbuf, sizeof (resetbuf)); if (rc < 0 || ii->ii_type == II_NOT) { iidesc_free(ii, NULL); return (rc); } *iidescp = ii; return (1); } /* * Check if we have this node in the hash table already */ tdesc_t * lookup(int h) { int bucket = HASH(h); tdesc_t *tdp = hash_table[bucket]; while (tdp != NULL) { if (tdp->t_id == h) return (tdp); tdp = tdp->t_hash; } return (NULL); } static char * whitesp(char *cp) { char c; for (c = *cp++; isspace(c); c = *cp++) ; --cp; return (cp); } static char * name(char *cp, char **w) { char *new, *orig, c; int len; orig = cp; c = *cp++; if (c == ':') *w = NULL; else if (isalpha(c) || strchr("_.$#", c)) { for (c = *cp++; isalnum(c) || strchr(" _.$#", c); c = *cp++) ; if (c != ':') reset(); len = cp - orig; new = xmalloc(len); while (orig < cp - 1) *new++ = *orig++; *new = '\0'; *w = new - (len - 1); } else reset(); return (cp); } static char * number(char *cp, int *n) { char *next; *n = (int)strtol(cp, &next, 10); if (next == cp) expected("number", "", cp); return (next); } static char * id(char *cp, int *h) { int n1, n2; if (*cp == '(') { /* SunPro style */ cp++; cp = number(cp, &n1); if (*cp++ != ',') expected("id", ",", cp - 1); cp = number(cp, &n2); if (*cp++ != ')') expected("id", ")", cp - 1); *h = MAKETYPEID(n1, n2); } else if (isdigit(*cp)) { /* gcc style */ cp = number(cp, &n1); *h = n1; } else { expected("id", "(/0-9", cp); } return (cp); } static int tagadd(char *w, int h, tdesc_t *tdp) { tdesc_t *otdp; tdp->t_name = w; if (!(otdp = lookup(h))) addhash(tdp, h); else if (otdp != tdp) { warning("duplicate entry\n"); warning(" old: %s %d (%d,%d)\n", tdesc_name(otdp), otdp->t_type, TYPEFILE(otdp->t_id), TYPENUM(otdp->t_id)); warning(" new: %s %d (%d,%d)\n", tdesc_name(tdp), tdp->t_type, TYPEFILE(tdp->t_id), TYPENUM(tdp->t_id)); return (-1); } return (0); } static char * tdefdecl(char *cp, int h, tdesc_t **rtdp) { tdesc_t *ntdp; char *w; int c, h2; char type; parse_debug(3, cp, "tdefdecl h=%d", h); /* Type codes */ switch (type = *cp) { case 'b': /* integer */ case 'R': /* fp */ cp = intrinsic(cp, rtdp); break; case '(': /* equiv to another type */ cp = id(cp, &h2); ntdp = lookup(h2); if (ntdp != NULL && *cp == '=') { if (ntdp->t_type == FORWARD && *(cp + 1) == 'x') { /* * The 6.2 compiler, and possibly others, will * sometimes emit the same stab for a forward * declaration twice. That is, "(1,2)=xsfoo:" * will sometimes show up in two different * places. This is, of course, quite fun. We * want CTF to work in spite of the compiler, * so we'll let this one through. */ char *c2 = cp + 2; char *nm; if (!strchr("sue", *c2++)) { expected("tdefdecl/x-redefine", "[sue]", c2 - 1); } c2 = name(c2, &nm); if (strcmp(nm, ntdp->t_name) != 0) { terminate("Stabs error: Attempt to " "redefine type (%d,%d) as " "something else: %s\n", TYPEFILE(h2), TYPENUM(h2), c2 - 1); } free(nm); h2 = faketypenumber++; ntdp = NULL; } else { terminate("Stabs error: Attempting to " "redefine type (%d,%d)\n", TYPEFILE(h2), TYPENUM(h2)); } } if (ntdp == NULL) { /* if that type isn't defined yet */ if (*cp != '=') { /* record it as unresolved */ parse_debug(3, NULL, "tdefdecl unres type %d", h2); *rtdp = calloc(sizeof (**rtdp), 1); (*rtdp)->t_type = TYPEDEF_UNRES; (*rtdp)->t_id = h2; break; } else cp++; /* define a new type */ cp = tdefdecl(cp, h2, rtdp); if ((*rtdp)->t_id && (*rtdp)->t_id != h2) { ntdp = calloc(sizeof (*ntdp), 1); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = *rtdp; *rtdp = ntdp; } addhash(*rtdp, h2); } else { /* that type is already defined */ if (ntdp->t_type != TYPEDEF || ntdp->t_name != NULL) { *rtdp = ntdp; } else { parse_debug(3, NULL, "No duplicate typedef anon for ref"); *rtdp = ntdp; } } break; case '*': ntdp = NULL; cp = tdefdecl(cp + 1, h, &ntdp); if (ntdp == NULL) expected("tdefdecl/*", "id", cp); if (!ntdp->t_id) ntdp->t_id = faketypenumber++; *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = POINTER; (*rtdp)->t_size = 0; (*rtdp)->t_id = h; (*rtdp)->t_tdesc = ntdp; break; case 'f': cp = tdefdecl(cp + 1, h, &ntdp); *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = FUNCTION; (*rtdp)->t_size = 0; (*rtdp)->t_id = h; (*rtdp)->t_fndef = xcalloc(sizeof (fndef_t)); /* * The 6.1 compiler will sometimes generate incorrect stabs for * function pointers (it'll get the return type wrong). This * causes merges to fail. We therefore treat function pointers * as if they all point to functions that return int. When * 4432549 is fixed, the lookupname() call below should be * replaced with `ntdp'. */ (*rtdp)->t_fndef->fn_ret = lookupname("int"); break; case 'a': case 'z': cp++; if (*cp++ != 'r') expected("tdefdecl/[az]", "r", cp - 1); *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = ARRAY; (*rtdp)->t_id = h; cp = arraydef(cp, rtdp); break; case 'x': c = *++cp; if (c != 's' && c != 'u' && c != 'e') expected("tdefdecl/x", "[sue]", cp - 1); cp = name(cp + 1, &w); ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_type = FORWARD; ntdp->t_name = w; /* * We explicitly don't set t_id here - the caller will do it. * The caller may want to use a real type ID, or they may * choose to make one up. */ *rtdp = ntdp; break; case 'B': /* volatile */ cp = tdefdecl(cp + 1, h, &ntdp); if (!ntdp->t_id) ntdp->t_id = faketypenumber++; *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = VOLATILE; (*rtdp)->t_size = 0; (*rtdp)->t_tdesc = ntdp; (*rtdp)->t_id = h; break; case 'k': /* const */ cp = tdefdecl(cp + 1, h, &ntdp); if (!ntdp->t_id) ntdp->t_id = faketypenumber++; *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = CONST; (*rtdp)->t_size = 0; (*rtdp)->t_tdesc = ntdp; (*rtdp)->t_id = h; break; case 'K': /* restricted */ cp = tdefdecl(cp + 1, h, &ntdp); if (!ntdp->t_id) ntdp->t_id = faketypenumber++; *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_type = RESTRICT; (*rtdp)->t_size = 0; (*rtdp)->t_tdesc = ntdp; (*rtdp)->t_id = h; break; case 'u': case 's': cp++; *rtdp = xcalloc(sizeof (**rtdp)); (*rtdp)->t_name = NULL; cp = soudef(cp, (type == 'u') ? UNION : STRUCT, rtdp); break; default: expected("tdefdecl", "", cp); } return (cp); } static char * intrinsic(char *cp, tdesc_t **rtdp) { intr_t *intr = xcalloc(sizeof (intr_t)); tdesc_t *tdp; int width, fmt, i; switch (*cp++) { case 'b': intr->intr_type = INTR_INT; if (*cp == 's') intr->intr_signed = 1; else if (*cp != 'u') expected("intrinsic/b", "[su]", cp); cp++; if (strchr("cbv", *cp)) intr->intr_iformat = *cp++; cp = number(cp, &width); if (*cp++ != ';') expected("intrinsic/b", "; (post-width)", cp - 1); cp = number(cp, &intr->intr_offset); if (*cp++ != ';') expected("intrinsic/b", "; (post-offset)", cp - 1); cp = number(cp, &intr->intr_nbits); break; case 'R': intr->intr_type = INTR_REAL; for (fmt = 0, i = 0; isdigit(*(cp + i)); i++) fmt = fmt * 10 + (*(cp + i) - '0'); if (fmt < 1 || fmt > CTF_FP_MAX) expected("intrinsic/R", "number <= CTF_FP_MAX", cp); intr->intr_fformat = fmt; cp += i; if (*cp++ != ';') expected("intrinsic/R", ";", cp - 1); cp = number(cp, &width); intr->intr_nbits = width * 8; break; } tdp = xcalloc(sizeof (*tdp)); tdp->t_type = INTRINSIC; tdp->t_size = width; tdp->t_name = NULL; tdp->t_intr = intr; parse_debug(3, NULL, "intrinsic: size=%d", width); *rtdp = tdp; return (cp); } static tdesc_t * bitintrinsic(tdesc_t *template, int nbits) { tdesc_t *newtdp = xcalloc(sizeof (tdesc_t)); newtdp->t_name = xstrdup(template->t_name); newtdp->t_id = faketypenumber++; newtdp->t_type = INTRINSIC; newtdp->t_size = template->t_size; newtdp->t_intr = xmalloc(sizeof (intr_t)); bcopy(template->t_intr, newtdp->t_intr, sizeof (intr_t)); newtdp->t_intr->intr_nbits = nbits; return (newtdp); } static char * offsize(char *cp, mlist_t *mlp) { int offset, size; if (*cp == ',') cp++; cp = number(cp, &offset); if (*cp++ != ',') expected("offsize/2", ",", cp - 1); cp = number(cp, &size); if (*cp++ != ';') expected("offsize/3", ";", cp - 1); mlp->ml_offset = offset; mlp->ml_size = size; return (cp); } static tdesc_t * find_intrinsic(tdesc_t *tdp) { for (;;) { switch (tdp->t_type) { case TYPEDEF: case VOLATILE: case CONST: case RESTRICT: tdp = tdp->t_tdesc; break; default: return (tdp); } } } static char * soudef(char *cp, stabtype_t type, tdesc_t **rtdp) { mlist_t *mlp, **prev; char *w; int h; int size; tdesc_t *tdp, *itdp; cp = number(cp, &size); (*rtdp)->t_size = size; (*rtdp)->t_type = type; /* s or u */ /* * An '@' here indicates a bitmask follows. This is so the * compiler can pass information to debuggers about how structures * are passed in the v9 world. We don't need this information * so we skip over it. */ if (cp[0] == '@') { cp += 3; } parse_debug(3, cp, "soudef: %s size=%d", tdesc_name(*rtdp), (*rtdp)->t_size); prev = &((*rtdp)->t_members); /* now fill up the fields */ while ((*cp != '\0') && (*cp != ';')) { /* signifies end of fields */ mlp = xcalloc(sizeof (*mlp)); *prev = mlp; cp = name(cp, &w); mlp->ml_name = w; cp = id(cp, &h); /* * find the tdesc struct in the hash table for this type * and stick a ptr in here */ tdp = lookup(h); if (tdp == NULL) { /* not in hash list */ parse_debug(3, NULL, " defines %s (%d)", w, h); if (*cp++ != '=') { tdp = unres_new(h); parse_debug(3, NULL, " refers to %s (unresolved %d)", (w ? w : "anon"), h); } else { cp = tdefdecl(cp, h, &tdp); if (tdp->t_id && tdp->t_id != h) { tdesc_t *ntdp = xcalloc(sizeof (*ntdp)); ntdp->t_type = TYPEDEF; ntdp->t_tdesc = tdp; tdp = ntdp; } addhash(tdp, h); parse_debug(4, cp, " soudef now looking at "); cp++; } } else { parse_debug(3, NULL, " refers to %s (%d, %s)", w ? w : "anon", h, tdesc_name(tdp)); } cp = offsize(cp, mlp); itdp = find_intrinsic(tdp); if (itdp->t_type == INTRINSIC) { if (mlp->ml_size != itdp->t_intr->intr_nbits) { parse_debug(4, cp, "making %d bit intrinsic " "from %s", mlp->ml_size, tdesc_name(itdp)); mlp->ml_type = bitintrinsic(itdp, mlp->ml_size); } else mlp->ml_type = tdp; } else if (itdp->t_type == TYPEDEF_UNRES) { list_add(&typedbitfldmems, mlp); mlp->ml_type = tdp; } else { mlp->ml_type = tdp; } /* cp is now pointing to next field */ prev = &mlp->ml_next; } return (cp); } static char * arraydef(char *cp, tdesc_t **rtdp) { int start, end, h; cp = id(cp, &h); if (*cp++ != ';') expected("arraydef/1", ";", cp - 1); (*rtdp)->t_ardef = xcalloc(sizeof (ardef_t)); (*rtdp)->t_ardef->ad_idxtype = lookup(h); cp = number(cp, &start); /* lower */ if (*cp++ != ';') expected("arraydef/2", ";", cp - 1); if (*cp == 'S') { /* * variable length array - treat as null dimensioned * * For VLA variables on sparc, SS12 generated stab entry * looks as follows: * .stabs "buf:(0,28)=zr(0,4);0;S-12;(0,1)", 0x80, 0, 0, -16 * Whereas SS12u1 generated stab entry looks like this: * .stabs "buf:(0,28)=zr(0,4);0;S0;(0,1)", 0x80, 0, 0, 0 * On x86, both versions generate the first type of entry. * We should be able to parse both. */ cp++; if (*cp == '-') cp++; cp = number(cp, &end); end = start; } else { /* * normal fixed-dimension array * Stab entry for this looks as follows : * .stabs "x:(0,28)=ar(0,4);0;9;(0,3)", 0x80, 0, 40, 0 */ cp = number(cp, &end); /* upper */ } if (*cp++ != ';') expected("arraydef/3", ";", cp - 1); (*rtdp)->t_ardef->ad_nelems = end - start + 1; cp = tdefdecl(cp, h, &((*rtdp)->t_ardef->ad_contents)); parse_debug(3, cp, "defined array idx type %d %d-%d next ", h, start, end); return (cp); } static void enumdef(char *cp, tdesc_t **rtdp) { elist_t *elp, **prev; char *w; (*rtdp)->t_type = ENUM; (*rtdp)->t_emem = NULL; prev = &((*rtdp)->t_emem); while (*cp != ';') { elp = xcalloc(sizeof (*elp)); elp->el_next = NULL; *prev = elp; cp = name(cp, &w); elp->el_name = w; cp = number(cp, &elp->el_number); parse_debug(3, NULL, "enum %s: %s=%d", tdesc_name(*rtdp), elp->el_name, elp->el_number); prev = &elp->el_next; if (*cp++ != ',') expected("enumdef", ",", cp - 1); } } static tdesc_t * lookup_name(tdesc_t **hash, const char *name1) { int bucket = compute_sum(name1); tdesc_t *tdp, *ttdp = NULL; for (tdp = hash[bucket]; tdp != NULL; tdp = tdp->t_next) { if (tdp->t_name != NULL && strcmp(tdp->t_name, name1) == 0) { if (tdp->t_type == STRUCT || tdp->t_type == UNION || tdp->t_type == ENUM || tdp->t_type == INTRINSIC) return (tdp); if (tdp->t_type == TYPEDEF) ttdp = tdp; } } return (ttdp); } tdesc_t * lookupname(const char *name1) { return (lookup_name(name_table, name1)); } /* * Add a node to the hash queues. */ static void addhash(tdesc_t *tdp, int num) { int hash = HASH(num); tdesc_t *ttdp; char added_num = 0, added_name = 0; /* * If it already exists in the hash table don't add it again * (but still check to see if the name should be hashed). */ ttdp = lookup(num); if (ttdp == NULL) { tdp->t_id = num; tdp->t_hash = hash_table[hash]; hash_table[hash] = tdp; added_num = 1; } if (tdp->t_name != NULL) { ttdp = lookupname(tdp->t_name); if (ttdp == NULL) { hash = compute_sum(tdp->t_name); tdp->t_next = name_table[hash]; name_table[hash] = tdp; added_name = 1; } } if (!added_num && !added_name) { terminate("stabs: broken hash\n"); } } static int compute_sum(const char *w) { char c; int sum; for (sum = 0; (c = *w) != '\0'; sum += c, w++) ; return (HASH(sum)); } static void reset(void) { longjmp(resetbuf, 1); } void check_hash(void) { tdesc_t *tdp; int i; printf("checking hash\n"); for (i = 0; i < BUCKETS; i++) { if (hash_table[i]) { for (tdp = hash_table[i]->t_hash; tdp && tdp != hash_table[i]; tdp = tdp->t_hash) continue; if (tdp) { terminate("cycle in hash bucket %d\n", i); return; } } if (name_table[i]) { for (tdp = name_table[i]->t_next; tdp && tdp != name_table[i]; tdp = tdp->t_next) continue; if (tdp) { terminate("cycle in name bucket %d\n", i); return; } } } printf("done\n"); } /*ARGSUSED1*/ static int resolve_typed_bitfields_cb(void *arg, void *private __unused) { mlist_t *ml = arg; tdesc_t *tdp = ml->ml_type; debug(3, "Resolving typed bitfields (member %s)\n", (ml->ml_name ? ml->ml_name : "(anon)")); while (tdp) { switch (tdp->t_type) { case INTRINSIC: if (ml->ml_size != tdp->t_intr->intr_nbits) { debug(3, "making %d bit intrinsic from %s", ml->ml_size, tdesc_name(tdp)); ml->ml_type = bitintrinsic(tdp, ml->ml_size); } else { debug(3, "using existing %d bit %s intrinsic", ml->ml_size, tdesc_name(tdp)); ml->ml_type = tdp; } return (1); case POINTER: case TYPEDEF: case VOLATILE: case CONST: case RESTRICT: tdp = tdp->t_tdesc; break; default: return (1); } } terminate("type chain for bitfield member %s has a NULL", ml->ml_name); /*NOTREACHED*/ return (0); } void resolve_typed_bitfields(void) { (void) list_iter(typedbitfldmems, resolve_typed_bitfields_cb, NULL); } Index: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c =================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c (revision 249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c (revision 249699) @@ -1,226 +1,226 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" /* * Routines used to traverse tdesc trees, invoking user-supplied callbacks * as the tree is traversed. */ #include #include #include "ctftools.h" #include "traverse.h" #include "memory.h" -int (*tddescenders[])(tdesc_t *, tdtrav_data_t *); -tdtrav_cb_f tdnops[]; +static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *); +static tdtrav_cb_f tdnops[]; void tdtrav_init(tdtrav_data_t *tdtd, int *vgenp, tdtrav_cb_f *firstops, tdtrav_cb_f *preops, tdtrav_cb_f *postops, void *private) { tdtd->vgen = ++(*vgenp); tdtd->firstops = firstops ? firstops : tdnops; tdtd->preops = preops ? preops : tdnops; tdtd->postops = postops ? postops : tdnops; tdtd->private = private; } static int tdtrav_plain(tdesc_t *this, tdtrav_data_t *tdtd) { return (tdtraverse(this->t_tdesc, &this->t_tdesc, tdtd)); } static int tdtrav_func(tdesc_t *this, tdtrav_data_t *tdtd) { fndef_t *fn = this->t_fndef; int i, rc; if ((rc = tdtraverse(fn->fn_ret, &fn->fn_ret, tdtd)) < 0) return (rc); for (i = 0; i < (int) fn->fn_nargs; i++) { if ((rc = tdtraverse(fn->fn_args[i], &fn->fn_args[i], tdtd)) < 0) return (rc); } return (0); } static int tdtrav_array(tdesc_t *this, tdtrav_data_t *tdtd) { ardef_t *ardef = this->t_ardef; int rc; if ((rc = tdtraverse(ardef->ad_contents, &ardef->ad_contents, tdtd)) < 0) return (rc); return (tdtraverse(ardef->ad_idxtype, &ardef->ad_idxtype, tdtd)); } static int tdtrav_su(tdesc_t *this, tdtrav_data_t *tdtd) { mlist_t *ml; int rc = 0; for (ml = this->t_members; ml; ml = ml->ml_next) { if ((rc = tdtraverse(ml->ml_type, &ml->ml_type, tdtd)) < 0) return (rc); } return (rc); } /*ARGSUSED*/ int tdtrav_assert(tdesc_t *node __unused, tdesc_t **nodep __unused, void *private __unused) { assert(1 == 0); return (-1); } -tdtrav_cb_f tdnops[] = { +static tdtrav_cb_f tdnops[] = { NULL, NULL, /* intrinsic */ NULL, /* pointer */ NULL, /* array */ NULL, /* function */ NULL, /* struct */ NULL, /* union */ NULL, /* enum */ NULL, /* forward */ NULL, /* typedef */ NULL, /* typedef_unres */ NULL, /* volatile */ NULL, /* const */ NULL /* restrict */ }; -int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = { +static int (*tddescenders[])(tdesc_t *, tdtrav_data_t *) = { NULL, NULL, /* intrinsic */ tdtrav_plain, /* pointer */ tdtrav_array, /* array */ tdtrav_func, /* function */ tdtrav_su, /* struct */ tdtrav_su, /* union */ NULL, /* enum */ NULL, /* forward */ tdtrav_plain, /* typedef */ NULL, /* typedef_unres */ tdtrav_plain, /* volatile */ tdtrav_plain, /* const */ tdtrav_plain /* restrict */ }; int tdtraverse(tdesc_t *this, tdesc_t **thisp, tdtrav_data_t *tdtd) { tdtrav_cb_f travcb; int (*descender)(tdesc_t *, tdtrav_data_t *); int descend = 1; int rc; if ((travcb = tdtd->firstops[this->t_type]) != NULL) { if ((rc = travcb(this, thisp, tdtd->private)) < 0) return (rc); else if (rc == 0) descend = 0; } if (this->t_vgen == tdtd->vgen) return (1); this->t_vgen = tdtd->vgen; if (descend && (travcb = tdtd->preops[this->t_type]) != NULL) { if ((rc = travcb(this, thisp, tdtd->private)) < 0) return (rc); else if (rc == 0) descend = 0; } if (descend) { if ((descender = tddescenders[this->t_type]) != NULL && (rc = descender(this, tdtd)) < 0) return (rc); if ((travcb = tdtd->postops[this->t_type]) != NULL && (rc = travcb(this, thisp, tdtd->private)) < 0) return (rc); } return (1); } int iitraverse_td(void *arg1, void *arg2) { iidesc_t *ii = arg1; tdtrav_data_t *tdtd = arg2; int i, rc; if ((rc = tdtraverse(ii->ii_dtype, &ii->ii_dtype, tdtd)) < 0) return (rc); for (i = 0; i < ii->ii_nargs; i++) { if ((rc = tdtraverse(ii->ii_args[i], &ii->ii_args[i], tdtd)) < 0) return (rc); } return (1); } int iitraverse(iidesc_t *ii, int *vgenp, tdtrav_cb_f *firstops, tdtrav_cb_f *preops, tdtrav_cb_f *postops, void *private) { tdtrav_data_t tdtd; tdtrav_init(&tdtd, vgenp, firstops, preops, postops, private); return (iitraverse_td(ii, &tdtd)); } int iitraverse_hash(hash_t *iihash, int *vgenp, tdtrav_cb_f *firstops, tdtrav_cb_f *preops, tdtrav_cb_f *postops, void *private) { tdtrav_data_t tdtd; tdtrav_init(&tdtd, vgenp, firstops, preops, postops, private); return (hash_iter(iihash, iitraverse_td, &tdtd)); } Index: user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c =================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c (revision 249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris/tools/ctf/cvt/util.c (revision 249699) @@ -1,283 +1,283 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "%Z%%M% %I% %E% SMI" /* * Utility functions */ #include #include #include #include #include #include #include #include #include #include #include "ctftools.h" #include "memory.h" static void (*terminate_cleanup)(void) = NULL; /* returns 1 if s1 == s2, 0 otherwise */ int streq(const char *s1, const char *s2) { if (s1 == NULL) { if (s2 != NULL) return (0); } else if (s2 == NULL) return (0); else if (strcmp(s1, s2) != 0) return (0); return (1); } int findelfsecidx(Elf *elf, const char *file, const char *tofind) { Elf_Scn *scn = NULL; GElf_Ehdr ehdr; GElf_Shdr shdr; if (gelf_getehdr(elf, &ehdr) == NULL) elfterminate(file, "Couldn't read ehdr"); while ((scn = elf_nextscn(elf, scn)) != NULL) { char *name; if (gelf_getshdr(scn, &shdr) == NULL) { elfterminate(file, "Couldn't read header for section %d", elf_ndxscn(scn)); } if ((name = elf_strptr(elf, ehdr.e_shstrndx, (size_t)shdr.sh_name)) == NULL) { elfterminate(file, "Couldn't get name for section %d", elf_ndxscn(scn)); } if (strcmp(name, tofind) == 0) return (elf_ndxscn(scn)); } return (-1); } size_t elf_ptrsz(Elf *elf) { GElf_Ehdr ehdr; if (gelf_getehdr(elf, &ehdr) == NULL) { terminate("failed to read ELF header: %s\n", elf_errmsg(-1)); } if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) return (4); else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) return (8); else terminate("unknown ELF class %d\n", ehdr.e_ident[EI_CLASS]); /*NOTREACHED*/ return (0); } /*PRINTFLIKE2*/ static void whine(const char *type, const char *format, va_list ap) { int error = errno; fprintf(stderr, "%s: %s: ", type, progname); vfprintf(stderr, format, ap); if (format[strlen(format) - 1] != '\n') fprintf(stderr, ": %s\n", strerror(error)); } void set_terminate_cleanup(void (*cleanup)(void)) { terminate_cleanup = cleanup; } /*PRINTFLIKE1*/ void terminate(const char *format, ...) { va_list ap; va_start(ap, format); whine("ERROR", format, ap); va_end(ap); if (terminate_cleanup) terminate_cleanup(); if (getenv("CTF_ABORT_ON_TERMINATE") != NULL) abort(); #if defined(__FreeBSD__) /* * For the time being just output the termination message, but don't * return an exit status that would cause the build to fail. We need * to get as much stuff built as possible before going back and * figuring out what is wrong with certain files. */ exit(0); #else exit(1); #endif } /*PRINTFLIKE1*/ void aborterr(const char *format, ...) { va_list ap; va_start(ap, format); whine("ERROR", format, ap); va_end(ap); #if defined(sun) abort(); #else exit(0); #endif } /*PRINTFLIKE1*/ void warning(const char *format, ...) { va_list ap; va_start(ap, format); whine("WARNING", format, ap); va_end(ap); if (debug_level >= 3) terminate("Termination due to warning\n"); } /*PRINTFLIKE2*/ void vadebug(int level, const char *format, va_list ap) { if (level > debug_level) return; (void) fprintf(DEBUG_STREAM, "DEBUG: "); (void) vfprintf(DEBUG_STREAM, format, ap); fflush(DEBUG_STREAM); } /*PRINTFLIKE2*/ void debug(int level, const char *format, ...) { va_list ap; if (level > debug_level) return; va_start(ap, format); (void) vadebug(level, format, ap); va_end(ap); } char * mktmpname(const char *origname, const char *suffix) { char *newname; newname = xmalloc(strlen(origname) + strlen(suffix) + 1); (void) strcpy(newname, origname); (void) strcat(newname, suffix); return (newname); } /*PRINTFLIKE2*/ void elfterminate(const char *file, const char *fmt, ...) { static char msgbuf[BUFSIZ]; va_list ap; va_start(ap, fmt); vsnprintf(msgbuf, sizeof (msgbuf), fmt, ap); va_end(ap); terminate("%s: %s: %s\n", file, msgbuf, elf_errmsg(-1)); } const char * tdesc_name(tdesc_t *tdp) { return (tdp->t_name == NULL ? "(anon)" : tdp->t_name); } -char *watch_address = NULL; -int watch_length = 0; +static char *watch_address = NULL; +static int watch_length = 0; void watch_set(void *addr, int len) { watch_address = addr; watch_length = len; } void watch_dump(int v) { char *p = watch_address; int i; if (watch_address == NULL || watch_length == 0) return; printf("%d: watch %p len %d\n",v,watch_address,watch_length); for (i = 0; i < watch_length; i++) { if (*p >= 0x20 && *p < 0x7f) { printf(" %c",*p++ & 0xff); } else { printf(" %02x",*p++ & 0xff); } } printf("\n"); } Index: user/attilio/vmcontention/cddl/contrib/opensolaris =================================================================== --- user/attilio/vmcontention/cddl/contrib/opensolaris (revision 249698) +++ user/attilio/vmcontention/cddl/contrib/opensolaris (revision 249699) Property changes on: user/attilio/vmcontention/cddl/contrib/opensolaris ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/cddl/contrib/opensolaris:r249647-249698 Index: user/attilio/vmcontention/cddl =================================================================== --- user/attilio/vmcontention/cddl (revision 249698) +++ user/attilio/vmcontention/cddl (revision 249699) Property changes on: user/attilio/vmcontention/cddl ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/cddl:r249647-249698 Index: user/attilio/vmcontention/contrib/tzdata/antarctica =================================================================== --- user/attilio/vmcontention/contrib/tzdata/antarctica (revision 249698) +++ user/attilio/vmcontention/contrib/tzdata/antarctica (revision 249699) @@ -1,411 +1,371 @@ #
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # From Paul Eggert (1999-11-15):
 # To keep things manageable, we list only locations occupied year-round; see
 # 
 # COMNAP - Stations and Bases
 # 
 # and
 # 
 # Summary of the Peri-Antarctic Islands (1998-07-23)
 # 
 # for information.
 # Unless otherwise specified, we have no time zone information.
 #
 # Except for the French entries,
 # I made up all time zone abbreviations mentioned here; corrections welcome!
 # FORMAT is `zzz' and GMTOFF is 0 for locations while uninhabited.
 
 # These rules are stolen from the `southamerica' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	ArgAQ	1964	1966	-	Mar	 1	0:00	0	-
 Rule	ArgAQ	1964	1966	-	Oct	15	0:00	1:00	S
 Rule	ArgAQ	1967	only	-	Apr	 2	0:00	0	-
 Rule	ArgAQ	1967	1968	-	Oct	Sun>=1	0:00	1:00	S
 Rule	ArgAQ	1968	1969	-	Apr	Sun>=1	0:00	0	-
 Rule	ArgAQ	1974	only	-	Jan	23	0:00	1:00	S
 Rule	ArgAQ	1974	only	-	May	 1	0:00	0	-
 Rule	ChileAQ	1972	1986	-	Mar	Sun>=9	3:00u	0	-
 Rule	ChileAQ	1974	1987	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	ChileAQ	1987	only	-	Apr	12	3:00u	0	-
 Rule	ChileAQ	1988	1989	-	Mar	Sun>=9	3:00u	0	-
 Rule	ChileAQ	1988	only	-	Oct	Sun>=1	4:00u	1:00	S
 Rule	ChileAQ	1989	only	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	ChileAQ	1990	only	-	Mar	18	3:00u	0	-
 Rule	ChileAQ	1990	only	-	Sep	16	4:00u	1:00	S
 Rule	ChileAQ	1991	1996	-	Mar	Sun>=9	3:00u	0	-
 Rule	ChileAQ	1991	1997	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	ChileAQ	1997	only	-	Mar	30	3:00u	0	-
 Rule	ChileAQ	1998	only	-	Mar	Sun>=9	3:00u	0	-
 Rule	ChileAQ	1998	only	-	Sep	27	4:00u	1:00	S
 Rule	ChileAQ	1999	only	-	Apr	 4	3:00u	0	-
 Rule	ChileAQ	1999	2010	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	ChileAQ	2000	2007	-	Mar	Sun>=9	3:00u	0	-
 # N.B.: the end of March 29 in Chile is March 30 in Universal time,
 # which is used below in specifying the transition.
 Rule	ChileAQ	2008	only	-	Mar	30	3:00u	0	-
 Rule	ChileAQ	2009	only	-	Mar	Sun>=9	3:00u	0	-
 Rule	ChileAQ	2010	only	-	Apr	Sun>=1	3:00u	0	-
 Rule	ChileAQ	2011	only	-	May	Sun>=2	3:00u	0	-
 Rule	ChileAQ	2011	only	-	Aug	Sun>=16	4:00u	1:00	S
 Rule	ChileAQ	2012	max	-	Apr	Sun>=23	3:00u	0	-
 Rule	ChileAQ	2012	max	-	Sep	Sun>=2	4:00u	1:00	S
 
-# These rules are stolen from the `australasia' file.
-Rule	AusAQ	1917	only	-	Jan	 1	0:01	1:00	-
-Rule	AusAQ	1917	only	-	Mar	25	2:00	0	-
-Rule	AusAQ	1942	only	-	Jan	 1	2:00	1:00	-
-Rule	AusAQ	1942	only	-	Mar	29	2:00	0	-
-Rule	AusAQ	1942	only	-	Sep	27	2:00	1:00	-
-Rule	AusAQ	1943	1944	-	Mar	lastSun	2:00	0	-
-Rule	AusAQ	1943	only	-	Oct	 3	2:00	1:00	-
-Rule	ATAQ	1967	only	-	Oct	Sun>=1	2:00s	1:00	-
-Rule	ATAQ	1968	only	-	Mar	lastSun	2:00s	0	-
-Rule	ATAQ	1968	1985	-	Oct	lastSun	2:00s	1:00	-
-Rule	ATAQ	1969	1971	-	Mar	Sun>=8	2:00s	0	-
-Rule	ATAQ	1972	only	-	Feb	lastSun	2:00s	0	-
-Rule	ATAQ	1973	1981	-	Mar	Sun>=1	2:00s	0	-
-Rule	ATAQ	1982	1983	-	Mar	lastSun	2:00s	0	-
-Rule	ATAQ	1984	1986	-	Mar	Sun>=1	2:00s	0	-
-Rule	ATAQ	1986	only	-	Oct	Sun>=15	2:00s	1:00	-
-Rule	ATAQ	1987	1990	-	Mar	Sun>=15	2:00s	0	-
-Rule	ATAQ	1987	only	-	Oct	Sun>=22	2:00s	1:00	-
-Rule	ATAQ	1988	1990	-	Oct	lastSun	2:00s	1:00	-
-Rule	ATAQ	1991	1999	-	Oct	Sun>=1	2:00s	1:00	-
-Rule	ATAQ	1991	2005	-	Mar	lastSun	2:00s	0	-
-Rule	ATAQ	2000	only	-	Aug	lastSun	2:00s	1:00	-
-Rule	ATAQ	2001	max	-	Oct	Sun>=1	2:00s	1:00	-
-Rule	ATAQ	2006	only	-	Apr	Sun>=1	2:00s	0	-
-Rule	ATAQ	2007	only	-	Mar	lastSun	2:00s	0	-
-Rule	ATAQ	2008	max	-	Apr	Sun>=1	2:00s	0	-
-
 # Argentina - year-round bases
 # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
 # Esperanza, San Martin Land, -6323-05659, since 1952-12-17
 # Jubany, Potter Peninsula, King George Island, -6414-0602320, since 1982-01
 # Marambio, Seymour I, -6414-05637, since 1969-10-29
 # Orcadas, Laurie I, -6016-04444, since 1904-02-22
 # San Martin, Debenham I, -6807-06708, since 1951-03-21
 #	(except 1960-03 / 1976-03-21)
 
 # Australia - territories
 # Heard Island, McDonald Islands (uninhabited)
 #	previously sealers and scientific personnel wintered
 #	
 #	Margaret Turner reports
 #	 (1999-09-30) that they're UTC+5, with no DST;
 #	presumably this is when they have visitors.
 #
 # year-round bases
 # Casey, Bailey Peninsula, -6617+11032, since 1969
 # Davis, Vestfold Hills, -6835+07759, since 1957-01-13
 #	(except 1964-11 - 1969-02)
 # Mawson, Holme Bay, -6736+06253, since 1954-02-13
 
 # From Steffen Thorsen (2009-03-11):
 # Three Australian stations in Antarctica have changed their time zone:
 # Casey moved from UTC+8 to UTC+11
 # Davis moved from UTC+7 to UTC+5
 # Mawson moved from UTC+6 to UTC+5
 # The changes occurred on 2009-10-18 at 02:00 (local times).
 #
 # Government source: (Australian Antarctic Division)
 # 
 # http://www.aad.gov.au/default.asp?casid=37079
 # 
 #
 # We have more background information here:
 # 
 # http://www.timeanddate.com/news/time/antarctica-new-times.html
 # 
 
 # From Steffen Thorsen (2010-03-10):
-# We got these changes from the Australian Antarctic Division:
-# - Macquarie Island will stay on UTC+11 for winter and therefore not
-# switch back from daylight savings time when other parts of Australia do
-# on 4 April.
+# We got these changes from the Australian Antarctic Division: ...
 #
 # - Casey station reverted to its normal time of UTC+8 on 5 March 2010.
 # The change to UTC+11 is being considered as a regular summer thing but
 # has not been decided yet.
 #
 # - Davis station will revert to its normal time of UTC+7 at 10 March 2010
 # 20:00 UTC.
 #
 # - Mawson station stays on UTC+5.
 #
-# In addition to the Rule changes for Casey/Davis, it means that Macquarie
-# will no longer be like Hobart and will have to have its own Zone created.
-#
 # Background:
 # 
 # http://www.timeanddate.com/news/time/antartica-time-changes-2010.html
 # 
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Casey	0	-	zzz	1969
 			8:00	-	WST	2009 Oct 18 2:00
 						# Western (Aus) Standard Time
 			11:00	-	CAST	2010 Mar 5 2:00
 						# Casey Time
 			8:00	-	WST	2011 Oct 28 2:00
 			11:00	-	CAST	2012 Feb 21 17:00u
 			8:00	-	WST
 Zone Antarctica/Davis	0	-	zzz	1957 Jan 13
 			7:00	-	DAVT	1964 Nov # Davis Time
 			0	-	zzz	1969 Feb
 			7:00	-	DAVT	2009 Oct 18 2:00
 			5:00	-	DAVT	2010 Mar 10 20:00u
 			7:00	-	DAVT	2011 Oct 28 2:00
 			5:00	-	DAVT	2012 Feb 21 20:00u
 			7:00	-	DAVT
 Zone Antarctica/Mawson	0	-	zzz	1954 Feb 13
 			6:00	-	MAWT	2009 Oct 18 2:00
 						# Mawson Time
 			5:00	-	MAWT
-Zone Antarctica/Macquarie 0	-	zzz	1911
-			10:00	-	EST	1916 Oct 1 2:00
-			10:00	1:00	EST	1917 Feb
-			10:00	AusAQ	EST	1967
-			10:00	ATAQ	EST	2010 Apr 4 3:00
-			11:00	-	MIST	# Macquarie Island Time
 # References:
 # 
 # Casey Weather (1998-02-26)
 # 
 # 
 # Davis Station, Antarctica (1998-02-26)
 # 
 # 
 # Mawson Station, Antarctica (1998-02-25)
 # 
 
 # Brazil - year-round base
 # Comandante Ferraz, King George Island, -6205+05824, since 1983/4
 
 # Chile - year-round bases and towns
 # Escudero, South Shetland Is, -621157-0585735, since 1994
 # Presidente Eduadro Frei, King George Island, -6214-05848, since 1969-03-07
 # General Bernardo O'Higgins, Antarctic Peninsula, -6319-05704, since 1948-02
 # Capitan Arturo Prat, -6230-05941
 # Villa Las Estrellas (a town), around the Frei base, since 1984-04-09
 # These locations have always used Santiago time; use TZ='America/Santiago'.
 
 # China - year-round bases
 # Great Wall, King George Island, -6213-05858, since 1985-02-20
 # Zhongshan, Larsemann Hills, Prydz Bay, -6922+07623, since 1989-02-26
 
 # France - year-round bases
 #
 # From Antoine Leca (1997-01-20):
 # Time data are from Nicole Pailleau at the IFRTP
 # (French Institute for Polar Research and Technology).
 # She confirms that French Southern Territories and Terre Adelie bases
 # don't observe daylight saving time, even if Terre Adelie supplies came
 # from Tasmania.
 #
 # French Southern Territories with year-round inhabitants
 #
 # Martin-de-Vivies Base, Amsterdam Island, -374105+0773155, since 1950
 # Alfred-Faure Base, Crozet Islands, -462551+0515152, since 1964
 # Port-aux-Francais, Kerguelen Islands, -492110+0701303, since 1951;
 #	whaling & sealing station operated 1908/1914, 1920/1929, and 1951/1956
 #
 # St Paul Island - near Amsterdam, uninhabited
 #	fishing stations operated variously 1819/1931
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Kerguelen	0	-	zzz	1950	# Port-aux-Francais
 			5:00	-	TFT	# ISO code TF Time
 #
 # year-round base in the main continent
 # Dumont-d'Urville, Ile des Petrels, -6640+14001, since 1956-11
 #
 # Another base at Port-Martin, 50km east, began operation in 1947.
 # It was destroyed by fire on 1952-01-14.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/DumontDUrville 0 -	zzz	1947
 			10:00	-	PMT	1952 Jan 14 # Port-Martin Time
 			0	-	zzz	1956 Nov
 			10:00	-	DDUT	# Dumont-d'Urville Time
 # Reference:
 # 
 # Dumont d'Urville Station (2005-12-05)
 # 
 
 # Germany - year-round base
 # Georg von Neumayer, -7039-00815
 
 # India - year-round base
 # Dakshin Gangotri, -7005+01200
 
 # Japan - year-round bases
 # Dome Fuji, -7719+03942
 # Syowa, -690022+0393524
 #
 # From Hideyuki Suzuki (1999-02-06):
 # In all Japanese stations, +0300 is used as the standard time.
 #
 # Syowa station, which is the first antarctic station of Japan,
 # was established on 1957-01-29.  Since Syowa station is still the main
 # station of Japan, it's appropriate for the principal location.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Syowa	0	-	zzz	1957 Jan 29
 			3:00	-	SYOT	# Syowa Time
 # See:
 # 
 # NIPR Antarctic Research Activities (1999-08-17)
 # 
 
 # S Korea - year-round base
 # King Sejong, King George Island, -6213-05847, since 1988
 
 # New Zealand - claims
 # Balleny Islands (never inhabited)
 # Scott Island (never inhabited)
 #
 # year-round base
 # Scott, Ross Island, since 1957-01, is like Antarctica/McMurdo.
 #
 # These rules for New Zealand are stolen from the `australasia' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NZAQ	1974	only	-	Nov	 3	2:00s	1:00	D
 Rule	NZAQ	1975	1988	-	Oct	lastSun	2:00s	1:00	D
 Rule	NZAQ	1989	only	-	Oct	 8	2:00s	1:00	D
 Rule	NZAQ	1990	2006	-	Oct	Sun>=1	2:00s	1:00	D
 Rule	NZAQ	1975	only	-	Feb	23	2:00s	0	S
 Rule	NZAQ	1976	1989	-	Mar	Sun>=1	2:00s	0	S
 Rule	NZAQ	1990	2007	-	Mar	Sun>=15	2:00s	0	S
 Rule	NZAQ	2007	max	-	Sep	lastSun	2:00s	1:00	D
 Rule	NZAQ	2008	max	-	Apr	Sun>=1	2:00s	0	S
 
 # Norway - territories
 # Bouvet (never inhabited)
 #
 # claims
 # Peter I Island (never inhabited)
 
 # Poland - year-round base
 # Arctowski, King George Island, -620945-0582745, since 1977
 
 # Russia - year-round bases
 # Bellingshausen, King George Island, -621159-0585337, since 1968-02-22
 # Mirny, Davis coast, -6633+09301, since 1956-02
 # Molodezhnaya, Alasheyev Bay, -6740+04551,
 #	year-round from 1962-02 to 1999-07-01
 # Novolazarevskaya, Queen Maud Land, -7046+01150,
 #	year-round from 1960/61 to 1992
 
 # Vostok, since 1957-12-16, temporarily closed 1994-02/1994-11
 # 
 # From Craig Mundell (1994-12-15):
 # Vostok, which is one of the Russian stations, is set on the same
 # time as Moscow, Russia.
 #
 # From Lee Hotz (2001-03-08):
 # I queried the folks at Columbia who spent the summer at Vostok and this is
 # what they had to say about time there:
 # ``in the US Camp (East Camp) we have been on New Zealand (McMurdo)
 # time, which is 12 hours ahead of GMT. The Russian Station Vostok was
 # 6 hours behind that (although only 2 miles away, i.e. 6 hours ahead
 # of GMT). This is a time zone I think two hours east of Moscow. The
 # natural time zone is in between the two: 8 hours ahead of GMT.''
 #
 # From Paul Eggert (2001-05-04):
 # This seems to be hopelessly confusing, so I asked Lee Hotz about it
 # in person.  He said that some Antartic locations set their local
 # time so that noon is the warmest part of the day, and that this
 # changes during the year and does not necessarily correspond to mean
 # solar noon.  So the Vostok time might have been whatever the clocks
 # happened to be during their visit.  So we still don't really know what time
 # it is at Vostok.  But we'll guess UTC+6.
 #
 Zone Antarctica/Vostok	0	-	zzz	1957 Dec 16
 			6:00	-	VOST	# Vostok time
 
 # S Africa - year-round bases
 # Marion Island, -4653+03752
 # Sanae, -7141-00250
 
 # UK
 #
 # British Antarctic Territories (BAT) claims
 # South Orkney Islands
 #	scientific station from 1903
 #	whaling station at Signy I 1920/1926
 # South Shetland Islands
 #
 # year-round bases
 # Bird Island, South Georgia, -5400-03803, since 1983
 # Deception Island, -6259-06034, whaling station 1912/1931,
 #	scientific station 1943/1967,
 #	previously sealers and a scientific expedition wintered by accident,
 #	and a garrison was deployed briefly
 # Halley, Coates Land, -7535-02604, since 1956-01-06
 #	Halley is on a moving ice shelf and is periodically relocated
 #	so that it is never more than 10km from its nominal location.
 # Rothera, Adelaide Island, -6734-6808, since 1976-12-01
 #
 # From Paul Eggert (2002-10-22)
 #  says Rothera is -03 all year.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Rothera	0	-	zzz	1976 Dec  1
 			-3:00	-	ROTT	# Rothera time
 
 # Uruguay - year round base
 # Artigas, King George Island, -621104-0585107
 
 # USA - year-round bases
 #
 # Palmer, Anvers Island, since 1965 (moved 2 miles in 1968)
 #
 # From Ethan Dicks (1996-10-06):
 # It keeps the same time as Punta Arenas, Chile, because, just like us
 # and the South Pole, that's the other end of their supply line....
 # I verified with someone who was there that since 1980,
 # Palmer has followed Chile.  Prior to that, before the Falklands War,
 # Palmer used to be supplied from Argentina.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Palmer	0	-	zzz	1965
 			-4:00	ArgAQ	AR%sT	1969 Oct 5
 			-3:00	ArgAQ	AR%sT	1982 May
 			-4:00	ChileAQ	CL%sT
 #
 #
 # McMurdo, Ross Island, since 1955-12
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/McMurdo	0	-	zzz	1956
 			12:00	NZAQ	NZ%sT
 #
 # Amundsen-Scott, South Pole, continuously occupied since 1956-11-20
 #
 # From Paul Eggert (1996-09-03):
 # Normally it wouldn't have a separate entry, since it's like the
 # larger Antarctica/McMurdo since 1970, but it's too famous to omit.
 #
 # From Chris Carrier (1996-06-27):
 # Siple, the first commander of the South Pole station,
 # stated that he would have liked to have kept GMT at the station,
 # but that he found it more convenient to keep GMT+12
 # as supplies for the station were coming from McMurdo Sound,
 # which was on GMT+12 because New Zealand was on GMT+12 all year
 # at that time (1957).  (Source: Siple's book 90 degrees SOUTH.)
 #
 # From Susan Smith
 # http://www.cybertours.com/whs/pole10.html
 # (1995-11-13 16:24:56 +1300, no longer available):
 # We use the same time as McMurdo does.
 # And they use the same time as Christchurch, NZ does....
 # One last quirk about South Pole time.
 # All the electric clocks are usually wrong.
 # Something about the generators running at 60.1hertz or something
 # makes all of the clocks run fast.  So every couple of days,
 # we have to go around and set them back 5 minutes or so.
 # Maybe if we let them run fast all of the time, we'd get to leave here sooner!!
 #
 Link	Antarctica/McMurdo	Antarctica/South_Pole
Index: user/attilio/vmcontention/contrib/tzdata/asia
===================================================================
--- user/attilio/vmcontention/contrib/tzdata/asia	(revision 249698)
+++ user/attilio/vmcontention/contrib/tzdata/asia	(revision 249699)
@@ -1,2751 +1,2755 @@
 # 
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # This data is by no means authoritative; if you think you know better,
 # go ahead and edit the file (and please send any changes to
 # tz@iana.org for general use in the future).
 
 # From Paul Eggert (2013-02-21):
 #
 # A good source for time zone historical data outside the U.S. is
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 #
 # Gwillim Law writes that a good source
 # for recent time zone data is the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.
 #
 # Except where otherwise noted, Shanks & Pottenger is the source for
 # entries through 1990, and IATA SSIM is the source for entries afterwards.
 #
 # Another source occasionally used is Edward W. Whitman, World Time Differences,
 # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
 # I found in the UCLA library.
 #
 # For data circa 1899, a common source is:
 # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
 # .
 #
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
 # I invented the abbreviations marked `*' in the following table;
 # the rest are from earlier versions of this file, or from other sources.
 # Corrections are welcome!
 #	     std  dst
 #	     LMT	Local Mean Time
 #	2:00 EET  EEST	Eastern European Time
 #	2:00 IST  IDT	Israel
 #	3:00 AST  ADT	Arabia*
 #	3:30 IRST IRDT	Iran
 #	4:00 GST	Gulf*
 #	5:30 IST	India
 #	7:00 ICT	Indochina*
 #	7:00 WIT	west Indonesia
 #	8:00 CIT	central Indonesia
 #	8:00 CST	China
 #	9:00 CJT	Central Japanese Time (1896/1937)*
 #	9:00 EIT	east Indonesia
 #	9:00 JST  JDT	Japan
 #	9:00 KST  KDT	Korea
 #	9:30 CST	(Australian) Central Standard Time
 #
 # See the `europe' file for Russia and Turkey in Asia.
 
 # From Guy Harris:
 # Incorporates data for Singapore from Robert Elz' asia 1.1, as well as
 # additional information from Tom Yap, Sun Microsystems Intercontinental
 # Technical Support (including a page from the Official Airline Guide -
 # Worldwide Edition).  The names for time zones are guesses.
 
 ###############################################################################
 
 # These rules are stolen from the `europe' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	EUAsia	1981	max	-	Mar	lastSun	 1:00u	1:00	S
 Rule	EUAsia	1979	1995	-	Sep	lastSun	 1:00u	0	-
 Rule	EUAsia	1996	max	-	Oct	lastSun	 1:00u	0	-
 Rule E-EurAsia	1981	max	-	Mar	lastSun	 0:00	1:00	S
 Rule E-EurAsia	1979	1995	-	Sep	lastSun	 0:00	0	-
 Rule E-EurAsia	1996	max	-	Oct	lastSun	 0:00	0	-
 Rule RussiaAsia	1981	1984	-	Apr	1	 0:00	1:00	S
 Rule RussiaAsia	1981	1983	-	Oct	1	 0:00	0	-
 Rule RussiaAsia	1984	1991	-	Sep	lastSun	 2:00s	0	-
 Rule RussiaAsia	1985	1991	-	Mar	lastSun	 2:00s	1:00	S
 Rule RussiaAsia	1992	only	-	Mar	lastSat	23:00	1:00	S
 Rule RussiaAsia	1992	only	-	Sep	lastSat	23:00	0	-
 Rule RussiaAsia	1993	max	-	Mar	lastSun	 2:00s	1:00	S
 Rule RussiaAsia	1993	1995	-	Sep	lastSun	 2:00s	0	-
 Rule RussiaAsia	1996	max	-	Oct	lastSun	 2:00s	0	-
 
 # Afghanistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kabul	4:36:48 -	LMT	1890
 			4:00	-	AFT	1945
 			4:30	-	AFT
 
 # Armenia
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger have Yerevan switching to 3:00 (with Russian DST)
 # in spring 1991, then to 4:00 with no DST in fall 1995, then
 # readopting Russian DST in 1997.  Go with Shanks & Pottenger, even
 # when they disagree with others.  Edgar Der-Danieliantz
 # reported (1996-05-04) that Yerevan probably wouldn't use DST
 # in 1996, though it did use DST in 1995.  IATA SSIM (1991/1998) reports that
 # Armenia switched from 3:00 to 4:00 in 1998 and observed DST after 1991,
 # but started switching at 3:00s in 1998.
 
 # From Arthur David Olson (2011-06-15):
 # While Russia abandoned DST in 2011, Armenia may choose to
 # follow Russia's "old" rules.
 
 # From Alexander Krivenyshev (2012-02-10):
 # According to News Armenia, on Feb 9, 2012,
 # http://newsarmenia.ru/society/20120209/42609695.html
 #
 # The Armenia National Assembly adopted final reading of Amendments to the
 # Law "On procedure of calculation time on the territory of the Republic of
 # Armenia" according to which Armenia [is] abolishing Daylight Saving Time.
 # or
 # (brief)
 # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Yerevan	2:58:00 -	LMT	1924 May  2
 			3:00	-	YERT	1957 Mar    # Yerevan Time
 			4:00 RussiaAsia YER%sT	1991 Mar 31 2:00s
 			3:00	1:00	YERST	1991 Sep 23 # independence
 			3:00 RussiaAsia	AM%sT	1995 Sep 24 2:00s
 			4:00	-	AMT	1997
 			4:00 RussiaAsia	AM%sT	2012 Mar 25 2:00s
 			4:00	-	AMT
 
 # Azerbaijan
 # From Rustam Aliyev of the Azerbaijan Internet Forum (2005-10-23):
 # According to the resolution of Cabinet of Ministers, 1997
 # Resolution available at: http://aif.az/docs/daylight_res.pdf
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Azer	1997	max	-	Mar	lastSun	 4:00	1:00	S
 Rule	Azer	1997	max	-	Oct	lastSun	 5:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baku	3:19:24 -	LMT	1924 May  2
 			3:00	-	BAKT	1957 Mar    # Baku Time
 			4:00 RussiaAsia BAK%sT	1991 Mar 31 2:00s
 			3:00	1:00	BAKST	1991 Aug 30 # independence
 			3:00 RussiaAsia	AZ%sT	1992 Sep lastSat 23:00
 			4:00	-	AZT	1996 # Azerbaijan time
 			4:00	EUAsia	AZ%sT	1997
 			4:00	Azer	AZ%sT
 
 # Bahrain
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bahrain	3:22:20 -	LMT	1920		# Al Manamah
 			4:00	-	GST	1972 Jun
 			3:00	-	AST
 
 # Bangladesh
 # From Alexander Krivenyshev (2009-05-13):
 # According to newspaper Asian Tribune (May 6, 2009) Bangladesh may introduce
 # Daylight Saving Time from June 16 to Sept 30
 #
 # Bangladesh to introduce daylight saving time likely from June 16
 # 
 # http://www.asiantribune.com/?q=node/17288
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html
 # 
 #
 # "... Bangladesh government has decided to switch daylight saving time from
 # June
 # 16 till September 30 in a bid to ensure maximum use of daylight to cope with
 # crippling power crisis. "
 #
 # The switch will remain in effect from June 16 to Sept 30 (2009) but if
 # implemented the next year, it will come in force from April 1, 2010
 
 # From Steffen Thorsen (2009-06-02):
 # They have finally decided now, but changed the start date to midnight between
 # the 19th and 20th, and they have not set the end date yet.
 #
 # Some sources:
 # 
 # http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601
 # 
 # 
 # http://bdnews24.com/details.php?id=85889&cid=2
 # 
 #
 # Our wrap-up:
 # 
 # http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html
 # 
 
 # From A. N. M. Kamrus Saadat (2009-06-15):
 # Finally we've got the official mail regarding DST start time where DST start
 # time is mentioned as Jun 19 2009, 23:00 from BTRC (Bangladesh
 # Telecommunication Regulatory Commission).
 #
 # No DST end date has been announced yet.
 
 # From Alexander Krivenyshev (2009-09-25):
 # Bangladesh won't go back to Standard Time from October 1, 2009,
 # instead it will continue DST measure till the cabinet makes a fresh decision.
 #
 # Following report by same newspaper-"The Daily Star Friday":
 # "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1"
 # 
 # http://www.thedailystar.net/newDesign/news-details.php?nid=107021
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html
 # 
 
 # From Steffen Thorsen (2009-10-13):
 # IANS (Indo-Asian News Service) now reports:
 # Bangladesh has decided that the clock advanced by an hour to make
 # maximum use of daylight hours as an energy saving measure would
 # "continue for an indefinite period."
 #
 # One of many places where it is published:
 # 
 # http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html
 # 
 
 # From Alexander Krivenyshev (2009-12-24):
 # According to Bangladesh newspaper "The Daily Star,"
 # Bangladesh will change its clock back to Standard Time on Dec 31, 2009.
 #
 # Clock goes back 1-hr on Dec 31 night.
 # 
 # http://www.thedailystar.net/newDesign/news-details.php?nid=119228
 # 
 # and
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_bangladesh05.html
 # 
 #
 # "...The government yesterday decided to put the clock back by one hour
 # on December 31 midnight and the new time will continue until March 31,
 # 2010 midnight. The decision came at a cabinet meeting at the Prime
 # Minister's Office last night..."
 
 # From Alexander Krivenyshev (2010-03-22):
 # According to Bangladesh newspaper "The Daily Star,"
 # Cabinet cancels Daylight Saving Time
 # 
 # http://www.thedailystar.net/newDesign/latest_news.php?nid=22817
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_bangladesh06.html
 # 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Dhaka	2009	only	-	Jun	19	23:00	1:00	S
 Rule	Dhaka	2009	only	-	Dec	31	23:59	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
 			6:30	-	BURT	1942 May 15 # Burma Time
 			5:30	-	IST	1942 Sep
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009
 			6:00	Dhaka	BD%sT
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Thimphu	5:58:36 -	LMT	1947 Aug 15 # or Thimbu
 			5:30	-	IST	1987 Oct
 			6:00	-	BTT	# Bhutan Time
 
 # British Indian Ocean Territory
 # Whitman and the 1995 CIA time zone map say 5:00, but the
 # 1997 and later maps say 6:00.  Assume the switch occurred in 1996.
 # We have no information as to when standard time was introduced;
 # assume it occurred in 1907, the same year as Mauritius (which
 # then contained the Chagos Archipelago).
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Chagos	4:49:40	-	LMT	1907
 			5:00	-	IOT	1996 # BIOT Time
 			6:00	-	IOT
 
 # Brunei
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Brunei	7:39:40 -	LMT	1926 Mar   # Bandar Seri Begawan
 			7:30	-	BNT	1933
 			8:00	-	BNT
 
 # Burma / Myanmar
 
 # Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Rangoon	6:24:40 -	LMT	1880		# or Yangon
 			6:24:40	-	RMT	1920	   # Rangoon Mean Time?
 			6:30	-	BURT	1942 May   # Burma Time
 			9:00	-	JST	1945 May 3
 			6:30	-	MMT		   # Myanmar Time
 
 # Cambodia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Phnom_Penh	6:59:40 -	LMT	1906 Jun  9
 			7:06:20	-	SMT	1911 Mar 11 0:01 # Saigon MT?
 			7:00	-	ICT	1912 May
 			8:00	-	ICT	1931 May
 			7:00	-	ICT
 
 # China
 
 # From Guy Harris:
 # People's Republic of China.  Yes, they really have only one time zone.
 
 # From Bob Devine (1988-01-28):
 # No they don't.  See TIME mag, 1986-02-17 p.52.  Even though
 # China is across 4 physical time zones, before Feb 1, 1986 only the
 # Peking (Bejing) time zone was recognized.  Since that date, China
 # has two of 'em -- Peking's and Urumqi (named after the capital of
 # the Xinjiang Uyghur Autonomous Region).  I don't know about DST for it.
 #
 # . . .I just deleted the DST table and this editor makes it too
 # painful to suck in another copy..  So, here is what I have for
 # DST start/end dates for Peking's time zone (info from AP):
 #
 #     1986 May 4 - Sept 14
 #     1987 mid-April - ??
 
 # From U. S. Naval Observatory (1989-01-19):
 # CHINA               8 H  AHEAD OF UTC  ALL OF CHINA, INCL TAIWAN
 # CHINA               9 H  AHEAD OF UTC  APR 17 - SEP 10
 
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger write that China (except for Hong Kong and Macau)
 # has had a single time zone since 1980 May 1, observing summer DST
 # from 1986 through 1991; this contradicts Devine's
 # note about Time magazine, though apparently _something_ happened in 1986.
 # Go with Shanks & Pottenger for now.  I made up names for the other
 # pre-1980 time zones.
 
 # From Shanks & Pottenger:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Shang	1940	only	-	Jun	 3	0:00	1:00	D
 Rule	Shang	1940	1941	-	Oct	 1	0:00	0	S
 Rule	Shang	1941	only	-	Mar	16	0:00	1:00	D
 Rule	PRC	1986	only	-	May	 4	0:00	1:00	D
 Rule	PRC	1986	1991	-	Sep	Sun>=11	0:00	0	S
 Rule	PRC	1987	1991	-	Apr	Sun>=10	0:00	1:00	D
 
 # From Anthony Fok (2001-12-20):
 # BTW, I did some research on-line and found some info regarding these five
 # historic timezones from some Taiwan websites.  And yes, there are official
 # Chinese names for these locales (before 1949).
 #
 # From Jesper Norgaard Welen (2006-07-14):
 # I have investigated the timezones around 1970 on the
 # http://www.astro.com/atlas site [with provinces and county
 # boundaries summarized below]....  A few other exceptions were two
 # counties on the Sichuan side of the Xizang-Sichuan border,
 # counties Dege and Baiyu which lies on the Sichuan side and are
 # therefore supposed to be GMT+7, Xizang region being GMT+6, but Dege
 # county is GMT+8 according to astro.com while Baiyu county is GMT+6
 # (could be true), for the moment I am assuming that those two
 # counties are mistakes in the astro.com data.
 
 # From Paul Eggert (2008-02-11):
 # I just now checked Google News for western news sources that talk
 # about China's single time zone, and couldn't find anything before 1986
 # talking about China being in one time zone.  (That article was: Jim
 # Mann, "A clumsy embrace for another western custom: China on daylight
 # time--sort of", Los Angeles Times, 1986-05-05.  By the way, this
 # article confirms the tz database's data claiming that China began
 # observing daylight saving time in 1986.
 #
 # From Thomas S. Mullaney (2008-02-11):
 # I think you're combining two subjects that need to treated
 # separately: daylight savings (which, you're correct, wasn't
 # implemented until the 1980s) and the unified time zone centered near
 # Beijing (which was implemented in 1949). Briefly, there was also a
 # "Lhasa Time" in Tibet and "Urumqi Time" in Xinjiang. The first was
 # ceased, and the second eventually recognized (again, in the 1980s).
 #
 # From Paul Eggert (2008-06-30):
 # There seems to be a good chance China switched to a single time zone in 1949
 # rather than in 1980 as Shanks & Pottenger have it, but we don't have a
 # reliable documentary source saying so yet, so for now we still go with
 # Shanks & Pottenger.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Changbai Time ("Long-white Time", Long-white = Heilongjiang area)
 # Heilongjiang (except Mohe county), Jilin
 Zone	Asia/Harbin	8:26:44	-	LMT	1928 # or Haerbin
 			8:30	-	CHAT	1932 Mar # Changbai Time
 			8:00	-	CST	1940
 			9:00	-	CHAT	1966 May
 			8:30	-	CHAT	1980 May
 			8:00	PRC	C%sT
 # Zhongyuan Time ("Central plain Time")
 # most of China
 # Milne gives 8:05:56.7; round to nearest.
 Zone	Asia/Shanghai	8:05:57	-	LMT	1928
 			8:00	Shang	C%sT	1949
 			8:00	PRC	C%sT
 # Long-shu Time (probably due to Long and Shu being two names of that area)
 # Guangxi, Guizhou, Hainan, Ningxia, Sichuan, Shaanxi, and Yunnan;
 # most of Gansu; west Inner Mongolia; west Qinghai; and the Guangdong
 # counties Deqing, Enping, Kaiping, Luoding, Taishan, Xinxing,
 # Yangchun, Yangjiang, Yu'nan, and Yunfu.
 Zone	Asia/Chongqing	7:06:20	-	LMT	1928 # or Chungking
 			7:00	-	LONT	1980 May # Long-shu Time
 			8:00	PRC	C%sT
 # Xin-zang Time ("Xinjiang-Tibet Time")
 # The Gansu counties Aksay, Anxi, Dunhuang, Subei; west Qinghai;
 # the Guangdong counties  Xuwen, Haikang, Suixi, Lianjiang,
 # Zhanjiang, Wuchuan, Huazhou, Gaozhou, Maoming, Dianbai, and Xinyi;
 # east Tibet, including Lhasa, Chamdo, Shigaise, Jimsar, Shawan and Hutubi;
 # east Xinjiang, including Urumqi, Turpan, Karamay, Korla, Minfeng, Jinghe,
 # Wusu, Qiemo, Xinyan, Wulanwusu, Jinghe, Yumin, Tacheng, Tuoli, Emin,
 # Shihezi, Changji, Yanqi, Heshuo, Tuokexun, Tulufan, Shanshan, Hami,
 # Fukang, Kuitun, Kumukuli, Miquan, Qitai, and Turfan.
 Zone	Asia/Urumqi	5:50:20	-	LMT	1928 # or Urumchi
 			6:00	-	URUT	1980 May # Urumqi Time
 			8:00	PRC	C%sT
 # Kunlun Time
 # West Tibet, including Pulan, Aheqi, Shufu, Shule;
 # West Xinjiang, including Aksu, Atushi, Yining, Hetian, Cele, Luopu, Nileke,
 # Zhaosu, Tekesi, Gongliu, Chabuchaer, Huocheng, Bole, Pishan, Suiding,
 # and Yarkand.
 
 # From Luther Ma (2009-10-17):
 # Almost all (>99.9%) ethnic Chinese (properly ethnic Han) living in
 # Xinjiang use Chinese Standard Time. Some are aware of Xinjiang time,
 # but have no need of it. All planes, trains, and schools function on
 # what is called "Beijing time." When Han make an appointment in Chinese
 # they implicitly use Beijing time.
 #
 # On the other hand, ethnic Uyghurs, who make up about half the
 # population of Xinjiang, typically use "Xinjiang time" which is two
 # hours behind Beijing time, or UTC +0600. The government of the Xinjiang
 # Uyghur Autonomous Region, (XAUR, or just Xinjiang for short) as well as
 # local governments such as the Urumqi city government use both times in
 # publications, referring to what is popularly called Xinjiang time as
 # "Urumqi time." When Uyghurs make an appointment in the Uyghur language
 # they almost invariably use Xinjiang time.
 #
 # (Their ethnic Han compatriots would typically have no clue of its
 # widespread use, however, because so extremely few of them are fluent in
 # Uyghur, comparable to the number of Anglo-Americans fluent in Navajo.)
 #
 # (...As with the rest of China there was a brief interval ending in 1990
 # or 1991 when summer time was in use.  The confusion was severe, with
 # the province not having dual times but four times in use at the same
 # time. Some areas remained on standard Xinjiang time or Beijing time and
 # others moving their clocks ahead.)
 #
 # ...an example of an official website using of Urumqi time.
 #
 # The first few lines of the Google translation of
 # 
 # http://www.fjysgl.gov.cn/show.aspx?id=2379&cid=39
 # 
 # (retrieved 2009-10-13)
 # > Urumqi fire seven people are missing the alleged losses of at least
 # > 500 million yuan
 # >
 # > (Reporter Dong Liu) the day before 20:20 or so (Urumqi Time 18:20),
 # > Urumqi City Department of International Plaza Luther Qiantang River
 # > burst fire. As of yesterday, 18:30, Urumqi City Fire officers and men
 # > have worked continuously for 22 hours...
 
 # From Luther Ma (2009-11-19):
 # With the risk of being redundant to previous answers these are the most common
 # English "transliterations" (w/o using non-English symbols):
 #
 # 1. Wulumuqi...
 # 2. Kashi...
 # 3. Urumqi...
 # 4. Kashgar...
 # ...
 # 5. It seems that Uyghurs in Urumqi has been using Xinjiang since at least the
 # 1960's. I know of one Han, now over 50, who grew up in the surrounding
 # countryside and used Xinjiang time as a child.
 #
 # 6. Likewise for Kashgar and the rest of south Xinjiang I don't know of any
 # start date for Xinjiang time.
 #
 # Without having access to local historical records, nor the ability to legally
 # publish them, I would go with October 1, 1949, when Xinjiang became the Uyghur
 # Autonomous Region under the PRC. (Before that Uyghurs, of course, would also
 # not be using Beijing time, but some local time.)
 
 Zone	Asia/Kashgar	5:03:56	-	LMT	1928 # or Kashi or Kaxgar
 			5:30	-	KAST	1940	 # Kashgar Time
 			5:00	-	KAST	1980 May
 			8:00	PRC	C%sT
 
 
 # Hong Kong (Xianggang)
 
 # Milne gives 7:36:41.7; round this.
 
 # From Lee Yiu Chung (2009-10-24):
 # I found there are some mistakes for the...DST rule for Hong
 # Kong. [According] to the DST record from Hong Kong Observatory (actually,
 # it is not [an] observatory, but the official meteorological agency of HK,
 # and also serves as the official timing agency), there are some missing
 # and incorrect rules. Although the exact switch over time is missing, I
 # think 3:30 is correct. The official DST record for Hong Kong can be
 # obtained from
 # 
 # http://www.hko.gov.hk/gts/time/Summertime.htm
 # .
 
 # From Arthur David Olson (2009-10-28):
 # Here are the dates given at
 # 
 # http://www.hko.gov.hk/gts/time/Summertime.htm
 # 
 # as of 2009-10-28:
 # Year        Period
 # 1941        1 Apr to 30 Sep
 # 1942        Whole year
 # 1943        Whole year
 # 1944        Whole year
 # 1945        Whole year
 # 1946        20 Apr to 1 Dec
 # 1947        13 Apr to 30 Dec
 # 1948        2 May to 31 Oct
 # 1949        3 Apr to 30 Oct
 # 1950        2 Apr to 29 Oct
 # 1951        1 Apr to 28 Oct
 # 1952        6 Apr to 25 Oct
 # 1953        5 Apr to 1 Nov
 # 1954        21 Mar to 31 Oct
 # 1955        20 Mar to 6 Nov
 # 1956        18 Mar to 4 Nov
 # 1957        24 Mar to 3 Nov
 # 1958        23 Mar to 2 Nov
 # 1959        22 Mar to 1 Nov
 # 1960        20 Mar to 6 Nov
 # 1961        19 Mar to 5 Nov
 # 1962        18 Mar to 4 Nov
 # 1963        24 Mar to 3 Nov
 # 1964        22 Mar to 1 Nov
 # 1965        18 Apr to 17 Oct
 # 1966        17 Apr to 16 Oct
 # 1967        16 Apr to 22 Oct
 # 1968        21 Apr to 20 Oct
 # 1969        20 Apr to 19 Oct
 # 1970        19 Apr to 18 Oct
 # 1971        18 Apr to 17 Oct
 # 1972        16 Apr to 22 Oct
 # 1973        22 Apr to 21 Oct
 # 1973/74     30 Dec 73 to 20 Oct 74
 # 1975        20 Apr to 19 Oct
 # 1976        18 Apr to 17 Oct
 # 1977        Nil
 # 1978        Nil
 # 1979        13 May to 21 Oct
 # 1980 to Now Nil
 # The page does not give start or end times of day.
 # The page does not give a start date for 1942.
 # The page does not givw an end date for 1945.
 # The Japanese occupation of Hong Kong began on 1941-12-25.
 # The Japanese surrender of Hong Kong was signed 1945-09-15.
 # For lack of anything better, use start of those days as the transition times.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	HK	1941	only	-	Apr	1	3:30	1:00	S
 Rule	HK	1941	only	-	Sep	30	3:30	0	-
 Rule	HK	1946	only	-	Apr	20	3:30	1:00	S
 Rule	HK	1946	only	-	Dec	1	3:30	0	-
 Rule	HK	1947	only	-	Apr	13	3:30	1:00	S
 Rule	HK	1947	only	-	Dec	30	3:30	0	-
 Rule	HK	1948	only	-	May	2	3:30	1:00	S
 Rule	HK	1948	1951	-	Oct	lastSun	3:30	0	-
 Rule	HK	1952	only	-	Oct	25	3:30	0	-
 Rule	HK	1949	1953	-	Apr	Sun>=1	3:30	1:00	S
 Rule	HK	1953	only	-	Nov	1	3:30	0	-
 Rule	HK	1954	1964	-	Mar	Sun>=18	3:30	1:00	S
 Rule	HK	1954	only	-	Oct	31	3:30	0	-
 Rule	HK	1955	1964	-	Nov	Sun>=1	3:30	0	-
 Rule	HK	1965	1976	-	Apr	Sun>=16	3:30	1:00	S
 Rule	HK	1965	1976	-	Oct	Sun>=16	3:30	0	-
 Rule	HK	1973	only	-	Dec	30	3:30	1:00	S
 Rule	HK	1979	only	-	May	Sun>=8	3:30	1:00	S
 Rule	HK	1979	only	-	Oct	Sun>=16	3:30	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Hong_Kong	7:36:42 -	LMT	1904 Oct 30
 			8:00	HK	HK%sT	1941 Dec 25
 			9:00	-	JST	1945 Sep 15
 			8:00	HK	HK%sT
 
 ###############################################################################
 
 # Taiwan
 
 # Shanks & Pottenger write that Taiwan observed DST during 1945, when it
 # was still controlled by Japan.  This is hard to believe, but we don't
 # have any other information.
 
 # From smallufo (2010-04-03):
 # According to Taiwan's CWB,
 # 
 # http://www.cwb.gov.tw/V6/astronomy/cdata/summert.htm
 # 
 # Taipei has DST in 1979 between July 1st and Sep 30.
 
 # From Arthur David Olson (2010-04-07):
 # Here's Google's translation of the table at the bottom of the "summert.htm" page:
 # Decade 	                                                    Name                      Start and end date
 # Republic of China 34 years to 40 years (AD 1945-1951 years) Summer Time               May 1 to September 30
 # 41 years of the Republic of China (AD 1952)                 Daylight Saving Time      March 1 to October 31
 # Republic of China 42 years to 43 years (AD 1953-1954 years) Daylight Saving Time      April 1 to October 31
 # In the 44 years to 45 years (AD 1955-1956 years)            Daylight Saving Time      April 1 to September 30
 # Republic of China 46 years to 48 years (AD 1957-1959)       Summer Time               April 1 to September 30
 # Republic of China 49 years to 50 years (AD 1960-1961)       Summer Time               June 1 to September 30
 # Republic of China 51 years to 62 years (AD 1962-1973 years) Stop Summer Time
 # Republic of China 63 years to 64 years (1974-1975 AD)       Daylight Saving Time      April 1 to September 30
 # Republic of China 65 years to 67 years (1976-1978 AD)       Stop Daylight Saving Time
 # Republic of China 68 years (AD 1979)                        Daylight Saving Time      July 1 to September 30
 # Republic of China since 69 years (AD 1980)                  Stop Daylight Saving Time
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Taiwan	1945	1951	-	May	1	0:00	1:00	D
 Rule	Taiwan	1945	1951	-	Oct	1	0:00	0	S
 Rule	Taiwan	1952	only	-	Mar	1	0:00	1:00	D
 Rule	Taiwan	1952	1954	-	Nov	1	0:00	0	S
 Rule	Taiwan	1953	1959	-	Apr	1	0:00	1:00	D
 Rule	Taiwan	1955	1961	-	Oct	1	0:00	0	S
 Rule	Taiwan	1960	1961	-	Jun	1	0:00	1:00	D
 Rule	Taiwan	1974	1975	-	Apr	1	0:00	1:00	D
 Rule	Taiwan	1974	1975	-	Oct	1	0:00	0	S
 Rule	Taiwan	1979	only	-	Jun	30	0:00	1:00	D
 Rule	Taiwan	1979	only	-	Sep	30	0:00	0	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Taipei	8:06:00 -	LMT	1896 # or Taibei or T'ai-pei
 			8:00	Taiwan	C%sT
 
 # Macau (Macao, Aomen)
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Macau	1961	1962	-	Mar	Sun>=16	3:30	1:00	S
 Rule	Macau	1961	1964	-	Nov	Sun>=1	3:30	0	-
 Rule	Macau	1963	only	-	Mar	Sun>=16	0:00	1:00	S
 Rule	Macau	1964	only	-	Mar	Sun>=16	3:30	1:00	S
 Rule	Macau	1965	only	-	Mar	Sun>=16	0:00	1:00	S
 Rule	Macau	1965	only	-	Oct	31	0:00	0	-
 Rule	Macau	1966	1971	-	Apr	Sun>=16	3:30	1:00	S
 Rule	Macau	1966	1971	-	Oct	Sun>=16	3:30	0	-
 Rule	Macau	1972	1974	-	Apr	Sun>=15	0:00	1:00	S
 Rule	Macau	1972	1973	-	Oct	Sun>=15	0:00	0	-
 Rule	Macau	1974	1977	-	Oct	Sun>=15	3:30	0	-
 Rule	Macau	1975	1977	-	Apr	Sun>=15	3:30	1:00	S
 Rule	Macau	1978	1980	-	Apr	Sun>=15	0:00	1:00	S
 Rule	Macau	1978	1980	-	Oct	Sun>=15	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Macau	7:34:20 -	LMT	1912
 			8:00	Macau	MO%sT	1999 Dec 20 # return to China
 			8:00	PRC	C%sT
 
 
 ###############################################################################
 
 # Cyprus
 #
 # Milne says the Eastern Telegraph Company used 2:14:00.  Stick with LMT.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Cyprus	1975	only	-	Apr	13	0:00	1:00	S
 Rule	Cyprus	1975	only	-	Oct	12	0:00	0	-
 Rule	Cyprus	1976	only	-	May	15	0:00	1:00	S
 Rule	Cyprus	1976	only	-	Oct	11	0:00	0	-
 Rule	Cyprus	1977	1980	-	Apr	Sun>=1	0:00	1:00	S
 Rule	Cyprus	1977	only	-	Sep	25	0:00	0	-
 Rule	Cyprus	1978	only	-	Oct	2	0:00	0	-
 Rule	Cyprus	1979	1997	-	Sep	lastSun	0:00	0	-
 Rule	Cyprus	1981	1998	-	Mar	lastSun	0:00	1:00	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Nicosia	2:13:28 -	LMT	1921 Nov 14
 			2:00	Cyprus	EE%sT	1998 Sep
 			2:00	EUAsia	EE%sT
 # IATA SSIM (1998-09) has Cyprus using EU rules for the first time.
 
 # Classically, Cyprus belongs to Asia; e.g. see Herodotus, Histories, I.72.
 # However, for various reasons many users expect to find it under Europe.
 Link	Asia/Nicosia	Europe/Nicosia
 
 # Georgia
 # From Paul Eggert (1994-11-19):
 # Today's _Economist_ (p 60) reports that Georgia moved its clocks forward
 # an hour recently, due to a law proposed by Zurab Murvanidze,
 # an MP who went on a hunger strike for 11 days to force discussion about it!
 # We have no details, but we'll guess they didn't move the clocks back in fall.
 #
 # From Mathew Englander, quoting AP (1996-10-23 13:05-04):
 # Instead of putting back clocks at the end of October, Georgia
 # will stay on daylight savings time this winter to save energy,
 # President Eduard Shevardnadze decreed Wednesday.
 #
 # From the BBC via Joseph S. Myers (2004-06-27):
 #
 # Georgia moved closer to Western Europe on Sunday...  The former Soviet
 # republic has changed its time zone back to that of Moscow.  As a result it
 # is now just four hours ahead of Greenwich Mean Time, rather than five hours
 # ahead.  The switch was decreed by the pro-Western president of Georgia,
 # Mikhail Saakashvili, who said the change was partly prompted by the process
 # of integration into Europe.
 
 # From Teimuraz Abashidze (2005-11-07):
 # Government of Georgia ... decided to NOT CHANGE daylight savings time on
 # [Oct.] 30, as it was done before during last more than 10 years.
 # Currently, we are in fact GMT +4:00, as before 30 October it was GMT
 # +3:00.... The problem is, there is NO FORMAL LAW or governmental document
 # about it.  As far as I can find, I was told, that there is no document,
 # because we just DIDN'T ISSUE document about switching to winter time....
 # I don't know what can be done, especially knowing that some years ago our
 # DST rules where changed THREE TIMES during one month.
 
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tbilisi	2:59:16 -	LMT	1880
 			2:59:16	-	TBMT	1924 May  2 # Tbilisi Mean Time
 			3:00	-	TBIT	1957 Mar    # Tbilisi Time
 			4:00 RussiaAsia TBI%sT	1991 Mar 31 2:00s
 			3:00	1:00	TBIST	1991 Apr  9 # independence
 			3:00 RussiaAsia GE%sT	1992 # Georgia Time
 			3:00 E-EurAsia	GE%sT	1994 Sep lastSun
 			4:00 E-EurAsia	GE%sT	1996 Oct lastSun
 			4:00	1:00	GEST	1997 Mar lastSun
 			4:00 E-EurAsia	GE%sT	2004 Jun 27
 			3:00 RussiaAsia	GE%sT	2005 Mar lastSun 2:00
 			4:00	-	GET
 
 # East Timor
 
 # See Indonesia for the 1945 transition.
 
 # From Joao Carrascalao, brother of the former governor of East Timor, in
 # 
 # East Timor may be late for its millennium
 #  (1999-12-26/31):
 # Portugal tried to change the time forward in 1974 because the sun
 # rises too early but the suggestion raised a lot of problems with the
 # Timorese and I still don't think it would work today because it
 # conflicts with their way of life.
 
 # From Paul Eggert (2000-12-04):
 # We don't have any record of the above attempt.
 # Most likely our records are incomplete, but we have no better data.
 
 # 
 # From Manoel de Almeida e Silva, Deputy Spokesman for the UN Secretary-General
 # (2000-08-16):
 # The Cabinet of the East Timor Transition Administration decided
 # today to advance East Timor's time by one hour.  The time change,
 # which will be permanent, with no seasonal adjustment, will happen at
 # midnight on Saturday, September 16.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dili	8:22:20 -	LMT	1912
 			8:00	-	TLT	1942 Feb 21 23:00 # E Timor Time
 			9:00	-	JST	1945 Sep 23
 			9:00	-	TLT	1976 May  3
 			8:00	-	CIT	2000 Sep 17 00:00
 			9:00	-	TLT
 
 # India
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kolkata	5:53:28 -	LMT	1880	# Kolkata
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
 			6:30	-	BURT	1942 May 15 # Burma Time
 			5:30	-	IST	1942 Sep
 			5:30	1:00	IST	1945 Oct 15
 			5:30	-	IST
 # The following are like Asia/Kolkata:
 #	Andaman Is
 #	Lakshadweep (Laccadive, Minicoy and Amindivi Is)
 #	Nicobar Is
 
 # Indonesia
 #
 # From Gwillim Law (2001-05-28), overriding Shanks & Pottenger:
 # 
 # says that Indonesia's time zones changed on 1988-01-01.  Looking at some
 # time zone maps, I think that must refer to Western Borneo (Kalimantan Barat
 # and Kalimantan Tengah) switching from UTC+8 to UTC+7.
 #
 # From Paul Eggert (2007-03-10):
 # Here is another correction to Shanks & Pottenger.
 # JohnTWB writes that Japanese forces did not surrender control in
 # Indonesia until 1945-09-01 00:00 at the earliest (in Jakarta) and
 # other formal surrender ceremonies were September 9, 11, and 13, plus
 # September 12 for the regional surrender to Mountbatten in Singapore.
 # These would be the earliest possible times for a change.
 # Regimes horaires pour le monde entier, by Henri Le Corre, (Editions
 # Traditionnelles, 1987, Paris) says that Java and Madura switched
 # from JST to UTC+07:30 on 1945-09-23, and gives 1944-09-01 for Jayapura
 # (Hollandia).  For now, assume all Indonesian locations other than Jayapura
 # switched on 1945-09-23.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Jakarta	7:07:12 -	LMT	1867 Aug 10
 # Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13,
 # but this must be a typo.
 			7:07:12	-	JMT	1923 Dec 31 23:47:12 # Jakarta
 			7:20	-	JAVT	1932 Nov	 # Java Time
 			7:30	-	WIT	1942 Mar 23
 			9:00	-	JST	1945 Sep 23
 			7:30	-	WIT	1948 May
 			8:00	-	WIT	1950 May
 			7:30	-	WIT	1964
 			7:00	-	WIT
 Zone Asia/Pontianak	7:17:20	-	LMT	1908 May
 			7:17:20	-	PMT	1932 Nov    # Pontianak MT
 			7:30	-	WIT	1942 Jan 29
 			9:00	-	JST	1945 Sep 23
 			7:30	-	WIT	1948 May
 			8:00	-	WIT	1950 May
 			7:30	-	WIT	1964
 			8:00	-	CIT	1988 Jan  1
 			7:00	-	WIT
 Zone Asia/Makassar	7:57:36 -	LMT	1920
 			7:57:36	-	MMT	1932 Nov    # Macassar MT
 			8:00	-	CIT	1942 Feb  9
 			9:00	-	JST	1945 Sep 23
 			8:00	-	CIT
 Zone Asia/Jayapura	9:22:48 -	LMT	1932 Nov
 			9:00	-	EIT	1944 Sep  1
 			9:30	-	CST	1964
 			9:00	-	EIT
 
 # Iran
 
 # From Roozbeh Pournader (2003-03-15):
 # This is an English translation of what I just found (originally in Persian).
 # The Gregorian dates in brackets are mine:
 #
 #	Official Newspaper No. 13548-1370/6/25 [1991-09-16]
 #	No. 16760/T233 H				1370/6/10 [1991-09-01]
 #
 #	The Rule About Change of the Official Time of the Country
 #
 #	The Board of Ministers, in the meeting dated 1370/5/23 [1991-08-14],
 #	based on the suggestion number 2221/D dated 1370/4/22 [1991-07-13]
 #	of the Country's Organization for Official and Employment Affairs,
 #	and referring to the law for equating the working hours of workers
 #	and officers in the whole country dated 1359/4/23 [1980-07-14], and
 #	for synchronizing the official times of the country, agreed that:
 #
 #	The official time of the country will should move forward one hour
 #	at the 24[:00] hours of the first day of Farvardin and should return
 #	to its previous state at the 24[:00] hours of the 30th day of
 #	Shahrivar.
 #
 #	First Deputy to the President - Hassan Habibi
 #
 # From personal experience, that agrees with what has been followed
 # for at least the last 5 years.  Before that, for a few years, the
 # date used was the first Thursday night of Farvardin and the last
 # Thursday night of Shahrivar, but I can't give exact dates....
 # I have also changed the abbreviations to what is considered correct
 # here in Iran, IRST for regular time and IRDT for daylight saving time.
 #
 # From Roozbeh Pournader (2005-04-05):
 # The text of the Iranian law, in effect since 1925, clearly mentions
 # that the true solar year is the measure, and there is no arithmetic
 # leap year calculation involved.  There has never been any serious
 # plan to change that law....
 #
 # From Paul Eggert (2006-03-22):
 # Go with Shanks & Pottenger before Sept. 1991, and with Pournader thereafter.
 # I used Ed Reingold's cal-persia in GNU Emacs 21.2 to check Persian dates,
 # stopping after 2037 when 32-bit time_t's overflow.
 # That cal-persia used Birashk's approximation, which disagrees with the solar
 # calendar predictions for the year 2025, so I corrected those dates by hand.
 #
 # From Oscar van Vlijmen (2005-03-30), writing about future
 # discrepancies between cal-persia and the Iranian calendar:
 # For 2091 solar-longitude-after yields 2091-03-20 08:40:07.7 UT for
 # the vernal equinox and that gets so close to 12:00 some local
 # Iranian time that the definition of the correct location needs to be
 # known exactly, amongst other factors.  2157 is even closer:
 # 2157-03-20 08:37:15.5 UT.  But the Gregorian year 2025 should give
 # no interpretation problem whatsoever.  By the way, another instant
 # in the near future where there will be a discrepancy between
 # arithmetical and astronomical Iranian calendars will be in 2058:
 # vernal equinox on 2058-03-20 09:03:05.9 UT.  The Java version of
 # Reingold's/Dershowitz' calculator gives correctly the Gregorian date
 # 2058-03-21 for 1 Farvardin 1437 (astronomical).
 #
 # From Steffen Thorsen (2006-03-22):
 # Several of my users have reported that Iran will not observe DST anymore:
 # http://www.irna.ir/en/news/view/line-17/0603193812164948.htm
 #
 # From Reuters (2007-09-16), with a heads-up from Jesper Norgaard Welen:
 # ... the Guardian Council ... approved a law on Sunday to re-introduce
 # daylight saving time ...
 # http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916
 #
 # From Roozbeh Pournader (2007-11-05):
 # This is quoted from Official Gazette of the Islamic Republic of
 # Iran, Volume 63, Number 18242, dated Tuesday 1386/6/24
 # [2007-10-16]. I am doing the best translation I can:...
 # The official time of the country will be moved forward for one hour
 # on the 24 hours of the first day of the month of Farvardin and will
 # be changed back to its previous state on the 24 hours of the
 # thirtieth day of Shahrivar.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Iran	1978	1980	-	Mar	21	0:00	1:00	D
 Rule	Iran	1978	only	-	Oct	21	0:00	0	S
 Rule	Iran	1979	only	-	Sep	19	0:00	0	S
 Rule	Iran	1980	only	-	Sep	23	0:00	0	S
 Rule	Iran	1991	only	-	May	 3	0:00	1:00	D
 Rule	Iran	1992	1995	-	Mar	22	0:00	1:00	D
 Rule	Iran	1991	1995	-	Sep	22	0:00	0	S
 Rule	Iran	1996	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	1996	only	-	Sep	21	0:00	0	S
 Rule	Iran	1997	1999	-	Mar	22	0:00	1:00	D
 Rule	Iran	1997	1999	-	Sep	22	0:00	0	S
 Rule	Iran	2000	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2000	only	-	Sep	21	0:00	0	S
 Rule	Iran	2001	2003	-	Mar	22	0:00	1:00	D
 Rule	Iran	2001	2003	-	Sep	22	0:00	0	S
 Rule	Iran	2004	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2004	only	-	Sep	21	0:00	0	S
 Rule	Iran	2005	only	-	Mar	22	0:00	1:00	D
 Rule	Iran	2005	only	-	Sep	22	0:00	0	S
 Rule	Iran	2008	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2008	only	-	Sep	21	0:00	0	S
 Rule	Iran	2009	2011	-	Mar	22	0:00	1:00	D
 Rule	Iran	2009	2011	-	Sep	22	0:00	0	S
 Rule	Iran	2012	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2012	only	-	Sep	21	0:00	0	S
 Rule	Iran	2013	2015	-	Mar	22	0:00	1:00	D
 Rule	Iran	2013	2015	-	Sep	22	0:00	0	S
 Rule	Iran	2016	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2016	only	-	Sep	21	0:00	0	S
 Rule	Iran	2017	2019	-	Mar	22	0:00	1:00	D
 Rule	Iran	2017	2019	-	Sep	22	0:00	0	S
 Rule	Iran	2020	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2020	only	-	Sep	21	0:00	0	S
 Rule	Iran	2021	2023	-	Mar	22	0:00	1:00	D
 Rule	Iran	2021	2023	-	Sep	22	0:00	0	S
 Rule	Iran	2024	only	-	Mar	21	0:00	1:00	D
 Rule	Iran	2024	only	-	Sep	21	0:00	0	S
 Rule	Iran	2025	2027	-	Mar	22	0:00	1:00	D
 Rule	Iran	2025	2027	-	Sep	22	0:00	0	S
 Rule	Iran	2028	2029	-	Mar	21	0:00	1:00	D
 Rule	Iran	2028	2029	-	Sep	21	0:00	0	S
 Rule	Iran	2030	2031	-	Mar	22	0:00	1:00	D
 Rule	Iran	2030	2031	-	Sep	22	0:00	0	S
 Rule	Iran	2032	2033	-	Mar	21	0:00	1:00	D
 Rule	Iran	2032	2033	-	Sep	21	0:00	0	S
 Rule	Iran	2034	2035	-	Mar	22	0:00	1:00	D
 Rule	Iran	2034	2035	-	Sep	22	0:00	0	S
 Rule	Iran	2036	2037	-	Mar	21	0:00	1:00	D
 Rule	Iran	2036	2037	-	Sep	21	0:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tehran	3:25:44	-	LMT	1916
 			3:25:44	-	TMT	1946	# Tehran Mean Time
 			3:30	-	IRST	1977 Nov
 			4:00	Iran	IR%sT	1979
 			3:30	Iran	IR%sT
 
 
 # Iraq
 #
 # From Jonathan Lennox (2000-06-12):
 # An article in this week's Economist ("Inside the Saddam-free zone", p. 50 in
 # the U.S. edition) on the Iraqi Kurds contains a paragraph:
 # "The three northern provinces ... switched their clocks this spring and
 # are an hour ahead of Baghdad."
 #
 # But Rives McDow (2000-06-18) quotes a contact in Iraqi-Kurdistan as follows:
 # In the past, some Kurdish nationalists, as a protest to the Iraqi
 # Government, did not adhere to daylight saving time.  They referred
 # to daylight saving as Saddam time.  But, as of today, the time zone
 # in Iraqi-Kurdistan is on standard time with Baghdad, Iraq.
 #
 # So we'll ignore the Economist's claim.
 
 # From Steffen Thorsen (2008-03-10):
 # The cabinet in Iraq abolished DST last week, according to the following
 # news sources (in Arabic):
 # 
 # http://www.aljeeran.net/wesima_articles/news-20080305-98602.html
 # 
 # 
 # http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10
 # 
 #
 # We have published a short article in English about the change:
 # 
 # http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html
 # 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Iraq	1982	only	-	May	1	0:00	1:00	D
 Rule	Iraq	1982	1984	-	Oct	1	0:00	0	S
 Rule	Iraq	1983	only	-	Mar	31	0:00	1:00	D
 Rule	Iraq	1984	1985	-	Apr	1	0:00	1:00	D
 Rule	Iraq	1985	1990	-	Sep	lastSun	1:00s	0	S
 Rule	Iraq	1986	1990	-	Mar	lastSun	1:00s	1:00	D
 # IATA SSIM (1991/1996) says Apr 1 12:01am UTC; guess the `:01' is a typo.
 # Shanks & Pottenger say Iraq did not observe DST 1992/1997; ignore this.
 #
 Rule	Iraq	1991	2007	-	Apr	 1	3:00s	1:00	D
 Rule	Iraq	1991	2007	-	Oct	 1	3:00s	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baghdad	2:57:40	-	LMT	1890
 			2:57:36	-	BMT	1918	    # Baghdad Mean Time?
 			3:00	-	AST	1982 May
 			3:00	Iraq	A%sT
 
 
 ###############################################################################
 
 # Israel
 
 # From Ephraim Silverberg (2001-01-11):
 #
 # I coined "IST/IDT" circa 1988.  Until then there were three
 # different abbreviations in use:
 #
 # JST  Jerusalem Standard Time [Danny Braniss, Hebrew University]
 # IZT  Israel Zonal (sic) Time [Prof. Haim Papo, Technion]
 # EEST Eastern Europe Standard Time [used by almost everyone else]
 #
 # Since timezones should be called by country and not capital cities,
 # I ruled out JST.  As Israel is in Asia Minor and not Eastern Europe,
 # EEST was equally unacceptable.  Since "zonal" was not compatible with
 # any other timezone abbreviation, I felt that 'IST' was the way to go
 # and, indeed, it has received almost universal acceptance in timezone
 # settings in Israeli computers.
 #
 # In any case, I am happy to share timezone abbreviations with India,
 # high on my favorite-country list (and not only because my wife's
 # family is from India).
 
 # From Shanks & Pottenger:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	1940	only	-	Jun	 1	0:00	1:00	D
 Rule	Zion	1942	1944	-	Nov	 1	0:00	0	S
 Rule	Zion	1943	only	-	Apr	 1	2:00	1:00	D
 Rule	Zion	1944	only	-	Apr	 1	0:00	1:00	D
 Rule	Zion	1945	only	-	Apr	16	0:00	1:00	D
 Rule	Zion	1945	only	-	Nov	 1	2:00	0	S
 Rule	Zion	1946	only	-	Apr	16	2:00	1:00	D
 Rule	Zion	1946	only	-	Nov	 1	0:00	0	S
 Rule	Zion	1948	only	-	May	23	0:00	2:00	DD
 Rule	Zion	1948	only	-	Sep	 1	0:00	1:00	D
 Rule	Zion	1948	1949	-	Nov	 1	2:00	0	S
 Rule	Zion	1949	only	-	May	 1	0:00	1:00	D
 Rule	Zion	1950	only	-	Apr	16	0:00	1:00	D
 Rule	Zion	1950	only	-	Sep	15	3:00	0	S
 Rule	Zion	1951	only	-	Apr	 1	0:00	1:00	D
 Rule	Zion	1951	only	-	Nov	11	3:00	0	S
 Rule	Zion	1952	only	-	Apr	20	2:00	1:00	D
 Rule	Zion	1952	only	-	Oct	19	3:00	0	S
 Rule	Zion	1953	only	-	Apr	12	2:00	1:00	D
 Rule	Zion	1953	only	-	Sep	13	3:00	0	S
 Rule	Zion	1954	only	-	Jun	13	0:00	1:00	D
 Rule	Zion	1954	only	-	Sep	12	0:00	0	S
 Rule	Zion	1955	only	-	Jun	11	2:00	1:00	D
 Rule	Zion	1955	only	-	Sep	11	0:00	0	S
 Rule	Zion	1956	only	-	Jun	 3	0:00	1:00	D
 Rule	Zion	1956	only	-	Sep	30	3:00	0	S
 Rule	Zion	1957	only	-	Apr	29	2:00	1:00	D
 Rule	Zion	1957	only	-	Sep	22	0:00	0	S
 Rule	Zion	1974	only	-	Jul	 7	0:00	1:00	D
 Rule	Zion	1974	only	-	Oct	13	0:00	0	S
 Rule	Zion	1975	only	-	Apr	20	0:00	1:00	D
 Rule	Zion	1975	only	-	Aug	31	0:00	0	S
 Rule	Zion	1985	only	-	Apr	14	0:00	1:00	D
 Rule	Zion	1985	only	-	Sep	15	0:00	0	S
 Rule	Zion	1986	only	-	May	18	0:00	1:00	D
 Rule	Zion	1986	only	-	Sep	 7	0:00	0	S
 Rule	Zion	1987	only	-	Apr	15	0:00	1:00	D
 Rule	Zion	1987	only	-	Sep	13	0:00	0	S
 Rule	Zion	1988	only	-	Apr	 9	0:00	1:00	D
 Rule	Zion	1988	only	-	Sep	 3	0:00	0	S
 
 # From Ephraim Silverberg
 # (1997-03-04, 1998-03-16, 1998-12-28, 2000-01-17, 2000-07-25, 2004-12-22,
 # and 2005-02-17):
 
 # According to the Office of the Secretary General of the Ministry of
 # Interior, there is NO set rule for Daylight-Savings/Standard time changes.
 # One thing is entrenched in law, however: that there must be at least 150
 # days of daylight savings time annually.  From 1993-1998, the change to
 # daylight savings time was on a Friday morning from midnight IST to
 # 1 a.m IDT; up until 1998, the change back to standard time was on a
 # Saturday night from midnight daylight savings time to 11 p.m. standard
 # time.  1996 is an exception to this rule where the change back to standard
 # time took place on Sunday night instead of Saturday night to avoid
 # conflicts with the Jewish New Year.  In 1999, the change to
 # daylight savings time was still on a Friday morning but from
 # 2 a.m. IST to 3 a.m. IDT; furthermore, the change back to standard time
 # was also on a Friday morning from 2 a.m. IDT to 1 a.m. IST for
 # 1999 only.  In the year 2000, the change to daylight savings time was
 # similar to 1999, but although the change back will be on a Friday, it
 # will take place from 1 a.m. IDT to midnight IST.  Starting in 2001, all
 # changes to/from will take place at 1 a.m. old time, but now there is no
 # rule as to what day of the week it will take place in as the start date
 # (except in 2003) is the night after the Passover Seder (i.e. the eve
 # of the 16th of Nisan in the lunar Hebrew calendar) and the end date
 # (except in 2002) is three nights before Yom Kippur [Day of Atonement]
 # (the eve of the 7th of Tishrei in the lunar Hebrew calendar).
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	1989	only	-	Apr	30	0:00	1:00	D
 Rule	Zion	1989	only	-	Sep	 3	0:00	0	S
 Rule	Zion	1990	only	-	Mar	25	0:00	1:00	D
 Rule	Zion	1990	only	-	Aug	26	0:00	0	S
 Rule	Zion	1991	only	-	Mar	24	0:00	1:00	D
 Rule	Zion	1991	only	-	Sep	 1	0:00	0	S
 Rule	Zion	1992	only	-	Mar	29	0:00	1:00	D
 Rule	Zion	1992	only	-	Sep	 6	0:00	0	S
 Rule	Zion	1993	only	-	Apr	 2	0:00	1:00	D
 Rule	Zion	1993	only	-	Sep	 5	0:00	0	S
 
 # The dates for 1994-1995 were obtained from Office of the Spokeswoman for the
 # Ministry of Interior, Jerusalem, Israel.  The spokeswoman can be reached by
 # calling the office directly at 972-2-6701447 or 972-2-6701448.
 
 # Rule	NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
 Rule	Zion	1994	only	-	Apr	 1	0:00	1:00	D
 Rule	Zion	1994	only	-	Aug	28	0:00	0	S
 Rule	Zion	1995	only	-	Mar	31	0:00	1:00	D
 Rule	Zion	1995	only	-	Sep	 3	0:00	0	S
 
 # The dates for 1996 were determined by the Minister of Interior of the
 # time, Haim Ramon.  The official announcement regarding 1996-1998
 # (with the dates for 1997-1998 no longer being relevant) can be viewed at:
 #
 #   ftp://ftp.cs.huji.ac.il/pub/tz/announcements/1996-1998.ramon.ps.gz
 #
 # The dates for 1997-1998 were altered by his successor, Rabbi Eli Suissa.
 #
 # The official announcements for the years 1997-1999 can be viewed at:
 #
 #   ftp://ftp.cs.huji.ac.il/pub/tz/announcements/YYYY.ps.gz
 #
 #       where YYYY is the relevant year.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	1996	only	-	Mar	15	0:00	1:00	D
 Rule	Zion	1996	only	-	Sep	16	0:00	0	S
 Rule	Zion	1997	only	-	Mar	21	0:00	1:00	D
 Rule	Zion	1997	only	-	Sep	14	0:00	0	S
 Rule	Zion	1998	only	-	Mar	20	0:00	1:00	D
 Rule	Zion	1998	only	-	Sep	 6	0:00	0	S
 Rule	Zion	1999	only	-	Apr	 2	2:00	1:00	D
 Rule	Zion	1999	only	-	Sep	 3	2:00	0	S
 
 # The Knesset Interior Committee has changed the dates for 2000 for
 # the third time in just over a year and have set new dates for the
 # years 2001-2004 as well.
 #
 # The official announcement for the start date of 2000 can be viewed at:
 #
 #	ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-start.ps.gz
 #
 # The official announcement for the end date of 2000 and the dates
 # for the years 2001-2004 can be viewed at:
 #
 #	ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2000-2004.ps.gz
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	2000	only	-	Apr	14	2:00	1:00	D
 Rule	Zion	2000	only	-	Oct	 6	1:00	0	S
 Rule	Zion	2001	only	-	Apr	 9	1:00	1:00	D
 Rule	Zion	2001	only	-	Sep	24	1:00	0	S
 Rule	Zion	2002	only	-	Mar	29	1:00	1:00	D
 Rule	Zion	2002	only	-	Oct	 7	1:00	0	S
 Rule	Zion	2003	only	-	Mar	28	1:00	1:00	D
 Rule	Zion	2003	only	-	Oct	 3	1:00	0	S
 Rule	Zion	2004	only	-	Apr	 7	1:00	1:00	D
 Rule	Zion	2004	only	-	Sep	22	1:00	0	S
 
 # The proposed law agreed upon by the Knesset Interior Committee on
 # 2005-02-14 is that, for 2005 and beyond, DST starts at 02:00 the
 # last Friday before April 2nd (i.e. the last Friday in March or April
 # 1st itself if it falls on a Friday) and ends at 02:00 on the Saturday
 # night _before_ the fast of Yom Kippur.
 #
 # Those who can read Hebrew can view the announcement at:
 #
 #	ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps
 
 # From Paul Eggert (2012-10-26):
 # I used Ephraim Silverberg's dst-israel.el program
 #  (2005-02-20)
 # along with Ed Reingold's cal-hebrew in GNU Emacs 21.4,
 # to generate the transitions from 2005 through 2012.
 # (I replaced "lastFri" with "Fri>=26" by hand.)
 # The spring transitions all correspond to the following Rule:
 #
 # Rule	Zion	2005	2012	-	Mar	Fri>=26	2:00	1:00	D
 #
 # but older zic implementations (e.g., Solaris 8) do not support
 # "Fri>=26" to mean April 1 in years like 2005, so for now we list the
 # springtime transitions explicitly.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	2005	only	-	Apr	 1	2:00	1:00	D
 Rule	Zion	2005	only	-	Oct	 9	2:00	0	S
 Rule	Zion	2006	2010	-	Mar	Fri>=26	2:00	1:00	D
 Rule	Zion	2006	only	-	Oct	 1	2:00	0	S
 Rule	Zion	2007	only	-	Sep	16	2:00	0	S
 Rule	Zion	2008	only	-	Oct	 5	2:00	0	S
 Rule	Zion	2009	only	-	Sep	27	2:00	0	S
 Rule	Zion	2010	only	-	Sep	12	2:00	0	S
 Rule	Zion	2011	only	-	Apr	 1	2:00	1:00	D
 Rule	Zion	2011	only	-	Oct	 2	2:00	0	S
 Rule	Zion	2012	only	-	Mar	Fri>=26	2:00	1:00	D
 Rule	Zion	2012	only	-	Sep	23	2:00	0	S
 
 # From Ephraim Silverberg (2012-10-18):
 # Yesterday, the Interior Ministry Committee, after more than a year
 # past, approved sending the proposed June 2011 changes to the Time
 # Decree Law back to the Knesset for second and third (final) votes
 # before the upcoming elections on Jan. 22, 2013.  Hence, although the
 # changes are not yet law, they are expected to be so before February 2013.
 #
 # As of 2013, DST starts at 02:00 on the Friday before the last Sunday in March.
 # DST ends at 02:00 on the first Sunday after October 1, unless it occurs on the
 # second day of the Jewish Rosh Hashana holiday, in which case DST ends a day
 # later (i.e. at 02:00 the first Monday after October 2).
 # [Rosh Hashana holidays are factored in until 2100.]
 
 # From Ephraim Silverberg (2012-11-05):
 # The Knesset passed today (in second and final readings) the amendment to the
 # Time Decree Law making the changes ... law.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Zion	2013	max	-	Mar	Fri>=23	2:00	1:00	D
 Rule	Zion	2013	2026	-	Oct	Sun>=2	2:00	0	S
 Rule	Zion	2027	only	-	Oct	Mon>=3	2:00	0	S
 Rule	Zion	2028	max	-	Oct	Sun>=2	2:00	0	S
 # The following rules are commented out for now, as they break older
 # versions of zic that support only signed 32-bit timestamps, i.e.,
 # through 2038-01-19 03:14:07 UTC.
 #Rule	Zion	2028	2053	-	Oct	Sun>=2	2:00	0	S
 #Rule	Zion	2054	only	-	Oct	Mon>=3	2:00	0	S
 #Rule	Zion	2055	2080	-	Oct	Sun>=2	2:00	0	S
 #Rule	Zion	2081	only	-	Oct	Mon>=3	2:00	0	S
 #Rule	Zion	2082	max	-	Oct	Sun>=2	2:00	0	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Jerusalem	2:20:56 -	LMT	1880
 			2:20:40	-	JMT	1918	# Jerusalem Mean Time?
 			2:00	Zion	I%sT
 
 
 
 ###############################################################################
 
 # Japan
 
 # `9:00' and `JST' is from Guy Harris.
 
 # From Paul Eggert (1995-03-06):
 # Today's _Asahi Evening News_ (page 4) reports that Japan had
 # daylight saving between 1948 and 1951, but ``the system was discontinued
 # because the public believed it would lead to longer working hours.''
 
 # From Mayumi Negishi in the 2005-08-10 Japan Times
 # :
 # Occupation authorities imposed daylight-saving time on Japan on
 # [1948-05-01]....  But lack of prior debate and the execution of
 # daylight-saving time just three days after the bill was passed generated
 # deep hatred of the concept....  The Diet unceremoniously passed a bill to
 # dump the unpopular system in October 1951, less than a month after the San
 # Francisco Peace Treaty was signed.  (A government poll in 1951 showed 53%
 # of the Japanese wanted to scrap daylight-saving time, as opposed to 30% who
 # wanted to keep it.)
 
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger write that DST in Japan during those years was as follows:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Japan	1948	only	-	May	Sun>=1	2:00	1:00	D
 Rule	Japan	1948	1951	-	Sep	Sat>=8	2:00	0	S
 Rule	Japan	1949	only	-	Apr	Sun>=1	2:00	1:00	D
 Rule	Japan	1950	1951	-	May	Sun>=1	2:00	1:00	D
 # but the only locations using it (for birth certificates, presumably, since
 # their audience is astrologers) were US military bases.  For now, assume
 # that for most purposes daylight-saving time was observed; otherwise, what
 # would have been the point of the 1951 poll?
 
 # From Hideyuki Suzuki (1998-11-09):
 # 'Tokyo' usually stands for the former location of Tokyo Astronomical
 # Observatory: E 139 44' 40".90 (9h 18m 58s.727), N 35 39' 16".0.
 # This data is from 'Rika Nenpyou (Chronological Scientific Tables) 1996'
 # edited by National Astronomical Observatory of Japan....
 # JST (Japan Standard Time) has been used since 1888-01-01 00:00 (JST).
 # The law is enacted on 1886-07-07.
 
 # From Hideyuki Suzuki (1998-11-16):
 # The ordinance No. 51 (1886) established "standard time" in Japan,
 # which stands for the time on E 135 degree.
 # In the ordinance No. 167 (1895), "standard time" was renamed to "central
 # standard time".  And the same ordinance also established "western standard
 # time", which stands for the time on E 120 degree....  But "western standard
 # time" was abolished in the ordinance No. 529 (1937).  In the ordinance No.
 # 167, there is no mention regarding for what place western standard time is
 # standard....
 #
 # I wrote "ordinance" above, but I don't know how to translate.
 # In Japanese it's "chokurei", which means ordinance from emperor.
 
 # Shanks & Pottenger claim JST in use since 1896, and that a few
 # places (e.g. Ishigaki) use +0800; go with Suzuki.  Guess that all
 # ordinances took effect on Jan 1.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tokyo	9:18:59	-	LMT	1887 Dec 31 15:00u
 			9:00	-	JST	1896
 			9:00	-	CJT	1938
 			9:00	Japan	J%sT
 # Since 1938, all Japanese possessions have been like Asia/Tokyo.
 
 # Jordan
 #
 # From 
 # Jordan Week (1999-07-01)  via Steffen Thorsen (1999-09-09):
 # Clocks in Jordan were forwarded one hour on Wednesday at midnight,
 # in accordance with the government's decision to implement summer time
 # all year round.
 #
 # From 
 # Jordan Week (1999-09-30)  via Steffen Thorsen (1999-11-09):
 # Winter time starts today Thursday, 30 September. Clocks will be turned back
 # by one hour.  This is the latest government decision and it's final!
 # The decision was taken because of the increase in working hours in
 # government's departments from six to seven hours.
 #
 # From Paul Eggert (2005-11-22):
 # Starting 2003 transitions are from Steffen Thorsen's web site timeanddate.com.
 #
 # From Steffen Thorsen (2005-11-23):
 # For Jordan I have received multiple independent user reports every year
 # about DST end dates, as the end-rule is different every year.
 #
 # From Steffen Thorsen (2006-10-01), after a heads-up from Hilal Malawi:
 # http://www.petranews.gov.jo/nepras/2006/Sep/05/4000.htm
 # "Jordan will switch to winter time on Friday, October 27".
 #
 
 # From Phil Pizzey (2009-04-02):
 # ...I think I may have spotted an error in the timezone data for
 # Jordan.
 # The current (2009d) asia file shows Jordan going to daylight
 # saving
 # time on the last Thursday in March.
 #
 # Rule  Jordan      2000  max	-  Mar   lastThu     0:00s 1:00  S
 #
 # However timeanddate.com, which I usually find reliable, shows Jordan
 # going to daylight saving time on the last Friday in March since 2002.
 # Please see
 # 
 # http://www.timeanddate.com/worldclock/timezone.html?n=11
 # 
 
 # From Steffen Thorsen (2009-04-02):
 # This single one might be good enough, (2009-03-24, Arabic):
 # 
 # http://petra.gov.jo/Artical.aspx?Lng=2&Section=8&Artical=95279
 # 
 #
 # Google's translation:
 #
 # > The Council of Ministers decided in 2002 to adopt the principle of timely
 # > submission of the summer at 60 minutes as of midnight on the last Thursday
 # > of the month of March of each year.
 #
 # So - this means the midnight between Thursday and Friday since 2002.
 
 # From Arthur David Olson (2009-04-06):
 # We still have Jordan switching to DST on Thursdays in 2000 and 2001.
 
 # From Steffen Thorsen (2012-10-25):
 # Yesterday the government in Jordan announced that they will not
 # switch back to standard time this winter, so the will stay on DST
 # until about the same time next year (at least).
 # http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?NewsID=88950
 #
 # From Paul Eggert (2012-10-25):
 # For now, assume this is just a one-year measure.  If it becomes
 # permanent, we should move Jordan from EET to AST effective tomorrow.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Jordan	1973	only	-	Jun	6	0:00	1:00	S
 Rule	Jordan	1973	1975	-	Oct	1	0:00	0	-
 Rule	Jordan	1974	1977	-	May	1	0:00	1:00	S
 Rule	Jordan	1976	only	-	Nov	1	0:00	0	-
 Rule	Jordan	1977	only	-	Oct	1	0:00	0	-
 Rule	Jordan	1978	only	-	Apr	30	0:00	1:00	S
 Rule	Jordan	1978	only	-	Sep	30	0:00	0	-
 Rule	Jordan	1985	only	-	Apr	1	0:00	1:00	S
 Rule	Jordan	1985	only	-	Oct	1	0:00	0	-
 Rule	Jordan	1986	1988	-	Apr	Fri>=1	0:00	1:00	S
 Rule	Jordan	1986	1990	-	Oct	Fri>=1	0:00	0	-
 Rule	Jordan	1989	only	-	May	8	0:00	1:00	S
 Rule	Jordan	1990	only	-	Apr	27	0:00	1:00	S
 Rule	Jordan	1991	only	-	Apr	17	0:00	1:00	S
 Rule	Jordan	1991	only	-	Sep	27	0:00	0	-
 Rule	Jordan	1992	only	-	Apr	10	0:00	1:00	S
 Rule	Jordan	1992	1993	-	Oct	Fri>=1	0:00	0	-
 Rule	Jordan	1993	1998	-	Apr	Fri>=1	0:00	1:00	S
 Rule	Jordan	1994	only	-	Sep	Fri>=15	0:00	0	-
 Rule	Jordan	1995	1998	-	Sep	Fri>=15	0:00s	0	-
 Rule	Jordan	1999	only	-	Jul	 1	0:00s	1:00	S
 Rule	Jordan	1999	2002	-	Sep	lastFri	0:00s	0	-
 Rule	Jordan	2000	2001	-	Mar	lastThu	0:00s	1:00	S
 Rule	Jordan	2002	max	-	Mar	lastThu	24:00	1:00	S
 Rule	Jordan	2003	only	-	Oct	24	0:00s	0	-
 Rule	Jordan	2004	only	-	Oct	15	0:00s	0	-
 Rule	Jordan	2005	only	-	Sep	lastFri	0:00s	0	-
 Rule	Jordan	2006	2011	-	Oct	lastFri	0:00s	0	-
 Rule	Jordan	2013	max	-	Oct	lastFri	0:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Amman	2:23:44 -	LMT	1931
 			2:00	Jordan	EE%sT
 
 
 # Kazakhstan
 
 # From Paul Eggert (1996-11-22):
 # Andrew Evtichov (1996-04-13) writes that Kazakhstan
 # stayed in sync with Moscow after 1990, and that Aqtobe (formerly Aktyubinsk)
 # and Aqtau (formerly Shevchenko) are the largest cities in their zones.
 # Guess that Aqtau and Aqtobe diverged in 1995, since that's the first time
 # IATA SSIM mentions a third time zone in Kazakhstan.
 
 # From Paul Eggert (2006-03-22):
 # German Iofis, ELSI, Almaty (2001-10-09) reports that Kazakhstan uses
 # RussiaAsia rules, instead of switching at 00:00 as the IATA has it.
 # Go with Shanks & Pottenger, who have them always using RussiaAsia rules.
 # Also go with the following claims of Shanks & Pottenger:
 #
 # - Kazakhstan did not observe DST in 1991.
 # - Qyzylorda switched from +5:00 to +6:00 on 1992-01-19 02:00.
 # - Oral switched from +5:00 to +4:00 in spring 1989.
 
 # 
 # From Kazakhstan Embassy's News Bulletin #11 (2005-03-21):
 # 
 # The Government of Kazakhstan passed a resolution March 15 abolishing
 # daylight saving time citing lack of economic benefits and health
 # complications coupled with a decrease in productivity.
 #
 # From Branislav Kojic (in Astana) via Gwillim Law (2005-06-28):
 # ... what happened was that the former Kazakhstan Eastern time zone
 # was "blended" with the Central zone.  Therefore, Kazakhstan now has
 # two time zones, and difference between them is one hour.  The zone
 # closer to UTC is the former Western zone (probably still called the
 # same), encompassing four provinces in the west: Aqtobe, Atyrau,
 # Mangghystau, and West Kazakhstan.  The other zone encompasses
 # everything else....  I guess that would make Kazakhstan time zones
 # de jure UTC+5 and UTC+6 respectively.
 
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Almaty (formerly Alma-Ata), representing most locations in Kazakhstan
 Zone	Asia/Almaty	5:07:48 -	LMT	1924 May  2 # or Alma-Ata
 			5:00	-	ALMT	1930 Jun 21 # Alma-Ata Time
 			6:00 RussiaAsia ALM%sT	1991
 			6:00	-	ALMT	1992
 			6:00 RussiaAsia	ALM%sT	2005 Mar 15
 			6:00	-	ALMT
 # Qyzylorda (aka Kyzylorda, Kizilorda, Kzyl-Orda, etc.)
 Zone	Asia/Qyzylorda	4:21:52 -	LMT	1924 May  2
 			4:00	-	KIZT	1930 Jun 21 # Kizilorda Time
 			5:00	-	KIZT	1981 Apr  1
 			5:00	1:00	KIZST	1981 Oct  1
 			6:00	-	KIZT	1982 Apr  1
 			5:00 RussiaAsia	KIZ%sT	1991
 			5:00	-	KIZT	1991 Dec 16 # independence
 			5:00	-	QYZT	1992 Jan 19 2:00
 			6:00 RussiaAsia	QYZ%sT	2005 Mar 15
 			6:00	-	QYZT
 # Aqtobe (aka Aktobe, formerly Akt'ubinsk)
 Zone	Asia/Aqtobe	3:48:40	-	LMT	1924 May  2
 			4:00	-	AKTT	1930 Jun 21 # Aktyubinsk Time
 			5:00	-	AKTT	1981 Apr  1
 			5:00	1:00	AKTST	1981 Oct  1
 			6:00	-	AKTT	1982 Apr  1
 			5:00 RussiaAsia	AKT%sT	1991
 			5:00	-	AKTT	1991 Dec 16 # independence
 			5:00 RussiaAsia	AQT%sT	2005 Mar 15 # Aqtobe Time
 			5:00	-	AQTT
 # Mangghystau
 # Aqtau was not founded until 1963, but it represents an inhabited region,
 # so include time stamps before 1963.
 Zone	Asia/Aqtau	3:21:04	-	LMT	1924 May  2
 			4:00	-	FORT	1930 Jun 21 # Fort Shevchenko T
 			5:00	-	FORT	1963
 			5:00	-	SHET	1981 Oct  1 # Shevchenko Time
 			6:00	-	SHET	1982 Apr  1
 			5:00 RussiaAsia	SHE%sT	1991
 			5:00	-	SHET	1991 Dec 16 # independence
 			5:00 RussiaAsia	AQT%sT	1995 Mar lastSun 2:00 # Aqtau Time
 			4:00 RussiaAsia	AQT%sT	2005 Mar 15
 			5:00	-	AQTT
 # West Kazakhstan
 Zone	Asia/Oral	3:25:24	-	LMT	1924 May  2 # or Ural'sk
 			4:00	-	URAT	1930 Jun 21 # Ural'sk time
 			5:00	-	URAT	1981 Apr  1
 			5:00	1:00	URAST	1981 Oct  1
 			6:00	-	URAT	1982 Apr  1
 			5:00 RussiaAsia	URA%sT	1989 Mar 26 2:00
 			4:00 RussiaAsia	URA%sT	1991
 			4:00	-	URAT	1991 Dec 16 # independence
 			4:00 RussiaAsia	ORA%sT	2005 Mar 15 # Oral Time
 			5:00	-	ORAT
 
 # Kyrgyzstan (Kirgizstan)
 # Transitions through 1991 are from Shanks & Pottenger.
 
 # From Paul Eggert (2005-08-15):
 # According to an article dated today in the Kyrgyzstan Development Gateway
 # 
 # Kyrgyzstan is canceling the daylight saving time system.  I take the article
 # to mean that they will leave their clocks at 6 hours ahead of UTC.
 # From Malik Abdugaliev (2005-09-21):
 # Our government cancels daylight saving time 6th of August 2005.
 # From 2005-08-12 our GMT-offset is +6, w/o any daylight saving.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Kyrgyz	1992	1996	-	Apr	Sun>=7	0:00s	1:00	S
 Rule	Kyrgyz	1992	1996	-	Sep	lastSun	0:00	0	-
 Rule	Kyrgyz	1997	2005	-	Mar	lastSun	2:30	1:00	S
 Rule	Kyrgyz	1997	2004	-	Oct	lastSun	2:30	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bishkek	4:58:24 -	LMT	1924 May  2
 			5:00	-	FRUT	1930 Jun 21 # Frunze Time
 			6:00 RussiaAsia FRU%sT	1991 Mar 31 2:00s
 			5:00	1:00	FRUST	1991 Aug 31 2:00 # independence
 			5:00	Kyrgyz	KG%sT	2005 Aug 12    # Kyrgyzstan Time
 			6:00	-	KGT
 
 ###############################################################################
 
 # Korea (North and South)
 
 # From Annie I. Bang (2006-07-10) in
 # :
 # The Ministry of Commerce, Industry and Energy has already
 # commissioned a research project [to reintroduce DST] and has said
 # the system may begin as early as 2008....  Korea ran a daylight
 # saving program from 1949-61 but stopped it during the 1950-53 Korean War.
 
 # From Shanks & Pottenger:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	ROK	1960	only	-	May	15	0:00	1:00	D
 Rule	ROK	1960	only	-	Sep	13	0:00	0	S
 Rule	ROK	1987	1988	-	May	Sun>=8	0:00	1:00	D
 Rule	ROK	1987	1988	-	Oct	Sun>=8	0:00	0	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Seoul	8:27:52	-	LMT	1890
 			8:30	-	KST	1904 Dec
 			9:00	-	KST	1928
 			8:30	-	KST	1932
 			9:00	-	KST	1954 Mar 21
 			8:00	ROK	K%sT	1961 Aug 10
 			8:30	-	KST	1968 Oct
 			9:00	ROK	K%sT
 Zone	Asia/Pyongyang	8:23:00 -	LMT	1890
 			8:30	-	KST	1904 Dec
 			9:00	-	KST	1928
 			8:30	-	KST	1932
 			9:00	-	KST	1954 Mar 21
 			8:00	-	KST	1961 Aug 10
 			9:00	-	KST
 
 ###############################################################################
 
 # Kuwait
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # From the Arab Times (2007-03-14):
 # The Civil Service Commission (CSC) has approved a proposal forwarded
 # by MP Ahmad Baqer on implementing the daylight saving time (DST) in
 # Kuwait starting from April until the end of Sept this year, reports Al-Anba.
 # .
 # From Paul Eggert (2007-03-29):
 # We don't know the details, or whether the approval means it'll happen,
 # so for now we assume no DST.
 Zone	Asia/Kuwait	3:11:56 -	LMT	1950
 			3:00	-	AST
 
 # Laos
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Vientiane	6:50:24 -	LMT	1906 Jun  9 # or Viangchan
 			7:06:20	-	SMT	1911 Mar 11 0:01 # Saigon MT?
 			7:00	-	ICT	1912 May
 			8:00	-	ICT	1931 May
 			7:00	-	ICT
 
 # Lebanon
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Lebanon	1920	only	-	Mar	28	0:00	1:00	S
 Rule	Lebanon	1920	only	-	Oct	25	0:00	0	-
 Rule	Lebanon	1921	only	-	Apr	3	0:00	1:00	S
 Rule	Lebanon	1921	only	-	Oct	3	0:00	0	-
 Rule	Lebanon	1922	only	-	Mar	26	0:00	1:00	S
 Rule	Lebanon	1922	only	-	Oct	8	0:00	0	-
 Rule	Lebanon	1923	only	-	Apr	22	0:00	1:00	S
 Rule	Lebanon	1923	only	-	Sep	16	0:00	0	-
 Rule	Lebanon	1957	1961	-	May	1	0:00	1:00	S
 Rule	Lebanon	1957	1961	-	Oct	1	0:00	0	-
 Rule	Lebanon	1972	only	-	Jun	22	0:00	1:00	S
 Rule	Lebanon	1972	1977	-	Oct	1	0:00	0	-
 Rule	Lebanon	1973	1977	-	May	1	0:00	1:00	S
 Rule	Lebanon	1978	only	-	Apr	30	0:00	1:00	S
 Rule	Lebanon	1978	only	-	Sep	30	0:00	0	-
 Rule	Lebanon	1984	1987	-	May	1	0:00	1:00	S
 Rule	Lebanon	1984	1991	-	Oct	16	0:00	0	-
 Rule	Lebanon	1988	only	-	Jun	1	0:00	1:00	S
 Rule	Lebanon	1989	only	-	May	10	0:00	1:00	S
 Rule	Lebanon	1990	1992	-	May	1	0:00	1:00	S
 Rule	Lebanon	1992	only	-	Oct	4	0:00	0	-
 Rule	Lebanon	1993	max	-	Mar	lastSun	0:00	1:00	S
 Rule	Lebanon	1993	1998	-	Sep	lastSun	0:00	0	-
 Rule	Lebanon	1999	max	-	Oct	lastSun	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Beirut	2:22:00 -	LMT	1880
 			2:00	Lebanon	EE%sT
 
 # Malaysia
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NBorneo	1935	1941	-	Sep	14	0:00	0:20	TS # one-Third Summer
 Rule	NBorneo	1935	1941	-	Dec	14	0:00	0	-
 #
 # peninsular Malaysia
 # The data here are taken from Mok Ly Yng (2003-10-30)
 # .
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Kuala_Lumpur	6:46:46 -	LMT	1901 Jan  1
 			6:55:25	-	SMT	1905 Jun  1 # Singapore M.T.
 			7:00	-	MALT	1933 Jan  1 # Malaya Time
 			7:00	0:20	MALST	1936 Jan  1
 			7:20	-	MALT	1941 Sep  1
 			7:30	-	MALT	1942 Feb 16
 			9:00	-	JST	1945 Sep 12
 			7:30	-	MALT	1982 Jan  1
 			8:00	-	MYT	# Malaysia Time
 # Sabah & Sarawak
 # From Paul Eggert (2006-03-22):
 # The data here are mostly from Shanks & Pottenger, but the 1942, 1945 and 1982
 # transition dates are from Mok Ly Yng.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Asia/Kuching	7:21:20	-	LMT	1926 Mar
 			7:30	-	BORT	1933	# Borneo Time
 			8:00	NBorneo	BOR%sT	1942 Feb 16
 			9:00	-	JST	1945 Sep 12
 			8:00	-	BORT	1982 Jan  1
 			8:00	-	MYT
 
 # Maldives
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Maldives	4:54:00 -	LMT	1880	# Male
 			4:54:00	-	MMT	1960	# Male Mean Time
 			5:00	-	MVT		# Maldives Time
 
 # Mongolia
 
 # Shanks & Pottenger say that Mongolia has three time zones, but
 # usno1995 and the CIA map Standard Time Zones of the World (2005-03)
 # both say that it has just one.
 
 # From Oscar van Vlijmen (1999-12-11):
 # 
 # General Information Mongolia
 #  (1999-09)
 # "Time: Mongolia has two time zones. Three westernmost provinces of
 # Bayan-Ulgii, Uvs, and Hovd are one hour earlier than the capital city, and
 # the rest of the country follows the Ulaanbaatar time, which is UTC/GMT plus
 # eight hours."
 
 # From Rives McDow (1999-12-13):
 # Mongolia discontinued the use of daylight savings time in 1999; 1998
 # being the last year it was implemented.  The dates of implementation I am
 # unsure of, but most probably it was similar to Russia, except for the time
 # of implementation may have been different....
 # Some maps in the past have indicated that there was an additional time
 # zone in the eastern part of Mongolia, including the provinces of Dornod,
 # Suhbaatar, and possibly Khentij.
 
 # From Paul Eggert (1999-12-15):
 # Naming and spelling is tricky in Mongolia.
 # We'll use Hovd (also spelled Chovd and Khovd) to represent the west zone;
 # the capital of the Hovd province is sometimes called Hovd, sometimes Dund-Us,
 # and sometimes Jirgalanta (with variant spellings), but the name Hovd
 # is good enough for our purposes.
 
 # From Rives McDow (2001-05-13):
 # In addition to Mongolia starting daylight savings as reported earlier
 # (adopted DST on 2001-04-27 02:00 local time, ending 2001-09-28),
 # there are three time zones.
 #
 # Provinces [at 7:00]: Bayan-ulgii, Uvs, Khovd, Zavkhan, Govi-Altai
 # Provinces [at 8:00]: Khovsgol, Bulgan, Arkhangai, Khentii, Tov,
 #	Bayankhongor, Ovorkhangai, Dundgovi, Dornogovi, Omnogovi
 # Provinces [at 9:00]: Dornod, Sukhbaatar
 #
 # [The province of Selenge is omitted from the above lists.]
 
 # From Ganbold Ts., Ulaanbaatar (2004-04-17):
 # Daylight saving occurs at 02:00 local time last Saturday of March.
 # It will change back to normal at 02:00 local time last Saturday of
 # September.... As I remember this rule was changed in 2001.
 #
 # From Paul Eggert (2004-04-17):
 # For now, assume Rives McDow's informant got confused about Friday vs
 # Saturday, and that his 2001 dates should have 1 added to them.
 
 # From Paul Eggert (2005-07-26):
 # We have wildly conflicting information about Mongolia's time zones.
 # Bill Bonnet (2005-05-19) reports that the US Embassy in Ulaanbaatar says
 # there is only one time zone and that DST is observed, citing Microsoft
 # Windows XP as the source.  Risto Nykanen (2005-05-16) reports that
 # travelmongolia.org says there are two time zones (UTC+7, UTC+8) with no DST.
 # Oscar van Vlijmen (2005-05-20) reports that the Mongolian Embassy in
 # Washington, DC says there are two time zones, with DST observed.
 # He also found
 # 
 # which also says that there is DST, and which has a comment by "Toddius"
 # (2005-03-31 06:05 +0700) saying "Mongolia actually has 3.5 time zones.
 # The West (OLGII) is +7 GMT, most of the country is ULAT is +8 GMT
 # and some Eastern provinces are +9 GMT but Sukhbaatar Aimag is SUHK +8.5 GMT.
 # The SUKH timezone is new this year, it is one of the few things the
 # parliament passed during the tumultuous winter session."
 # For now, let's ignore this information, until we have more confirmation.
 
 # From Ganbold Ts. (2007-02-26):
 # Parliament of Mongolia has just changed the daylight-saving rule in February.
 # They decided not to adopt daylight-saving time....
 # http://www.mongolnews.mn/index.php?module=unuudur&sec=view&id=15742
 
 # From Deborah Goldsmith (2008-03-30):
 # We received a bug report claiming that the tz database UTC offset for
 # Asia/Choibalsan (GMT+09:00) is incorrect, and that it should be GMT
 # +08:00 instead. Different sources appear to disagree with the tz
 # database on this, e.g.:
 #
 # 
 # http://www.timeanddate.com/worldclock/city.html?n=1026
 # 
 # 
 # http://www.worldtimeserver.com/current_time_in_MN.aspx
 # 
 #
 # both say GMT+08:00.
 
 # From Steffen Thorsen (2008-03-31):
 # eznis airways, which operates several domestic flights, has a flight
 # schedule here:
 # 
 # http://www.eznis.com/Container.jsp?id=112
 # 
 # (click the English flag for English)
 #
 # There it appears that flights between Choibalsan and Ulaanbatar arrive
 # about 1:35 - 1:50 hours later in local clock time, no matter the
 # direction, while Ulaanbaatar-Khvod takes 2 hours in the Eastern
 # direction and 3:35 back, which indicates that Ulaanbatar and Khvod are
 # in different time zones (like we know about), while Choibalsan and
 # Ulaanbatar are in the same time zone (correction needed).
 
 # From Arthur David Olson (2008-05-19):
 # Assume that Choibalsan is indeed offset by 8:00.
 # XXX--in the absence of better information, assume that transition
 # was at the start of 2008-03-31 (the day of Steffen Thorsen's report);
 # this is almost surely wrong.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Mongol	1983	1984	-	Apr	1	0:00	1:00	S
 Rule	Mongol	1983	only	-	Oct	1	0:00	0	-
 # Shanks & Pottenger and IATA SSIM say 1990s switches occurred at 00:00,
 # but McDow says the 2001 switches occurred at 02:00.  Also, IATA SSIM
 # (1996-09) says 1996-10-25.  Go with Shanks & Pottenger through 1998.
 #
 # Shanks & Pottenger say that the Sept. 1984 through Sept. 1990 switches
 # in Choibalsan (more precisely, in Dornod and Sukhbaatar) took place
 # at 02:00 standard time, not at 00:00 local time as in the rest of
 # the country.  That would be odd, and possibly is a result of their
 # correction of 02:00 (in the previous edition) not being done correctly
 # in the latest edition; so ignore it for now.
 
 Rule	Mongol	1985	1998	-	Mar	lastSun	0:00	1:00	S
 Rule	Mongol	1984	1998	-	Sep	lastSun	0:00	0	-
 # IATA SSIM (1999-09) says Mongolia no longer observes DST.
 Rule	Mongol	2001	only	-	Apr	lastSat	2:00	1:00	S
 Rule	Mongol	2001	2006	-	Sep	lastSat	2:00	0	-
 Rule	Mongol	2002	2006	-	Mar	lastSat	2:00	1:00	S
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta
 Zone	Asia/Hovd	6:06:36 -	LMT	1905 Aug
 			6:00	-	HOVT	1978	# Hovd Time
 			7:00	Mongol	HOV%sT
 # Ulaanbaatar, a.k.a. Ulan Bataar, Ulan Bator, Urga
 Zone	Asia/Ulaanbaatar 7:07:32 -	LMT	1905 Aug
 			7:00	-	ULAT	1978	# Ulaanbaatar Time
 			8:00	Mongol	ULA%sT
 # Choibalsan, a.k.a. Bajan Tuemen, Bajan Tumen, Chojbalsan,
 # Choybalsan, Sanbejse, Tchoibalsan
 Zone	Asia/Choibalsan	7:38:00 -	LMT	1905 Aug
 			7:00	-	ULAT	1978
 			8:00	-	ULAT	1983 Apr
 			9:00	Mongol	CHO%sT	2008 Mar 31 # Choibalsan Time
 			8:00	Mongol	CHO%sT
 
 # Nepal
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Kathmandu	5:41:16 -	LMT	1920
 			5:30	-	IST	1986
 			5:45	-	NPT	# Nepal Time
 
 # Oman
 
 # Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Muscat	3:54:24 -	LMT	1920
 			4:00	-	GST
 
 # Pakistan
 
 # From Rives McDow (2002-03-13):
 # I have been advised that Pakistan has decided to adopt dst on a
 # TRIAL basis for one year, starting 00:01 local time on April 7, 2002
 # and ending at 00:01 local time October 6, 2002.  This is what I was
 # told, but I believe that the actual time of change may be 00:00; the
 # 00:01 was to make it clear which day it was on.
 
 # From Paul Eggert (2002-03-15):
 # Jesper Norgaard found this URL:
 # http://www.pak.gov.pk/public/news/app/app06_dec.htm
 # (dated 2001-12-06) which says that the Cabinet adopted a scheme "to
 # advance the clocks by one hour on the night between the first
 # Saturday and Sunday of April and revert to the original position on
 # 15th October each year".  This agrees with McDow's 04-07 at 00:00,
 # but disagrees about the October transition, and makes it sound like
 # it's not on a trial basis.  Also, the "between the first Saturday
 # and Sunday of April" phrase, if taken literally, means that the
 # transition takes place at 00:00 on the first Sunday on or after 04-02.
 
 # From Paul Eggert (2003-02-09):
 # DAWN  reported on 2002-10-05
 # that 2002 DST ended that day at midnight.  Go with McDow for now.
 
 # From Steffen Thorsen (2003-03-14):
 # According to http://www.dawn.com/2003/03/07/top15.htm
 # there will be no DST in Pakistan this year:
 #
 # ISLAMABAD, March 6: Information and Media Development Minister Sheikh
 # Rashid Ahmed on Thursday said the cabinet had reversed a previous
 # decision to advance clocks by one hour in summer and put them back by
 # one hour in winter with the aim of saving light hours and energy.
 #
 # The minister told a news conference that the experiment had rather
 # shown 8 per cent higher consumption of electricity.
 
 # From Alex Krivenyshev (2008-05-15):
 #
 # Here is an article that Pakistan plan to introduce Daylight Saving Time
 # on June 1, 2008 for 3 months.
 #
 # "... The federal cabinet on Wednesday announced a new conservation plan to help
 # reduce load shedding by approving the closure of commercial centres at 9pm and
 # moving clocks forward by one hour for the next three months.
 # ...."
 #
 # 
 # http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html
 # 
 # OR
 # 
 # http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4
 # 
 
 # From Arthur David Olson (2008-05-19):
 # XXX--midnight transitions is a guess; 2008 only is a guess.
 
 # From Alexander Krivenyshev (2008-08-28):
 # Pakistan government has decided to keep the watches one-hour advanced
 # for another 2 months--plan to return to Standard Time on October 31
 # instead of August 31.
 #
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_pakistan02.html
 # 
 # OR
 # 
 # http://dailymailnews.com/200808/28/news/dmbrn03.html
 # 
 
 # From Alexander Krivenyshev (2009-04-08):
 # Based on previous media reports that "... proposed plan to
 # advance clocks by one hour from May 1 will cause disturbance
 # to the working schedules rather than bringing discipline in
 # official working."
 # 
 # http://www.thenews.com.pk/daily_detail.asp?id=171280
 # 
 #
 # recent news that instead of May 2009 - Pakistan plan to
 # introduce DST from April 15, 2009
 #
 # FYI: Associated Press Of Pakistan
 # April 08, 2009
 # Cabinet okays proposal to advance clocks by one hour from April 15
 # 
 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=73043&Itemid=1
 # 
 #
 # or
 #
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_pakistan05.html
 # 
 #
 # ....
 # The Federal Cabinet on Wednesday approved the proposal to
 # advance clocks in the country by one hour from April 15 to
 # conserve energy"
 
 # From Steffen Thorsen (2009-09-17):
 # "The News International," Pakistan reports that: "The Federal
 # Government has decided to restore the previous time by moving the
 # clocks backward by one hour from October 1. A formal announcement to
 # this effect will be made after the Prime Minister grants approval in
 # this regard."
 # 
 # http://www.thenews.com.pk/updates.asp?id=87168
 # 
 
 # From Alexander Krivenyshev (2009-09-28):
 # According to Associated Press Of Pakistan, it is confirmed that
 # Pakistan clocks across the country would be turned back by an hour from October
 # 1, 2009.
 #
 # "Clocks to go back one hour from 1 Oct"
 # 
 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm
 # 
 
 # From Steffen Thorsen (2009-09-29):
 # Alexander Krivenyshev wrote:
 # > According to Associated Press Of Pakistan, it is confirmed that
 # > Pakistan clocks across the country would be turned back by an hour from October
 # > 1, 2009.
 #
 # Now they seem to have changed their mind, November 1 is the new date:
 # 
 # http://www.thenews.com.pk/top_story_detail.asp?Id=24742
 # 
 # "The country's clocks will be reversed by one hour on November 1.
 # Officials of Federal Ministry for Interior told this to Geo News on
 # Monday."
 #
 # And more importantly, it seems that these dates will be kept every year:
 # "It has now been decided that clocks will be wound forward by one hour
 # on April 15 and reversed by an hour on November 1 every year without
 # obtaining prior approval, the officials added."
 #
 # We have confirmed this year's end date with both with the Ministry of
 # Water and Power and the Pakistan Electric Power Company:
 # 
 # http://www.timeanddate.com/news/time/pakistan-ends-dst09.html
 # 
 
 # From Christoph Goehre (2009-10-01):
 # [T]he German Consulate General in Karachi reported me today that Pakistan
 # will go back to standard time on 1st of November.
 
 # From Steffen Thorsen (2010-03-26):
 # Steffen Thorsen wrote:
 # > On Thursday (2010-03-25) it was announced that DST would start in
 # > Pakistan on 2010-04-01.
 # >
 # > Then today, the president said that they might have to revert the
 # > decision if it is not supported by the parliament. So at the time
 # > being, it seems unclear if DST will be actually observed or not - but
 # > April 1 could be a more likely date than April 15.
 # Now, it seems that the decision to not observe DST in final:
 #
 # "Govt Withdraws Plan To Advance Clocks"
 # 
 # http://www.apakistannews.com/govt-withdraws-plan-to-advance-clocks-172041
 # 
 #
 # "People laud PM's announcement to end DST"
 # 
 # http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=99374&Itemid=2
 # 
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Pakistan	2002	only	-	Apr	Sun>=2	0:01	1:00	S
 Rule Pakistan	2002	only	-	Oct	Sun>=2	0:01	0	-
 Rule Pakistan	2008	only	-	Jun	1	0:00	1:00	S
 Rule Pakistan	2008	only	-	Nov	1	0:00	0	-
 Rule Pakistan	2009	only	-	Apr	15	0:00	1:00	S
 Rule Pakistan	2009	only	-	Nov	1	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
 			5:30	-	IST	1942 Sep
 			5:30	1:00	IST	1945 Oct 15
 			5:30	-	IST	1951 Sep 30
 			5:00	-	KART	1971 Mar 26 # Karachi Time
 			5:00 Pakistan	PK%sT	# Pakistan Time
 
 # Palestine
 
 # From Amos Shapir (1998-02-15):
 #
 # From 1917 until 1948-05-15, all of Palestine, including the parts now
 # known as the Gaza Strip and the West Bank, was under British rule.
 # Therefore the rules given for Israel for that period, apply there too...
 #
 # The Gaza Strip was under Egyptian rule between 1948-05-15 until 1967-06-05
 # (except a short occupation by Israel from 1956-11 till 1957-03, but no
 # time zone was affected then).  It was never formally annexed to Egypt,
 # though.
 #
 # The rest of Palestine was under Jordanian rule at that time, formally
 # annexed in 1950 as the West Bank (and the word "Trans" was dropped from
 # the country's previous name of "the Hashemite Kingdom of the
 # Trans-Jordan").  So the rules for Jordan for that time apply.  Major
 # towns in that area are Nablus (Shchem), El-Halil (Hebron), Ramallah, and
 # East Jerusalem.
 #
 # Both areas were occupied by Israel in June 1967, but not annexed (except
 # for East Jerusalem).  They were on Israel time since then; there might
 # have been a Military Governor's order about time zones, but I'm not aware
 # of any (such orders may have been issued semi-annually whenever summer
 # time was in effect, but maybe the legal aspect of time was just neglected).
 #
 # The Palestinian Authority was established in 1993, and got hold of most
 # towns in the West Bank and Gaza by 1995.  I know that in order to
 # demonstrate...independence, they have been switching to
 # summer time and back on a different schedule than Israel's, but I don't
 # know when this was started, or what algorithm is used (most likely the
 # Jordanian one).
 #
 # To summarize, the table should probably look something like that:
 #
 # Area \ when | 1918-1947 | 1948-1967 | 1967-1995 | 1996-
 # ------------+-----------+-----------+-----------+-----------
 # Israel      | Zion      | Zion      | Zion      | Zion
 # West bank   | Zion      | Jordan    | Zion      | Jordan
 # Gaza        | Zion      | Egypt     | Zion      | Jordan
 #
 # I guess more info may be available from the PA's web page (if/when they
 # have one).
 
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger write that Gaza did not observe DST until 1957, but go
 # with Shapir and assume that it observed DST from 1940 through 1947,
 # and that it used Jordanian rules starting in 1996.
 # We don't yet need a separate entry for the West Bank, since
 # the only differences between it and Gaza that we know about
 # occurred before our cutoff date of 1970.
 # However, as we get more information, we may need to add entries
 # for parts of the West Bank as they transitioned from Israel's rules
 # to Palestine's rules.
 
 # From IINS News Service - Israel - 1998-03-23 10:38:07 Israel time,
 # forwarded by Ephraim Silverberg:
 #
 # Despite the fact that Israel changed over to daylight savings time
 # last week, the PLO Authority (PA) has decided not to turn its clocks
 # one-hour forward at this time.  As a sign of independence from Israeli rule,
 # the PA has decided to implement DST in April.
 
 # From Paul Eggert (1999-09-20):
 # Daoud Kuttab writes in
 # 
 # Holiday havoc
 #  (Jerusalem Post, 1999-04-22) that
 # the Palestinian National Authority changed to DST on 1999-04-15.
 # I vaguely recall that they switch back in October (sorry, forgot the source).
 # For now, let's assume that the spring switch was at 24:00,
 # and that they switch at 0:00 on the 3rd Fridays of April and October.
 
 # From Paul Eggert (2005-11-22):
 # Starting 2004 transitions are from Steffen Thorsen's web site timeanddate.com.
 
 # From Steffen Thorsen (2005-11-23):
 # A user from Gaza reported that Gaza made the change early because of
 # the Ramadan.  Next year Ramadan will be even earlier, so I think
 # there is a good chance next year's end date will be around two weeks
 # earlier--the same goes for Jordan.
 
 # From Steffen Thorsen (2006-08-17):
 # I was informed by a user in Bethlehem that in Bethlehem it started the
 # same day as Israel, and after checking with other users in the area, I
 # was informed that they started DST one day after Israel.  I was not
 # able to find any authoritative sources at the time, nor details if
 # Gaza changed as well, but presumed Gaza to follow the same rules as
 # the West Bank.
 
 # From Steffen Thorsen (2006-09-26):
 # according to the Palestine News Network (2006-09-19):
 # http://english.pnn.ps/index.php?option=com_content&task=view&id=596&Itemid=5
 # > The Council of Ministers announced that this year its winter schedule
 # > will begin early, as of midnight Thursday.  It is also time to turn
 # > back the clocks for winter.  Friday will begin an hour late this week.
 # I guess it is likely that next year's date will be moved as well,
 # because of the Ramadan.
 
 # From Jesper Norgaard Welen (2007-09-18):
 # According to Steffen Thorsen's web site the Gaza Strip and the rest of the
 # Palestinian territories left DST early on 13.th. of September at 2:00.
 
 # From Paul Eggert (2007-09-20):
 # My understanding is that Gaza and the West Bank disagree even over when
 # the weekend is (Thursday+Friday versus Friday+Saturday), so I'd be a bit
 # surprised if they agreed about DST.  But for now, assume they agree.
 # For lack of better information, predict that future changes will be
 # the 2nd Thursday of September at 02:00.
 
 # From Alexander Krivenyshev (2008-08-28):
 # Here is an article, that Mideast running on different clocks at Ramadan.
 #
 # Gaza Strip (as Egypt) ended DST at midnight Thursday (Aug 28, 2008), while
 # the West Bank will end Daylight Saving Time at midnight Sunday (Aug 31, 2008).
 #
 # 
 # http://www.guardian.co.uk/world/feedarticle/7759001
 # 
 # 
 # http://www.abcnews.go.com/International/wireStory?id=5676087
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_gazastrip01.html
 # 
 
 # From Alexander Krivenyshev (2009-03-26):
 # According to the Palestine News Network (arabic.pnn.ps), Palestinian
 # government decided to start Daylight Time on Thursday night March
 # 26 and continue until the night of 27 September 2009.
 #
 # (in Arabic)
 # 
 # http://arabic.pnn.ps/index.php?option=com_content&task=view&id=50850
 # 
 #
 # or
 # (English translation)
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_westbank01.html
 # 
 
 # From Steffen Thorsen (2009-08-31):
 # Palestine's Council of Ministers announced that they will revert back to
 # winter time on Friday, 2009-09-04.
 #
 # One news source:
 # 
 # http://www.safa.ps/ara/?action=showdetail&seid=4158
 # 
 # (Palestinian press agency, Arabic),
 # Google translate: "Decided that the Palestinian government in Ramallah
 # headed by Salam Fayyad, the start of work in time for the winter of
 # 2009, starting on Friday approved the fourth delay Sept. clock sixty
 # minutes per hour as of Friday morning."
 #
 # We are not sure if Gaza will do the same, last year they had a different
 # end date, we will keep this page updated:
 # 
 # http://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html
 # 
 
 # From Alexander Krivenyshev (2009-09-02):
 # Seems that Gaza Strip will go back to Winter Time same date as West Bank.
 #
 # According to Palestinian Ministry Of Interior, West Bank and Gaza Strip plan
 # to change time back to Standard time on September 4, 2009.
 #
 # "Winter time unite the West Bank and Gaza"
 # (from Palestinian National Authority):
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_gazastrip02.html
 # 
 
 # From Alexander Krivenyshev (2010-03-19):
 # According to Voice of Palestine DST will last for 191 days, from March
 # 26, 2010 till "the last Sunday before the tenth day of Tishri
 # (October), each year" (October 03, 2010?)
 #
 # 
 # http://palvoice.org/forums/showthread.php?t=245697
 # 
 # (in Arabic)
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_westbank03.html
 # 
 
 # From Steffen Thorsen (2010-03-24):
 # ...Ma'an News Agency reports that Hamas cabinet has decided it will
 # start one day later, at 12:01am. Not sure if they really mean 12:01am or
 # noon though:
 #
 # 
 # http://www.maannews.net/eng/ViewDetails.aspx?ID=271178
 # 
 # (Ma'an News Agency)
 # "At 12:01am Friday, clocks in Israel and the West Bank will change to
 # 1:01am, while Gaza clocks will change at 12:01am Saturday morning."
 
 # From Steffen Thorsen (2010-08-11):
 # According to several sources, including
 # 
 # http://www.maannews.net/eng/ViewDetails.aspx?ID=306795
 # 
 # the clocks were set back one hour at 2010-08-11 00:00:00 local time in
 # Gaza and the West Bank.
 # Some more background info:
 # 
 # http://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html
 # 
 
 # From Steffen Thorsen (2011-08-26):
 # Gaza and the West Bank did go back to standard time in the beginning of
 # August, and will now enter daylight saving time again on 2011-08-30
 # 00:00 (so two periods of DST in 2011). The pause was because of
 # Ramadan.
 #
 # 
 # http://www.maannews.net/eng/ViewDetails.aspx?ID=416217
 # 
 # Additional info:
 # 
 # http://www.timeanddate.com/news/time/palestine-dst-2011.html
 # 
 
 # From Alexander Krivenyshev (2011-08-27):
 # According to the article in The Jerusalem Post:
 # "...Earlier this month, the Palestinian government in the West Bank decided to
 # move to standard time for 30 days, during Ramadan. The Palestinians in the
 # Gaza Strip accepted the change and also moved their clocks one hour back.
 # The Hamas government said on Saturday that it won't observe summertime after
 # the Muslim feast of Id al-Fitr, which begins on Tuesday..."
 # ...
 # 
 # http://www.jpost.com/MiddleEast/Article.aspx?id=235650
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_gazastrip05.html
 # 
 # The rules for Egypt are stolen from the `africa' file.
 
 # From Steffen Thorsen (2011-09-30):
 # West Bank did end Daylight Saving Time this morning/midnight (2011-09-30
 # 00:00).
 # So West Bank and Gaza now have the same time again.
 #
 # Many sources, including:
 # 
 # http://www.maannews.net/eng/ViewDetails.aspx?ID=424808
 # 
 
 # From Steffen Thorsen (2012-03-26):
 # Palestinian news sources tell that both Gaza and West Bank will start DST
 # on Friday (Thursday midnight, 2012-03-29 24:00).
 # Some of many sources in Arabic:
 # 
 # http://www.samanews.com/index.php?act=Show&id=122638
 # 
 #
 # 
 # http://safa.ps/details/news/74352/%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-%D8%A8%D8%A7%D9%84%D8%B6%D9%81%D8%A9-%D9%88%D8%BA%D8%B2%D8%A9-%D9%84%D9%8A%D9%84%D8%A9-%D8%A7%D9%84%D8%AC%D9%85%D8%B9%D8%A9.html
 # 
 #
 # Our brief summary:
 # 
 # http://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html
 # 
 
-# From Arthur David Olson (2012-03-27):
-# The timeanddate article for 2012 says that "the end date has not yet been
-# announced" and that "Last year, both...paused daylight saving time during...
-# Ramadan. It is not yet known [for] 2012."
-# For now, assume both switch back on the last Friday in September. XXX
+# From Steffen Thorsen (2013-03-26):
+# The following news sources tells that Palestine will "start daylight saving
+# time from midnight on Friday, March 29, 2013" (translated).
+# [These are in Arabic and are for Gaza and for Ramallah, respectively.]
+# http://www.samanews.com/index.php?act=Show&id=154120
+# http://safa.ps/details/news/99844/%D8%B1%D8%A7%D9%85-%D8%A7%D9%84%D9%84%D9%87-%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-29-%D8%A7%D9%84%D8%AC%D8%A7%D8%B1%D9%8A.html
 
+# From Paul Eggert (2013-04-15):
+# For future dates, guess the last Thursday in March at 24:00 through
+# the first Friday on or after September 21 at 01:00.  This is consistent with
+# the predictions in today's editions of the following URLs,
+# which are for Gaza and Hebron respectively:
+# http://www.timeanddate.com/worldclock/timezone.html?n=702
+# http://www.timeanddate.com/worldclock/timezone.html?n=2364
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
 Rule EgyptAsia	1957	1958	-	Oct	 1	0:00	0	-
 Rule EgyptAsia	1958	only	-	May	 1	0:00	1:00	S
 Rule EgyptAsia	1959	1967	-	May	 1	1:00	1:00	S
 Rule EgyptAsia	1959	1965	-	Sep	30	3:00	0	-
 Rule EgyptAsia	1966	only	-	Oct	 1	3:00	0	-
 
 Rule Palestine	1999	2005	-	Apr	Fri>=15	0:00	1:00	S
 Rule Palestine	1999	2003	-	Oct	Fri>=15	0:00	0	-
 Rule Palestine	2004	only	-	Oct	 1	1:00	0	-
 Rule Palestine	2005	only	-	Oct	 4	2:00	0	-
-Rule Palestine	2006	2008	-	Apr	 1	0:00	1:00	S
+Rule Palestine	2006	2007	-	Apr	 1	0:00	1:00	S
 Rule Palestine	2006	only	-	Sep	22	0:00	0	-
 Rule Palestine	2007	only	-	Sep	Thu>=8	2:00	0	-
-Rule Palestine	2008	only	-	Aug	lastFri	0:00	0	-
-Rule Palestine	2009	only	-	Mar	lastFri	0:00	1:00	S
-Rule Palestine	2009	only	-	Sep	Fri>=1	2:00	0	-
-Rule Palestine	2010	only	-	Mar	lastSat	0:01	1:00	S
+Rule Palestine	2008	2009	-	Mar	lastFri	0:00	1:00	S
+Rule Palestine	2008	only	-	Sep	 1	0:00	0	-
+Rule Palestine	2009	only	-	Sep	Fri>=1	1:00	0	-
+Rule Palestine	2010	only	-	Mar	26	0:00	1:00	S
 Rule Palestine	2010	only	-	Aug	11	0:00	0	-
+Rule Palestine	2011	only	-	Apr	 1	0:01	1:00	S
+Rule Palestine	2011	only	-	Aug	 1	0:00	0	-
+Rule Palestine	2011	only	-	Aug	30	0:00	1:00	S
+Rule Palestine	2011	only	-	Sep	30	0:00	0	-
+Rule Palestine	2012	max	-	Mar	lastThu	24:00	1:00	S
+Rule Palestine	2012	max	-	Sep	Fri>=21	1:00	0	-
 
-# From Arthur David Olson (2011-09-20):
-# 2011 transitions per http://www.timeanddate.com as of 2011-09-20.
-# From Paul Eggert (2012-10-12):
-# 2012 transitions per http://www.timeanddate.com as of 2012-10-12.
-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
 			2:00	Zion	EET	1948 May 15
 			2:00 EgyptAsia	EE%sT	1967 Jun  5
 			2:00	Zion	I%sT	1996
 			2:00	Jordan	EE%sT	1999
-			2:00 Palestine	EE%sT	2011 Apr  2 12:01
-			2:00	1:00	EEST	2011 Aug  1
-			2:00	-	EET	2012 Mar 30
-			2:00	1:00	EEST	2012 Sep 21 1:00
-			2:00	-	EET
+			2:00 Palestine	EE%sT	2008 Aug 29 0:00
+			2:00	-	EET	2008 Sep
+			2:00 Palestine	EE%sT	2010
+			2:00	-	EET	2010 Mar 27 0:01
+			2:00 Palestine	EE%sT	2011 Aug  1
+			2:00	-	EET	2012
+			2:00 Palestine	EE%sT
 
 Zone	Asia/Hebron	2:20:23	-	LMT	1900 Oct
 			2:00	Zion	EET	1948 May 15
 			2:00 EgyptAsia	EE%sT	1967 Jun  5
 			2:00	Zion	I%sT	1996
 			2:00	Jordan	EE%sT	1999
-			2:00 Palestine	EE%sT	2008 Aug
-			2:00 	1:00	EEST	2008 Sep
-			2:00 Palestine	EE%sT	2011 Apr  1 12:01
-			2:00	1:00	EEST	2011 Aug  1
-			2:00	-	EET	2011 Aug 30
-			2:00	1:00	EEST	2011 Sep 30 3:00
-			2:00	-	EET	2012 Mar 30
-			2:00	1:00	EEST	2012 Sep 21 1:00
-			2:00	-	EET
+			2:00 Palestine	EE%sT
 
 # Paracel Is
 # no information
 
 # Philippines
 # On 1844-08-16, Narciso Claveria, governor-general of the
 # Philippines, issued a proclamation announcing that 1844-12-30 was to
 # be immediately followed by 1845-01-01.  Robert H. van Gent has a
 # transcript of the decree in .
 # The rest of the data are from Shanks & Pottenger.
 
 # From Paul Eggert (2006-04-25):
 # Tomorrow's Manila Standard reports that the Philippines Department of
 # Trade and Industry is considering adopting DST this June when the
 # rainy season begins.  See
 # .
 # For now, we'll ignore this, since it's not definite and we lack details.
 #
 # From Jesper Norgaard Welen (2006-04-26):
 # ... claims that Philippines had DST last time in 1990:
 # http://story.philippinetimes.com/p.x/ct/9/id/145be20cc6b121c0/cid/3e5bbccc730d258c/
 # [a story dated 2006-04-25 by Cris Larano of Dow Jones Newswires,
 # but no details]
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Phil	1936	only	-	Nov	1	0:00	1:00	S
 Rule	Phil	1937	only	-	Feb	1	0:00	0	-
 Rule	Phil	1954	only	-	Apr	12	0:00	1:00	S
 Rule	Phil	1954	only	-	Jul	1	0:00	0	-
 Rule	Phil	1978	only	-	Mar	22	0:00	1:00	S
 Rule	Phil	1978	only	-	Sep	21	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Manila	-15:56:00 -	LMT	1844 Dec 31
 			8:04:00 -	LMT	1899 May 11
 			8:00	Phil	PH%sT	1942 May
 			9:00	-	JST	1944 Nov
 			8:00	Phil	PH%sT
 
 # Qatar
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Qatar	3:26:08 -	LMT	1920	# Al Dawhah / Doha
 			4:00	-	GST	1972 Jun
 			3:00	-	AST
 
 # Saudi Arabia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Riyadh	3:06:52 -	LMT	1950
 			3:00	-	AST
 
 # Singapore
 # The data here are taken from Mok Ly Yng (2003-10-30)
 # .
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Singapore	6:55:25 -	LMT	1901 Jan  1
 			6:55:25	-	SMT	1905 Jun  1 # Singapore M.T.
 			7:00	-	MALT	1933 Jan  1 # Malaya Time
 			7:00	0:20	MALST	1936 Jan  1
 			7:20	-	MALT	1941 Sep  1
 			7:30	-	MALT	1942 Feb 16
 			9:00	-	JST	1945 Sep 12
 			7:30	-	MALT	1965 Aug  9 # independence
 			7:30	-	SGT	1982 Jan  1 # Singapore Time
 			8:00	-	SGT
 
 # Spratly Is
 # no information
 
 # Sri Lanka
 
 # From Paul Eggert (2013-02-21):
 # Milne says "Madras mean time use from May 1, 1898.  Prior to this Colombo
 # mean time, 5h. 4m. 21.9s. F., was used."  But 5:04:21.9 differs considerably
 # from Colombo's meridian 5:19:24, so for now ignore Milne and stick with
 # Shanks and Pottenger.
 
 # From Paul Eggert (1996-09-03):
 # "Sri Lanka advances clock by an hour to avoid blackout"
 # (www.virtual-pc.com/lankaweb/news/items/240596-2.html, 1996-05-24,
 # no longer available as of 1999-08-17)
 # reported ``the country's standard time will be put forward by one hour at
 # midnight Friday (1830 GMT) `in the light of the present power crisis'.''
 #
 # From Dharmasiri Senanayake, Sri Lanka Media Minister (1996-10-24), as quoted
 # by Shamindra in
 # 
 # Daily News - Hot News Section (1996-10-26)
 # :
 # With effect from 12.30 a.m. on 26th October 1996
 # Sri Lanka will be six (06) hours ahead of GMT.
 
 # From Jesper Norgaard Welen (2006-04-14), quoting Sri Lanka News Online
 #  (2006-04-13):
 # 0030 hrs on April 15, 2006 (midnight of April 14, 2006 +30 minutes)
 # at present, become 2400 hours of April 14, 2006 (midnight of April 14, 2006).
 
 # From Peter Apps and Ranga Sirila of Reuters (2006-04-12) in:
 # 
 # [The Tamil Tigers] never accepted the original 1996 time change and simply
 # kept their clocks set five and a half hours ahead of Greenwich Mean
 # Time (GMT), in line with neighbor India.
 # From Paul Eggert (2006-04-18):
 # People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],
 # as that zone has agreed with the Tamil areas since our cutoff date of 1970.
 
 # From K Sethu (2006-04-25):
 # I think the abbreviation LKT originated from the world of computers at
 # the time of or subsequent to the time zone changes by SL Government
 # twice in 1996 and probably SL Government or its standardization
 # agencies never declared an abbreviation as a national standard.
 #
 # I recollect before the recent change the government annoucemments
 # mentioning it as simply changing Sri Lanka Standard Time or Sri Lanka
 # Time and no mention was made about the abbreviation.
 #
 # If we look at Sri Lanka Department of Government's "Official News
 # Website of Sri Lanka" ... http://www.news.lk/ we can see that they
 # use SLT as abbreviation in time stamp at the beginning of each news
 # item....
 #
 # Within Sri Lanka I think LKT is well known among computer users and
 # adminsitrators.  In my opinion SLT may not be a good choice because the
 # nation's largest telcom / internet operator Sri Lanka Telcom is well
 # known by that abbreviation - simply as SLT (there IP domains are
 # slt.lk and sltnet.lk).
 #
 # But if indeed our government has adopted SLT as standard abbreviation
 # (that we have not known so far) then  it is better that it be used for
 # all computers.
 
 # From Paul Eggert (2006-04-25):
 # One possibility is that we wait for a bit for the dust to settle down
 # and then see what people actually say in practice.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Colombo	5:19:24 -	LMT	1880
 			5:19:32	-	MMT	1906	# Moratuwa Mean Time
 			5:30	-	IST	1942 Jan  5
 			5:30	0:30	IHST	1942 Sep
 			5:30	1:00	IST	1945 Oct 16 2:00
 			5:30	-	IST	1996 May 25 0:00
 			6:30	-	LKT	1996 Oct 26 0:30
 			6:00	-	LKT	2006 Apr 15 0:30
 			5:30	-	IST
 
 # Syria
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Syria	1920	1923	-	Apr	Sun>=15	2:00	1:00	S
 Rule	Syria	1920	1923	-	Oct	Sun>=1	2:00	0	-
 Rule	Syria	1962	only	-	Apr	29	2:00	1:00	S
 Rule	Syria	1962	only	-	Oct	1	2:00	0	-
 Rule	Syria	1963	1965	-	May	1	2:00	1:00	S
 Rule	Syria	1963	only	-	Sep	30	2:00	0	-
 Rule	Syria	1964	only	-	Oct	1	2:00	0	-
 Rule	Syria	1965	only	-	Sep	30	2:00	0	-
 Rule	Syria	1966	only	-	Apr	24	2:00	1:00	S
 Rule	Syria	1966	1976	-	Oct	1	2:00	0	-
 Rule	Syria	1967	1978	-	May	1	2:00	1:00	S
 Rule	Syria	1977	1978	-	Sep	1	2:00	0	-
 Rule	Syria	1983	1984	-	Apr	9	2:00	1:00	S
 Rule	Syria	1983	1984	-	Oct	1	2:00	0	-
 Rule	Syria	1986	only	-	Feb	16	2:00	1:00	S
 Rule	Syria	1986	only	-	Oct	9	2:00	0	-
 Rule	Syria	1987	only	-	Mar	1	2:00	1:00	S
 Rule	Syria	1987	1988	-	Oct	31	2:00	0	-
 Rule	Syria	1988	only	-	Mar	15	2:00	1:00	S
 Rule	Syria	1989	only	-	Mar	31	2:00	1:00	S
 Rule	Syria	1989	only	-	Oct	1	2:00	0	-
 Rule	Syria	1990	only	-	Apr	1	2:00	1:00	S
 Rule	Syria	1990	only	-	Sep	30	2:00	0	-
 Rule	Syria	1991	only	-	Apr	 1	0:00	1:00	S
 Rule	Syria	1991	1992	-	Oct	 1	0:00	0	-
 Rule	Syria	1992	only	-	Apr	 8	0:00	1:00	S
 Rule	Syria	1993	only	-	Mar	26	0:00	1:00	S
 Rule	Syria	1993	only	-	Sep	25	0:00	0	-
 # IATA SSIM (1998-02) says 1998-04-02;
 # (1998-09) says 1999-03-29 and 1999-09-29; (1999-02) says 1999-04-02,
 # 2000-04-02, and 2001-04-02; (1999-09) says 2000-03-31 and 2001-03-31;
 # (2006) says 2006-03-31 and 2006-09-22;
 # for now ignore all these claims and go with Shanks & Pottenger,
 # except for the 2006-09-22 claim (which seems right for Ramadan).
 Rule	Syria	1994	1996	-	Apr	 1	0:00	1:00	S
 Rule	Syria	1994	2005	-	Oct	 1	0:00	0	-
 Rule	Syria	1997	1998	-	Mar	lastMon	0:00	1:00	S
 Rule	Syria	1999	2006	-	Apr	 1	0:00	1:00	S
 # From Stephen Colebourne (2006-09-18):
 # According to IATA data, Syria will change DST on 21st September [21:00 UTC]
 # this year [only]....  This is probably related to Ramadan, like Egypt.
 Rule	Syria	2006	only	-	Sep	22	0:00	0	-
 # From Paul Eggert (2007-03-29):
 # Today the AP reported "Syria will switch to summertime at midnight Thursday."
 # http://www.iht.com/articles/ap/2007/03/29/africa/ME-GEN-Syria-Time-Change.php
 Rule	Syria	2007	only	-	Mar	lastFri	0:00	1:00	S
 # From Jesper Norgard (2007-10-27):
 # The sister center ICARDA of my work CIMMYT is confirming that Syria DST will
 # not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or
 # rather Midnight between Thursday and Friday. This does make more sence than
 # having it between Wednesday and Thursday (two workdays in Syria) since the
 # weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now
 # it is implemented at midnight of the last workday before weekend...
 #
 # From Steffen Thorsen (2007-10-27):
 # Jesper Norgaard Welen wrote:
 #
 # > "Winter local time in Syria will be observed at midnight of Thursday 1
 # > November 2007, and the clock will be put back 1 hour."
 #
 # I found confirmation on this in this gov.sy-article (Arabic):
 # http://wehda.alwehda.gov.sy/_print_veiw.asp?FileName=12521710520070926111247
 #
 # which using Google's translate tools says:
 # Council of Ministers also approved the commencement of work on
 # identifying the winter time as of Friday, 2/11/2007 where the 60th
 # minute delay at midnight Thursday 1/11/2007.
 Rule	Syria	2007	only	-	Nov	 Fri>=1	0:00	0	-
 
 # From Stephen Colebourne (2008-03-17):
 # For everyone's info, I saw an IATA time zone change for [Syria] for
 # this month (March 2008) in the last day or so...This is the data IATA
 # are now using:
 # Country     Time Standard   --- DST Start ---   --- DST End ---  DST
 # Name        Zone Variation   Time    Date        Time    Date
 # Variation
 # Syrian Arab
 # Republic    SY    +0200      2200  03APR08       2100  30SEP08   +0300
 #                              2200  02APR09       2100  30SEP09   +0300
 #                              2200  01APR10       2100  30SEP10   +0300
 
 # From Arthur David Olson (2008-03-17):
 # Here's a link to English-language coverage by the Syrian Arab News
 # Agency (SANA)...
 # 
 # http://www.sana.sy/eng/21/2008/03/11/165173.htm
 # ...which reads (in part) "The Cabinet approved the suggestion of the
 # Ministry of Electricity to begin daylight savings time on Friday April
 # 4th, advancing clocks one hour ahead on midnight of Thursday April 3rd."
 # Since Syria is two hours east of UTC, the 2200 and 2100 transition times
 # shown above match up with midnight in Syria.
 
 # From Arthur David Olson (2008-03-18):
 # My buest guess at a Syrian rule is "the Friday nearest April 1";
 # coding that involves either using a "Mar Fri>=29" construct that old time zone
 # compilers can't handle  or having multiple Rules (a la Israel).
 # For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end.
 
 # From Steffen Thorsen (2008-10-07):
 # Syria has now officially decided to end DST on 2008-11-01 this year,
 # according to the following article in the Syrian Arab News Agency (SANA).
 #
 # The article is in Arabic, and seems to tell that they will go back to
 # winter time on 2008-11-01 at 00:00 local daylight time (delaying/setting
 # clocks back 60 minutes).
 #
 # 
 # http://sana.sy/ara/2/2008/10/07/195459.htm
 # 
 
 # From Steffen Thorsen (2009-03-19):
 # Syria will start DST on 2009-03-27 00:00 this year according to many sources,
 # two examples:
 #
 # 
 # http://www.sana.sy/eng/21/2009/03/17/217563.htm
 # 
 # (English, Syrian Arab News # Agency)
 # 
 # http://thawra.alwehda.gov.sy/_View_news2.asp?FileName=94459258720090318012209
 # 
 # (Arabic, gov-site)
 #
 # We have not found any sources saying anything about when DST ends this year.
 #
 # Our summary
 # 
 # http://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html
 # 
 
 # From Steffen Thorsen (2009-10-27):
 # The Syrian Arab News Network on 2009-09-29 reported that Syria will
 # revert back to winter (standard) time on midnight between Thursday
 # 2009-10-29 and Friday 2009-10-30:
 # 
 # http://www.sana.sy/ara/2/2009/09/29/247012.htm (Arabic)
 # 
 
 # From Arthur David Olson (2009-10-28):
 # We'll see if future DST switching times turn out to be end of the last
 # Thursday of the month or the start of the last Friday of the month or
 # something else. For now, use the start of the last Friday.
 
 # From Steffen Thorsen (2010-03-17):
 # The "Syrian News Station" reported on 2010-03-16 that the Council of
 # Ministers has decided that Syria will start DST on midnight Thursday
 # 2010-04-01: (midnight between Thursday and Friday):
 # 
 # http://sns.sy/sns/?path=news/read/11421 (Arabic)
 # 
 
 # From Steffen Thorsen (2012-03-26):
 # Today, Syria's government announced that they will start DST early on Friday
 # (00:00). This is a bit earlier than the past two years.
 #
 # From Syrian Arab News Agency, in Arabic:
 # 
 # http://www.sana.sy/ara/2/2012/03/26/408215.htm
 # 
 #
 # Our brief summary:
 # 
 # http://www.timeanddate.com/news/time/syria-dst-2012.html
 # 
 
 # From Arthur David Olson (2012-03-27):
 # Assume last Friday in March going forward XXX.
 
 Rule	Syria	2008	only	-	Apr	Fri>=1	0:00	1:00	S
 Rule	Syria	2008	only	-	Nov	1	0:00	0	-
 Rule	Syria	2009	only	-	Mar	lastFri	0:00	1:00	S
 Rule	Syria	2010	2011	-	Apr	Fri>=1	0:00	1:00	S
 Rule	Syria	2012	max	-	Mar	lastFri	0:00	1:00	S
 Rule	Syria	2009	max	-	Oct	lastFri	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Damascus	2:25:12 -	LMT	1920	# Dimashq
 			2:00	Syria	EE%sT
 
 # Tajikistan
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dushanbe	4:35:12 -	LMT	1924 May  2
 			5:00	-	DUST	1930 Jun 21 # Dushanbe Time
 			6:00 RussiaAsia DUS%sT	1991 Mar 31 2:00s
 			5:00	1:00	DUSST	1991 Sep  9 2:00s
 			5:00	-	TJT		    # Tajikistan Time
 
 # Thailand
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Bangkok	6:42:04	-	LMT	1880
 			6:42:04	-	BMT	1920 Apr # Bangkok Mean Time
 			7:00	-	ICT
 
 # Turkmenistan
 # From Shanks & Pottenger.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Ashgabat	3:53:32 -	LMT	1924 May  2 # or Ashkhabad
 			4:00	-	ASHT	1930 Jun 21 # Ashkhabad Time
 			5:00 RussiaAsia	ASH%sT	1991 Mar 31 2:00
 			4:00 RussiaAsia	ASH%sT	1991 Oct 27 # independence
 			4:00 RussiaAsia	TM%sT	1992 Jan 19 2:00
 			5:00	-	TMT
 
 # United Arab Emirates
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dubai	3:41:12 -	LMT	1920
 			4:00	-	GST
 
 # Uzbekistan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Samarkand	4:27:12 -	LMT	1924 May  2
 			4:00	-	SAMT	1930 Jun 21 # Samarkand Time
 			5:00	-	SAMT	1981 Apr  1
 			5:00	1:00	SAMST	1981 Oct  1
 			6:00	-	TAST	1982 Apr  1 # Tashkent Time
 			5:00 RussiaAsia	SAM%sT	1991 Sep  1 # independence
 			5:00 RussiaAsia	UZ%sT	1992
 			5:00	-	UZT
 Zone	Asia/Tashkent	4:37:12 -	LMT	1924 May  2
 			5:00	-	TAST	1930 Jun 21 # Tashkent Time
 			6:00 RussiaAsia	TAS%sT	1991 Mar 31 2:00
 			5:00 RussiaAsia	TAS%sT	1991 Sep  1 # independence
 			5:00 RussiaAsia	UZ%sT	1992
 			5:00	-	UZT
 
 # Vietnam
 
 # From Paul Eggert (2013-02-21):
 # Milne gives 7:16:56 for the meridian of Saigon in 1899, as being
 # used in Lower Laos, Cambodia, and Annam.  But this is quite a ways
 # from Saigon's location.  For now, ignore this and stick with Shanks
 # and Pottenger.
 
 # From Arthur David Olson (2008-03-18):
 # The English-language name of Vietnam's most populous city is "Ho Chi Min City";
 # we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
 
 # From Shanks & Pottenger:
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Ho_Chi_Minh	7:06:40 -	LMT	1906 Jun  9
 			7:06:20	-	SMT	1911 Mar 11 0:01 # Saigon MT?
 			7:00	-	ICT	1912 May
 			8:00	-	ICT	1931 May
 			7:00	-	ICT
 
 # Yemen
 
 # Milne says 2:59:54 was the meridian of the saluting battery at Aden,
 # and that Yemen was at 1:55:56, the meridian of the Hagia Sophia.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Aden	2:59:54	-	LMT	1950
 			3:00	-	AST
Index: user/attilio/vmcontention/contrib/tzdata/australasia
===================================================================
--- user/attilio/vmcontention/contrib/tzdata/australasia	(revision 249698)
+++ user/attilio/vmcontention/contrib/tzdata/australasia	(revision 249699)
@@ -1,1726 +1,1743 @@
 # 
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # This file also includes Pacific islands.
 
 # Notes are at the end of this file
 
 ###############################################################################
 
 # Australia
 
 # Please see the notes below for the controversy about "EST" versus "AEST" etc.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Aus	1917	only	-	Jan	 1	0:01	1:00	-
 Rule	Aus	1917	only	-	Mar	25	2:00	0	-
 Rule	Aus	1942	only	-	Jan	 1	2:00	1:00	-
 Rule	Aus	1942	only	-	Mar	29	2:00	0	-
 Rule	Aus	1942	only	-	Sep	27	2:00	1:00	-
 Rule	Aus	1943	1944	-	Mar	lastSun	2:00	0	-
 Rule	Aus	1943	only	-	Oct	 3	2:00	1:00	-
 # Go with Whitman and the Australian National Standards Commission, which
 # says W Australia didn't use DST in 1943/1944.  Ignore Whitman's claim that
 # 1944/1945 was just like 1943/1944.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 # Northern Territory
 Zone Australia/Darwin	 8:43:20 -	LMT	1895 Feb
 			 9:00	-	CST	1899 May
 			 9:30	Aus	CST
 # Western Australia
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AW	1974	only	-	Oct	lastSun	2:00s	1:00	-
 Rule	AW	1975	only	-	Mar	Sun>=1	2:00s	0	-
 Rule	AW	1983	only	-	Oct	lastSun	2:00s	1:00	-
 Rule	AW	1984	only	-	Mar	Sun>=1	2:00s	0	-
 Rule	AW	1991	only	-	Nov	17	2:00s	1:00	-
 Rule	AW	1992	only	-	Mar	Sun>=1	2:00s	0	-
 Rule	AW	2006	only	-	Dec	 3	2:00s	1:00	-
 Rule	AW	2007	2009	-	Mar	lastSun	2:00s	0	-
 Rule	AW	2007	2008	-	Oct	lastSun	2:00s	1:00	-
 Zone Australia/Perth	 7:43:24 -	LMT	1895 Dec
 			 8:00	Aus	WST	1943 Jul
 			 8:00	AW	WST
 Zone Australia/Eucla	 8:35:28 -	LMT	1895 Dec
 			 8:45	Aus	CWST	1943 Jul
 			 8:45	AW	CWST
 
 # Queensland
 #
 # From Alex Livingston (1996-11-01):
 # I have heard or read more than once that some resort islands off the coast
 # of Queensland chose to keep observing daylight-saving time even after
 # Queensland ceased to.
 #
 # From Paul Eggert (1996-11-22):
 # IATA SSIM (1993-02/1994-09) say that the Holiday Islands (Hayman, Lindeman,
 # Hamilton) observed DST for two years after the rest of Queensland stopped.
 # Hamilton is the largest, but there is also a Hamilton in Victoria,
 # so use Lindeman.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AQ	1971	only	-	Oct	lastSun	2:00s	1:00	-
 Rule	AQ	1972	only	-	Feb	lastSun	2:00s	0	-
 Rule	AQ	1989	1991	-	Oct	lastSun	2:00s	1:00	-
 Rule	AQ	1990	1992	-	Mar	Sun>=1	2:00s	0	-
 Rule	Holiday	1992	1993	-	Oct	lastSun	2:00s	1:00	-
 Rule	Holiday	1993	1994	-	Mar	Sun>=1	2:00s	0	-
 Zone Australia/Brisbane	10:12:08 -	LMT	1895
 			10:00	Aus	EST	1971
 			10:00	AQ	EST
 Zone Australia/Lindeman  9:55:56 -	LMT	1895
 			10:00	Aus	EST	1971
 			10:00	AQ	EST	1992 Jul
 			10:00	Holiday	EST
 
 # South Australia
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AS	1971	1985	-	Oct	lastSun	2:00s	1:00	-
 Rule	AS	1986	only	-	Oct	19	2:00s	1:00	-
 Rule	AS	1987	2007	-	Oct	lastSun	2:00s	1:00	-
 Rule	AS	1972	only	-	Feb	27	2:00s	0	-
 Rule	AS	1973	1985	-	Mar	Sun>=1	2:00s	0	-
 Rule	AS	1986	1990	-	Mar	Sun>=15	2:00s	0	-
 Rule	AS	1991	only	-	Mar	3	2:00s	0	-
 Rule	AS	1992	only	-	Mar	22	2:00s	0	-
 Rule	AS	1993	only	-	Mar	7	2:00s	0	-
 Rule	AS	1994	only	-	Mar	20	2:00s	0	-
 Rule	AS	1995	2005	-	Mar	lastSun	2:00s	0	-
 Rule	AS	2006	only	-	Apr	2	2:00s	0	-
 Rule	AS	2007	only	-	Mar	lastSun	2:00s	0	-
 Rule	AS	2008	max	-	Apr	Sun>=1	2:00s	0	-
 Rule	AS	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Australia/Adelaide	9:14:20 -	LMT	1895 Feb
 			9:00	-	CST	1899 May
 			9:30	Aus	CST	1971
 			9:30	AS	CST
 
 # Tasmania
 #
 # From Paul Eggert (2005-08-16):
 # 
 # says King Island didn't observe DST from WWII until late 1971.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AT	1967	only	-	Oct	Sun>=1	2:00s	1:00	-
 Rule	AT	1968	only	-	Mar	lastSun	2:00s	0	-
 Rule	AT	1968	1985	-	Oct	lastSun	2:00s	1:00	-
 Rule	AT	1969	1971	-	Mar	Sun>=8	2:00s	0	-
 Rule	AT	1972	only	-	Feb	lastSun	2:00s	0	-
 Rule	AT	1973	1981	-	Mar	Sun>=1	2:00s	0	-
 Rule	AT	1982	1983	-	Mar	lastSun	2:00s	0	-
 Rule	AT	1984	1986	-	Mar	Sun>=1	2:00s	0	-
 Rule	AT	1986	only	-	Oct	Sun>=15	2:00s	1:00	-
 Rule	AT	1987	1990	-	Mar	Sun>=15	2:00s	0	-
 Rule	AT	1987	only	-	Oct	Sun>=22	2:00s	1:00	-
 Rule	AT	1988	1990	-	Oct	lastSun	2:00s	1:00	-
 Rule	AT	1991	1999	-	Oct	Sun>=1	2:00s	1:00	-
 Rule	AT	1991	2005	-	Mar	lastSun	2:00s	0	-
 Rule	AT	2000	only	-	Aug	lastSun	2:00s	1:00	-
 Rule	AT	2001	max	-	Oct	Sun>=1	2:00s	1:00	-
 Rule	AT	2006	only	-	Apr	Sun>=1	2:00s	0	-
 Rule	AT	2007	only	-	Mar	lastSun	2:00s	0	-
 Rule	AT	2008	max	-	Apr	Sun>=1	2:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Australia/Hobart	9:49:16	-	LMT	1895 Sep
 			10:00	-	EST	1916 Oct 1 2:00
 			10:00	1:00	EST	1917 Feb
 			10:00	Aus	EST	1967
 			10:00	AT	EST
 Zone Australia/Currie	9:35:28	-	LMT	1895 Sep
 			10:00	-	EST	1916 Oct 1 2:00
 			10:00	1:00	EST	1917 Feb
 			10:00	Aus	EST	1971 Jul
 			10:00	AT	EST
 
 # Victoria
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AV	1971	1985	-	Oct	lastSun	2:00s	1:00	-
 Rule	AV	1972	only	-	Feb	lastSun	2:00s	0	-
 Rule	AV	1973	1985	-	Mar	Sun>=1	2:00s	0	-
 Rule	AV	1986	1990	-	Mar	Sun>=15	2:00s	0	-
 Rule	AV	1986	1987	-	Oct	Sun>=15	2:00s	1:00	-
 Rule	AV	1988	1999	-	Oct	lastSun	2:00s	1:00	-
 Rule	AV	1991	1994	-	Mar	Sun>=1	2:00s	0	-
 Rule	AV	1995	2005	-	Mar	lastSun	2:00s	0	-
 Rule	AV	2000	only	-	Aug	lastSun	2:00s	1:00	-
 Rule	AV	2001	2007	-	Oct	lastSun	2:00s	1:00	-
 Rule	AV	2006	only	-	Apr	Sun>=1	2:00s	0	-
 Rule	AV	2007	only	-	Mar	lastSun	2:00s	0	-
 Rule	AV	2008	max	-	Apr	Sun>=1	2:00s	0	-
 Rule	AV	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Australia/Melbourne 9:39:52 -	LMT	1895 Feb
 			10:00	Aus	EST	1971
 			10:00	AV	EST
 
 # New South Wales
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	AN	1971	1985	-	Oct	lastSun	2:00s	1:00	-
 Rule	AN	1972	only	-	Feb	27	2:00s	0	-
 Rule	AN	1973	1981	-	Mar	Sun>=1	2:00s	0	-
 Rule	AN	1982	only	-	Apr	Sun>=1	2:00s	0	-
 Rule	AN	1983	1985	-	Mar	Sun>=1	2:00s	0	-
 Rule	AN	1986	1989	-	Mar	Sun>=15	2:00s	0	-
 Rule	AN	1986	only	-	Oct	19	2:00s	1:00	-
 Rule	AN	1987	1999	-	Oct	lastSun	2:00s	1:00	-
 Rule	AN	1990	1995	-	Mar	Sun>=1	2:00s	0	-
 Rule	AN	1996	2005	-	Mar	lastSun	2:00s	0	-
 Rule	AN	2000	only	-	Aug	lastSun	2:00s	1:00	-
 Rule	AN	2001	2007	-	Oct	lastSun	2:00s	1:00	-
 Rule	AN	2006	only	-	Apr	Sun>=1	2:00s	0	-
 Rule	AN	2007	only	-	Mar	lastSun	2:00s	0	-
 Rule	AN	2008	max	-	Apr	Sun>=1	2:00s	0	-
 Rule	AN	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Australia/Sydney	10:04:52 -	LMT	1895 Feb
 			10:00	Aus	EST	1971
 			10:00	AN	EST
 Zone Australia/Broken_Hill 9:25:48 -	LMT	1895 Feb
 			10:00	-	EST	1896 Aug 23
 			9:00	-	CST	1899 May
 			9:30	Aus	CST	1971
 			9:30	AN	CST	2000
 			9:30	AS	CST
 
 # Lord Howe Island
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	LH	1981	1984	-	Oct	lastSun	2:00	1:00	-
 Rule	LH	1982	1985	-	Mar	Sun>=1	2:00	0	-
 Rule	LH	1985	only	-	Oct	lastSun	2:00	0:30	-
 Rule	LH	1986	1989	-	Mar	Sun>=15	2:00	0	-
 Rule	LH	1986	only	-	Oct	19	2:00	0:30	-
 Rule	LH	1987	1999	-	Oct	lastSun	2:00	0:30	-
 Rule	LH	1990	1995	-	Mar	Sun>=1	2:00	0	-
 Rule	LH	1996	2005	-	Mar	lastSun	2:00	0	-
 Rule	LH	2000	only	-	Aug	lastSun	2:00	0:30	-
 Rule	LH	2001	2007	-	Oct	lastSun	2:00	0:30	-
 Rule	LH	2006	only	-	Apr	Sun>=1	2:00	0	-
 Rule	LH	2007	only	-	Mar	lastSun	2:00	0	-
 Rule	LH	2008	max	-	Apr	Sun>=1	2:00	0	-
 Rule	LH	2008	max	-	Oct	Sun>=1	2:00	0:30	-
 Zone Australia/Lord_Howe 10:36:20 -	LMT	1895 Feb
 			10:00	-	EST	1981 Mar
 			10:30	LH	LHST
 
 # Australian miscellany
 #
 # Ashmore Is, Cartier
 # no indigenous inhabitants; only seasonal caretakers
 # no times are set
 #
 # Coral Sea Is
 # no indigenous inhabitants; only meteorologists
 # no times are set
 #
 # Macquarie
-# permanent occupation (scientific station) since 1948;
-# sealing and penguin oil station operated 1888/1917
-# like Australia/Hobart
+# Permanent occupation (scientific station) 1911-1915 and since 25 March 1948;
+# sealing and penguin oil station operated Nov 1899 to Apr 1919.  See the
+# Tasmania Parks & Wildlife Service history of sealing at Macquarie Island
+# 
+# .
+# Guess that it was like Australia/Hobart while inhabited before 2010.
+#
+# From Steffen Thorsen (2010-03-10):
+# We got these changes from the Australian Antarctic Division:
+# - Macquarie Island will stay on UTC+11 for winter and therefore not
+# switch back from daylight savings time when other parts of Australia do
+# on 4 April.
+Zone Antarctica/Macquarie 0	-	zzz	1899 Nov
+			10:00	-	EST	1916 Oct 1 2:00
+			10:00	1:00	EST	1917 Feb
+			10:00	Aus	EST	1919 Apr
+			0	-	zzz	1948 Mar 25
+			10:00	Aus	EST	1967
+			10:00	AT	EST	2010 Apr 4 3:00
+			11:00	-	MIST	# Macquarie I Standard Time
 
 # Christmas
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Christmas	7:02:52 -	LMT	1895 Feb
 			7:00	-	CXT	# Christmas Island Time
 
 # Cook Is
 # From Shanks & Pottenger:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Cook	1978	only	-	Nov	12	0:00	0:30	HS
 Rule	Cook	1979	1991	-	Mar	Sun>=1	0:00	0	-
 Rule	Cook	1979	1990	-	Oct	lastSun	0:00	0:30	HS
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Rarotonga	-10:39:04 -	LMT	1901		# Avarua
 			-10:30	-	CKT	1978 Nov 12	# Cook Is Time
 			-10:00	Cook	CK%sT
 
 # Cocos
 # These islands were ruled by the Ross family from about 1830 to 1978.
 # We don't know when standard time was introduced; for now, we guess 1900.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Indian/Cocos	6:27:40	-	LMT	1900
 			6:30	-	CCT	# Cocos Islands Time
 
 # Fiji
 
 # Milne gives 11:55:44 for Suva.
 
 # From Alexander Krivenyshev (2009-11-10):
 # According to Fiji Broadcasting Corporation,  Fiji plans to re-introduce DST
 # from November 29th 2009  to April 25th 2010.
 #
 # "Daylight savings to commence this month"
 # 
 # http://www.radiofiji.com.fj/fullstory.php?id=23719
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_fiji01.html
 # 
 
 # From Steffen Thorsen (2009-11-10):
 # The Fiji Government has posted some more details about the approved
 # amendments:
 # 
 # http://www.fiji.gov.fj/publish/page_16198.shtml
 # 
 
 # From Steffen Thorsen (2010-03-03):
 # The Cabinet in Fiji has decided to end DST about a month early, on
 # 2010-03-28 at 03:00.
 # The plan is to observe DST again, from 2010-10-24 to sometime in March
 # 2011 (last Sunday a good guess?).
 #
 # Official source:
 # 
 # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=1096:3310-cabinet-approves-change-in-daylight-savings-dates&catid=49:cabinet-releases&Itemid=166
 # 
 #
 # A bit more background info here:
 # 
 # http://www.timeanddate.com/news/time/fiji-dst-ends-march-2010.html
 # 
 
 # From Alexander Krivenyshev (2010-10-24):
 # According to Radio Fiji and Fiji Times online, Fiji will end DST 3
 # weeks earlier than expected - on March 6, 2011, not March 27, 2011...
 # Here is confirmation from Government of the Republic of the Fiji Islands,
 # Ministry of Information (fiji.gov.fj) web site:
 # 
 # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=2608:daylight-savings&catid=71:press-releases&Itemid=155
 # 
 # or
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_fiji04.html
 # 
 
 # From Steffen Thorsen (2011-10-03):
 # Now the dates have been confirmed, and at least our start date
 # assumption was correct (end date was one week wrong).
 #
 # 
 # www.fiji.gov.fj/index.php?option=com_content&view=article&id=4966:daylight-saving-starts-in-fiji&catid=71:press-releases&Itemid=155
 # 
 # which says
 # Members of the public are reminded to change their time to one hour in
 # advance at 2am to 3am on October 23, 2011 and one hour back at 3am to
 # 2am on February 26 next year.
 
 # From Ken Rylander (2011-10-24)
 # Another change to the Fiji DST end date. In the TZ database the end date for
 # Fiji DST 2012, is currently Feb 26. This has been changed to Jan 22.
 #
 # 
 # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=5017:amendments-to-daylight-savings&catid=71:press-releases&Itemid=155
 # 
 # states:
 #
 # The end of daylight saving scheduled initially for the 26th of February 2012
 # has been brought forward to the 22nd of January 2012.
 # The commencement of daylight saving will remain unchanged and start
 # on the  23rd of October, 2011.
 
 # From the Fiji Government Online Portal (2012-08-21) via Steffen Thorsen:
 # The Minister for Labour, Industrial Relations and Employment Mr Jone Usamate
 # today confirmed that Fiji will start daylight savings at 2 am on Sunday 21st
 # October 2012 and end at 3 am on Sunday 20th January 2013.
 # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155
 #
 # From Paul Eggert (2012-08-31):
 # For now, guess a pattern of the penultimate Sundays in October and January.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Fiji	1998	1999	-	Nov	Sun>=1	2:00	1:00	S
 Rule	Fiji	1999	2000	-	Feb	lastSun	3:00	0	-
 Rule	Fiji	2009	only	-	Nov	29	2:00	1:00	S
 Rule	Fiji	2010	only	-	Mar	lastSun	3:00	0	-
 Rule	Fiji	2010	max	-	Oct	Sun>=18	2:00	1:00	S
 Rule	Fiji	2011	only	-	Mar	Sun>=1	3:00	0	-
 Rule	Fiji	2012	max	-	Jan	Sun>=18	3:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fiji	11:55:44 -	LMT	1915 Oct 26	# Suva
 			12:00	Fiji	FJ%sT	# Fiji Time
 
 # French Polynesia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Gambier	 -8:59:48 -	LMT	1912 Oct	# Rikitea
 			 -9:00	-	GAMT	# Gambier Time
 Zone	Pacific/Marquesas -9:18:00 -	LMT	1912 Oct
 			 -9:30	-	MART	# Marquesas Time
 Zone	Pacific/Tahiti	 -9:58:16 -	LMT	1912 Oct	# Papeete
 			-10:00	-	TAHT	# Tahiti Time
 # Clipperton (near North America) is administered from French Polynesia;
 # it is uninhabited.
 
 # Guam
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Guam	-14:21:00 -	LMT	1844 Dec 31
 			 9:39:00 -	LMT	1901		# Agana
 			10:00	-	GST	2000 Dec 23	# Guam
 			10:00	-	ChST	# Chamorro Standard Time
 
 # Kiribati
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Tarawa	 11:32:04 -	LMT	1901		# Bairiki
 			 12:00	-	GILT		 # Gilbert Is Time
 Zone Pacific/Enderbury	-11:24:20 -	LMT	1901
 			-12:00	-	PHOT	1979 Oct # Phoenix Is Time
 			-11:00	-	PHOT	1995
 			 13:00	-	PHOT
 Zone Pacific/Kiritimati	-10:29:20 -	LMT	1901
 			-10:40	-	LINT	1979 Oct # Line Is Time
 			-10:00	-	LINT	1995
 			 14:00	-	LINT
 
 # N Mariana Is
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Saipan	-14:17:00 -	LMT	1844 Dec 31
 			 9:43:00 -	LMT	1901
 			 9:00	-	MPT	1969 Oct # N Mariana Is Time
 			10:00	-	MPT	2000 Dec 23
 			10:00	-	ChST	# Chamorro Standard Time
 
 # Marshall Is
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Majuro	11:24:48 -	LMT	1901
 			11:00	-	MHT	1969 Oct # Marshall Islands Time
 			12:00	-	MHT
 Zone Pacific/Kwajalein	11:09:20 -	LMT	1901
 			11:00	-	MHT	1969 Oct
 			-12:00	-	KWAT	1993 Aug 20	# Kwajalein Time
 			12:00	-	MHT
 
 # Micronesia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Chuuk	10:07:08 -	LMT	1901
 			10:00	-	CHUT			# Chuuk Time
 Zone Pacific/Pohnpei	10:32:52 -	LMT	1901		# Kolonia
 			11:00	-	PONT			# Pohnpei Time
 Zone Pacific/Kosrae	10:51:56 -	LMT	1901
 			11:00	-	KOST	1969 Oct	# Kosrae Time
 			12:00	-	KOST	1999
 			11:00	-	KOST
 
 # Nauru
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Nauru	11:07:40 -	LMT	1921 Jan 15	# Uaobe
 			11:30	-	NRT	1942 Mar 15	# Nauru Time
 			9:00	-	JST	1944 Aug 15
 			11:30	-	NRT	1979 May
 			12:00	-	NRT
 
 # New Caledonia
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NC	1977	1978	-	Dec	Sun>=1	0:00	1:00	S
 Rule	NC	1978	1979	-	Feb	27	0:00	0	-
 Rule	NC	1996	only	-	Dec	 1	2:00s	1:00	S
 # Shanks & Pottenger say the following was at 2:00; go with IATA.
 Rule	NC	1997	only	-	Mar	 2	2:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Noumea	11:05:48 -	LMT	1912 Jan 13
 			11:00	NC	NC%sT
 
 
 ###############################################################################
 
 # New Zealand
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NZ	1927	only	-	Nov	 6	2:00	1:00	S
 Rule	NZ	1928	only	-	Mar	 4	2:00	0	M
 Rule	NZ	1928	1933	-	Oct	Sun>=8	2:00	0:30	S
 Rule	NZ	1929	1933	-	Mar	Sun>=15	2:00	0	M
 Rule	NZ	1934	1940	-	Apr	lastSun	2:00	0	M
 Rule	NZ	1934	1940	-	Sep	lastSun	2:00	0:30	S
 Rule	NZ	1946	only	-	Jan	 1	0:00	0	S
 # Since 1957 Chatham has been 45 minutes ahead of NZ, but there's no
 # convenient notation for this so we must duplicate the Rule lines.
 Rule	NZ	1974	only	-	Nov	Sun>=1	2:00s	1:00	D
 Rule	Chatham	1974	only	-	Nov	Sun>=1	2:45s	1:00	D
 Rule	NZ	1975	only	-	Feb	lastSun	2:00s	0	S
 Rule	Chatham	1975	only	-	Feb	lastSun	2:45s	0	S
 Rule	NZ	1975	1988	-	Oct	lastSun	2:00s	1:00	D
 Rule	Chatham	1975	1988	-	Oct	lastSun	2:45s	1:00	D
 Rule	NZ	1976	1989	-	Mar	Sun>=1	2:00s	0	S
 Rule	Chatham	1976	1989	-	Mar	Sun>=1	2:45s	0	S
 Rule	NZ	1989	only	-	Oct	Sun>=8	2:00s	1:00	D
 Rule	Chatham	1989	only	-	Oct	Sun>=8	2:45s	1:00	D
 Rule	NZ	1990	2006	-	Oct	Sun>=1	2:00s	1:00	D
 Rule	Chatham	1990	2006	-	Oct	Sun>=1	2:45s	1:00	D
 Rule	NZ	1990	2007	-	Mar	Sun>=15	2:00s	0	S
 Rule	Chatham	1990	2007	-	Mar	Sun>=15	2:45s	0	S
 Rule	NZ	2007	max	-	Sep	lastSun	2:00s	1:00	D
 Rule	Chatham	2007	max	-	Sep	lastSun	2:45s	1:00	D
 Rule	NZ	2008	max	-	Apr	Sun>=1	2:00s	0	S
 Rule	Chatham	2008	max	-	Apr	Sun>=1	2:45s	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Auckland	11:39:04 -	LMT	1868 Nov  2
 			11:30	NZ	NZ%sT	1946 Jan  1
 			12:00	NZ	NZ%sT
 Zone Pacific/Chatham	12:13:48 -	LMT	1957 Jan  1
 			12:45	Chatham	CHA%sT
 
 
 # Auckland Is
 # uninhabited; Maori and Moriori, colonial settlers, pastoralists, sealers,
 # and scientific personnel have wintered
 
 # Campbell I
 # minor whaling stations operated 1909/1914
 # scientific station operated 1941/1995;
 # previously whalers, sealers, pastoralists, and scientific personnel wintered
 # was probably like Pacific/Auckland
 
 ###############################################################################
 
 
 # Niue
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Niue	-11:19:40 -	LMT	1901		# Alofi
 			-11:20	-	NUT	1951	# Niue Time
 			-11:30	-	NUT	1978 Oct 1
 			-11:00	-	NUT
 
 # Norfolk
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Norfolk	11:11:52 -	LMT	1901		# Kingston
 			11:12	-	NMT	1951	# Norfolk Mean Time
 			11:30	-	NFT		# Norfolk Time
 
 # Palau (Belau)
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Palau	8:57:56 -	LMT	1901		# Koror
 			9:00	-	PWT	# Palau Time
 
 # Papua New Guinea
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Port_Moresby 9:48:40 -	LMT	1880
 			9:48:32	-	PMMT	1895	# Port Moresby Mean Time
 			10:00	-	PGT		# Papua New Guinea Time
 
 # Pitcairn
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Pitcairn	-8:40:20 -	LMT	1901		# Adamstown
 			-8:30	-	PNT	1998 Apr 27 00:00
 			-8:00	-	PST	# Pitcairn Standard Time
 
 # American Samoa
 Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1879 Jul  5
 			-11:22:48 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
 			-11:00	-	NST	1967 Apr	# N=Nome
 			-11:00	-	BST	1983 Nov 30	# B=Bering
 			-11:00	-	SST			# S=Samoa
 
 # Samoa
 
 # From Steffen Thorsen (2009-10-16):
 # We have been in contact with the government of Samoa again, and received
 # the following info:
 #
 # "Cabinet has now approved Daylight Saving to be effected next year
 # commencing from the last Sunday of September 2010 and conclude first
 # Sunday of April 2011."
 #
 # Background info:
 # 
 # http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
 # 
 #
 # Samoa's Daylight Saving Time Act 2009 is available here, but does not
 # contain any dates:
 # 
 # http://www.parliament.gov.ws/documents/acts/Daylight%20Saving%20Act%20%202009%20%28English%29%20-%20Final%207-7-091.pdf
 # 
 
 # From Laupue Raymond Hughes (2010-10-07):
 # Please see
 # 
 # http://www.mcil.gov.ws
 # ,
 # the Ministry of Commerce, Industry and Labour (sideframe) "Last Sunday
 # September 2010 (26/09/10) - adjust clocks forward from 12:00 midnight
 # to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks
 # backwards from 1:00am to 12:00am"
 
 # From Laupue Raymond Hughes (2011-03-07):
 # I believe this will be posted shortly on the website
 # 
 # www.mcil.gov.ws
 # 
 #
 # PUBLIC NOTICE ON DAYLIGHT SAVING TIME
 #
 # Pursuant to the Daylight Saving Act 2009 and Cabinets decision,
 # businesses and the general public are hereby advised that daylight
 # saving time is on the first Saturday of April 2011 (02/04/11).
 #
 # The public is therefore advised that when the standard time strikes
 # the hour of four oclock (4.00am or 0400 Hours) on the 2nd April 2011,
 # then all instruments used to measure standard time are to be
 # adjusted/changed to three oclock (3:00am or 0300Hrs).
 #
 # Margaret Fruean ACTING CHIEF EXECUTIVE OFFICER MINISTRY OF COMMERCE,
 # INDUSTRY AND LABOUR 28th February 2011
 
 # From David Zuelke (2011-05-09):
 # Subject: Samoa to move timezone from east to west of international date line
 #
 # 
 # http://www.morningstar.co.uk/uk/markets/newsfeeditem.aspx?id=138501958347963
 # 
 
 # From Mark Sim-Smith (2011-08-17):
 # I have been in contact with Leilani Tuala Warren from the Samoa Law
 # Reform Commission, and she has sent me a copy of the Bill that she
 # confirmed has been passed...Most of the sections are about maps rather
 # than the time zone change, but I'll paste the relevant bits below. But
 # the essence is that at midnight 29 Dec (UTC-11 I suppose), Samoa
 # changes from UTC-11 to UTC+13:
 #
 # International Date Line Bill 2011
 #
 # AN ACT to provide for the change to standard time in Samoa and to make
 # consequential amendments to the position of the International Date
 # Line, and for related purposes.
 #
 # BE IT ENACTED by the Legislative Assembly of Samoa in Parliament
 # assembled as follows:
 #
 # 1. Short title and commencement-(1) This Act may be cited as the
 # International Date Line Act 2011. (2) Except for section 5(3) this Act
 # commences at 12 o'clock midnight, on Thursday 29th December 2011. (3)
 # Section 5(3) commences on the date of assent by the Head of State.
 #
 # [snip]
 #
 # 3. Interpretation - [snip] "Samoa standard time" in this Act and any
 # other statute of Samoa which refers to 'Samoa standard time' means the
 # time 13 hours in advance of Co-ordinated Universal Time.
 #
 # 4. Samoa standard time - (1) Upon the commencement of this Act, Samoa
 # standard time shall be set at 13 hours in advance of Co-ordinated
 # Universal Time for the whole of Samoa. (2) All references to Samoa's
 # time zone and to Samoa standard time in Samoa in all legislation and
 # instruments after the commencement of this Act shall be references to
 # Samoa standard time as provided for in this Act. (3) Nothing in this
 # Act affects the provisions of the Daylight Saving Act 2009, except that
 # it defines Samoa standard time....
 
 # From Laupue Raymond Hughes (2011-09-02):
 # 
 # http://www.mcil.gov.ws/mcil_publications.html
 # 
 #
 # here is the official website publication for Samoa DST and dateline change
 #
 # DST
 # Year	End	Time	Start	Time
 # 2011	- - -	- - -	24 September	3:00am to 4:00am
 # 2012	01 April	4:00am to 3:00am	- - -	- - -
 #
 # Dateline Change skip Friday 30th Dec 2011
 # Thursday 29th December 2011	23:59:59 Hours
 # Saturday 31st December 2011	00:00:00 Hours
 #
 # Clarification by Tim Parenti (2012-01-03):
 # Although Samoa has used Daylight Saving Time in the 2010-2011 and 2011-2012
 # seasons, there is not yet any indication that this trend will continue on
 # a regular basis. For now, we have explicitly listed the transitions below.
 #
 # From Nicky (2012-09-10):
 # Daylight Saving Time commences on Sunday 30th September 2012 and
 # ends on Sunday 7th of April 2013.
 #
 # Please find link below for more information.
 # http://www.mcil.gov.ws/mcil_publications.html
 #
 # That publication also includes dates for Summer of 2013/4 as well
 # which give the impression of a pattern in selecting dates for the
 # future, so for now, we will guess this will continue.
 
 # Western Samoa
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	WS	2012	max	-	Sep	lastSun	3:00	1	D
 Rule	WS	2012	max	-	Apr	Sun>=1	4:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
 			-11:00	-	WST	2010 Sep 26
 			-11:00	1:00	WSDT	2011 Apr 2 4:00
 			-11:00	-	WST	2011 Sep 24 3:00
 			-11:00	1:00	WSDT	2011 Dec 30
 			 13:00	1:00	WSDT	2012 Apr Sun>=1 4:00
 			 13:00	WS	WS%sT
 
 # Solomon Is
 # excludes Bougainville, for which see Papua New Guinea
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Guadalcanal 10:39:48 -	LMT	1912 Oct	# Honiara
 			11:00	-	SBT	# Solomon Is Time
 
 # Tokelau Is
 #
 # From Gwillim Law (2011-12-29)
 # A correspondent informed me that Tokelau, like Samoa, will be skipping
 # December 31 this year ...
 #
 # From Steffen Thorsen (2012-07-25)
 # ... we double checked by calling hotels and offices based in Tokelau asking
 # about the time there, and they all told a time that agrees with UTC+13....
 # Shanks says UTC-10 from 1901 [but] ... there is a good chance the change
 # actually was to UTC-11 back then.
 #
 # From Paul Eggert (2012-07-25)
 # A Google Books snippet of Appendix to the Journals of the House of
 # Representatives of New Zealand, Session 1948,
 # , page 65, says Tokelau
 # was "11 hours slow on G.M.T."  Go with Thorsen and assume Shanks & Pottenger
 # are off by an hour starting in 1901.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Fakaofo	-11:24:56 -	LMT	1901
 			-11:00	-	TKT 2011 Dec 30	# Tokelau Time
 			13:00	-	TKT
 
 # Tonga
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Tonga	1999	only	-	Oct	 7	2:00s	1:00	S
 Rule	Tonga	2000	only	-	Mar	19	2:00s	0	-
 Rule	Tonga	2000	2001	-	Nov	Sun>=1	2:00	1:00	S
 Rule	Tonga	2001	2002	-	Jan	lastSun	2:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Tongatapu	12:19:20 -	LMT	1901
 			12:20	-	TOT	1941 # Tonga Time
 			13:00	-	TOT	1999
 			13:00	Tonga	TO%sT
 
 # Tuvalu
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Funafuti	11:56:52 -	LMT	1901
 			12:00	-	TVT	# Tuvalu Time
 
 
 # US minor outlying islands
 
 # Howland, Baker
 # Howland was mined for guano by American companies 1857-1878 and British
 # 1886-1891; Baker was similar but exact dates are not known.
 # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944;
 # uninhabited thereafter.
 # Howland observed Hawaii Standard Time (UTC-10:30) in 1937;
 # see page 206 of Elgen M. Long and Marie K. Long,
 # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000).
 # So most likely Howland and Baker observed Hawaii Time from 1935
 # until they were abandoned after the war.
 
 # Jarvis
 # Mined for guano by American companies 1857-1879 and British 1883?-1891?.
 # Inhabited by civilians 1935-1942; IGY scientific base 1957-1958;
 # uninhabited thereafter.
 # no information; was probably like Pacific/Kiritimati
 
 # Johnston
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Pacific/Johnston	-10:00	-	HST
 
 # Kingman
 # uninhabited
 
 # Midway
 #
 # From Mark Brader (2005-01-23):
 # [Fallacies and Fantasies of Air Transport History, by R.E.G. Davies,
 # published 1994 by Paladwr Press, McLean, VA, USA; ISBN 0-9626483-5-3]
 # reproduced a Pan American Airways timeables from 1936, for their weekly
 # "Orient Express" flights between San Francisco and Manila, and connecting
 # flights to Chicago and the US East Coast.  As it uses some time zone
 # designations that I've never seen before:....
 # Fri. 6:30A Lv. HONOLOLU (Pearl Harbor), H.I.   H.L.T. Ar. 5:30P Sun.
 #  "   3:00P Ar. MIDWAY ISLAND . . . . . . . . . M.L.T. Lv. 6:00A  "
 #
 Zone Pacific/Midway	-11:49:28 -	LMT	1901
 			-11:00	-	NST	1956 Jun  3
 			-11:00	1:00	NDT	1956 Sep  2
 			-11:00	-	NST	1967 Apr	# N=Nome
 			-11:00	-	BST	1983 Nov 30	# B=Bering
 			-11:00	-	SST			# S=Samoa
 
 # Palmyra
 # uninhabited since World War II; was probably like Pacific/Kiritimati
 
 # Wake
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Wake	11:06:28 -	LMT	1901
 			12:00	-	WAKT	# Wake Time
 
 
 # Vanuatu
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Vanuatu	1983	only	-	Sep	25	0:00	1:00	S
 Rule	Vanuatu	1984	1991	-	Mar	Sun>=23	0:00	0	-
 Rule	Vanuatu	1984	only	-	Oct	23	0:00	1:00	S
 Rule	Vanuatu	1985	1991	-	Sep	Sun>=23	0:00	1:00	S
 Rule	Vanuatu	1992	1993	-	Jan	Sun>=23	0:00	0	-
 Rule	Vanuatu	1992	only	-	Oct	Sun>=23	0:00	1:00	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Efate	11:13:16 -	LMT	1912 Jan 13		# Vila
 			11:00	Vanuatu	VU%sT	# Vanuatu Time
 
 # Wallis and Futuna
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Pacific/Wallis	12:15:20 -	LMT	1901
 			12:00	-	WFT	# Wallis & Futuna Time
 
 ###############################################################################
 
 # NOTES
 
 # This data is by no means authoritative; if you think you know better,
 # go ahead and edit the file (and please send any changes to
 # tz@iana.org for general use in the future).
 
 # From Paul Eggert (2013-02-21):
 # A good source for time zone historical data outside the U.S. is
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 #
 # Gwillim Law writes that a good source
 # for recent time zone data is the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.
 #
 # Except where otherwise noted, Shanks & Pottenger is the source for
 # entries through 1990, and IATA SSIM is the source for entries afterwards.
 #
 # Another source occasionally used is Edward W. Whitman, World Time Differences,
 # Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
 # I found in the UCLA library.
 #
 # For data circa 1899, a common source is:
 # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
 # .
 #
 # A reliable and entertaining source about time zones is
 # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
 #
 # I invented the abbreviations marked `*' in the following table;
 # the rest are from earlier versions of this file, or from other sources.
 # Corrections are welcome!
 #		std dst
 #		LMT	Local Mean Time
 #	  8:00	WST WST	Western Australia
 #	  8:45	CWST CWST Central Western Australia*
 #	  9:00	JST	Japan
 #	  9:30	CST CST	Central Australia
 #	 10:00	EST EST	Eastern Australia
 #	 10:00	ChST	Chamorro
 #	 10:30	LHST LHST Lord Howe*
 #	 11:30	NZMT NZST New Zealand through 1945
 #	 12:00	NZST NZDT New Zealand 1946-present
 #	 12:45	CHAST CHADT Chatham*
 #	-11:00	SST	Samoa
 #	-10:00	HST	Hawaii
 #	- 8:00	PST	Pitcairn*
 #
 # See the `northamerica' file for Hawaii.
 # See the `southamerica' file for Easter I and the Galapagos Is.
 
 ###############################################################################
 
 # Australia
 
 # From Paul Eggert (2005-12-08):
 # 
 # Implementation Dates of Daylight Saving Time within Australia
 #  summarizes daylight saving issues in Australia.
 
 # From Arthur David Olson (2005-12-12):
 # 
 # Lawlink NSW:Daylight Saving in New South Wales
 #  covers New South Wales in particular.
 
 # From John Mackin (1991-03-06):
 # We in Australia have _never_ referred to DST as `daylight' time.
 # It is called `summer' time.  Now by a happy coincidence, `summer'
 # and `standard' happen to start with the same letter; hence, the
 # abbreviation does _not_ change...
 # The legislation does not actually define abbreviations, at least
 # in this State, but the abbreviation is just commonly taken to be the
 # initials of the phrase, and the legislation here uniformly uses
 # the phrase `summer time' and does not use the phrase `daylight
 # time'.
 # Announcers on the Commonwealth radio network, the ABC (for Australian
 # Broadcasting Commission), use the phrases `Eastern Standard Time'
 # or `Eastern Summer Time'.  (Note, though, that as I say in the
 # current australasia file, there is really no such thing.)  Announcers
 # on its overseas service, Radio Australia, use the same phrases
 # prefixed by the word `Australian' when referring to local times;
 # time announcements on that service, naturally enough, are made in UTC.
 
 # From Arthur David Olson (1992-03-08):
 # Given the above, what's chosen for year-round use is:
 #	CST	for any place operating at a GMTOFF of 9:30
 #	WST	for any place operating at a GMTOFF of 8:00
 #	EST	for any place operating at a GMTOFF of 10:00
 
 # From Chuck Soper (2006-06-01):
 # I recently found this Australian government web page on time zones:
 # 
 # And this government web page lists time zone names and abbreviations:
 # 
 
 # From Paul Eggert (2001-04-05), summarizing a long discussion about "EST"
 # versus "AEST" etc.:
 #
 # I see the following points of dispute:
 #
 # * How important are unique time zone abbreviations?
 #
 #   Here I tend to agree with the point (most recently made by Chris
 #   Newman) that unique abbreviations should not be essential for proper
 #   operation of software.  We have other instances of ambiguity
 #   (e.g. "IST" denoting both "Israel Standard Time" and "Indian
 #   Standard Time"), and they are not likely to go away any time soon.
 #   In the old days, some software mistakenly relied on unique
 #   abbreviations, but this is becoming less true with time, and I don't
 #   think it's that important to cater to such software these days.
 #
 #   On the other hand, there is another motivation for unambiguous
 #   abbreviations: it cuts down on human confusion.  This is
 #   particularly true for Australia, where "EST" can mean one thing for
 #   time T and a different thing for time T plus 1 second.
 #
 # * Does the relevant legislation indicate which abbreviations should be used?
 #
 #   Here I tend to think that things are a mess, just as they are in
 #   many other countries.  We Americans are currently disagreeing about
 #   which abbreviation to use for the newly legislated Chamorro Standard
 #   Time, for example.
 #
 #   Personally, I would prefer to use common practice; I would like to
 #   refer to legislation only for examples of common practice, or as a
 #   tiebreaker.
 #
 # * Do Australians more often use "Eastern Daylight Time" or "Eastern
 #   Summer Time"?  Do they typically prefix the time zone names with
 #   the word "Australian"?
 #
 #   My own impression is that both "Daylight Time" and "Summer Time" are
 #   common and are widely understood, but that "Summer Time" is more
 #   popular; and that the leading "A" is also common but is omitted more
 #   often than not.  I just used AltaVista advanced search and got the
 #   following count of page hits:
 #
 #     1,103 "Eastern Summer Time" AND domain:au
 #       971 "Australian Eastern Summer Time" AND domain:au
 #       613 "Eastern Daylight Time" AND domain:au
 #       127 "Australian Eastern Daylight Time" AND domain:au
 #
 #   Here "Summer" seems quite a bit more popular than "Daylight",
 #   particularly when we know the time zone is Australian and not US,
 #   say.  The "Australian" prefix seems to be popular for Eastern Summer
 #   Time, but unpopular for Eastern Daylight Time.
 #
 #   For abbreviations, tools like AltaVista are less useful because of
 #   ambiguity.  Many hits are not really time zones, unfortunately, and
 #   many hits denote US time zones and not Australian ones.  But here
 #   are the hit counts anyway:
 #
 #     161,304 "EST" and domain:au
 #      25,156 "EDT" and domain:au
 #      18,263 "AEST" and domain:au
 #      10,416 "AEDT" and domain:au
 #
 #      14,538 "CST" and domain:au
 #       5,728 "CDT" and domain:au
 #         176 "ACST" and domain:au
 #          29 "ACDT" and domain:au
 #
 #       7,539 "WST" and domain:au
 #          68 "AWST" and domain:au
 #
 #   This data suggest that Australians tend to omit the "A" prefix in
 #   practice.  The situation for "ST" versus "DT" is less clear, given
 #   the ambiguities involved.
 #
 # * How do Australians feel about the abbreviations in the tz database?
 #
 #   If you just count Australians on this list, I count 2 in favor and 3
 #   against.  One of the "against" votes (David Keegel) counseled delay,
 #   saying that both AEST/AEDT and EST/EST are widely used and
 #   understood in Australia.
 
 # From Paul Eggert (1995-12-19):
 # Shanks & Pottenger report 2:00 for all autumn changes in Australia and NZ.
 # Mark Prior writes that his newspaper
 # reports that NSW's fall 1995 change will occur at 2:00,
 # but Robert Elz says it's been 3:00 in Victoria since 1970
 # and perhaps the newspaper's `2:00' is referring to standard time.
 # For now we'll continue to assume 2:00s for changes since 1960.
 
 # From Eric Ulevik (1998-01-05):
 #
 # Here are some URLs to Australian time legislation. These URLs are stable,
 # and should probably be included in the data file. There are probably more
 # relevant entries in this database.
 #
 # NSW (including LHI and Broken Hill):
 # 
 # Standard Time Act 1987 (updated 1995-04-04)
 # 
 # ACT
 # 
 # Standard Time and Summer Time Act 1972
 # 
 # SA
 # 
 # Standard Time Act, 1898
 # 
 
 # From David Grosz (2005-06-13):
 # It was announced last week that Daylight Saving would be extended by
 # one week next year to allow for the 2006 Commonwealth Games.
 # Daylight Saving is now to end for next year only on the first Sunday
 # in April instead of the last Sunday in March.
 #
 # From Gwillim Law (2005-06-14):
 # I did some Googling and found that all of those states (and territory) plan
 # to extend DST together in 2006.
 # ACT: http://www.cmd.act.gov.au/mediareleases/fileread.cfm?file=86.txt
 # New South Wales: http://www.thecouriermail.news.com.au/common/story_page/0,5936,15538869%255E1702,00.html
 # South Australia: http://www.news.com.au/story/0,10117,15555031-1246,00.html
 # Tasmania: http://www.media.tas.gov.au/release.php?id=14772
 # Victoria: I wasn't able to find anything separate, but the other articles
 # allude to it.
 # But not Queensland
 # http://www.news.com.au/story/0,10117,15564030-1248,00.html.
 
 # Northern Territory
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # # The NORTHERN TERRITORY..  [ Courtesy N.T. Dept of the Chief Minister ]
 # #					[ Nov 1990 ]
 # #	N.T. have never utilised any DST due to sub-tropical/tropical location.
 # ...
 # Zone        Australia/North         9:30    -       CST
 
 # From Bradley White (1991-03-04):
 # A recent excerpt from an Australian newspaper...
 # the Northern Territory do[es] not have daylight saving.
 
 # Western Australia
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # #  The state of WESTERN AUSTRALIA..  [ Courtesy W.A. dept Premier+Cabinet ]
 # #						[ Nov 1990 ]
 # #	W.A. suffers from a great deal of public and political opposition to
 # #	DST in principle. A bill is brought before parliament in most years, but
 # #	usually defeated either in the upper house, or in party caucus
 # #	before reaching parliament.
 # ...
 # Zone	Australia/West		8:00	AW	%sST
 # ...
 # Rule	AW	1974	only	-	Oct	lastSun	2:00	1:00	D
 # Rule	AW	1975	only	-	Mar	Sun>=1	3:00	0	W
 # Rule	AW	1983	only	-	Oct	lastSun	2:00	1:00	D
 # Rule	AW	1984	only	-	Mar	Sun>=1	3:00	0	W
 
 # From Bradley White (1991-03-04):
 # A recent excerpt from an Australian newspaper...
 # Western Australia...do[es] not have daylight saving.
 
 # From John D. Newman via Bradley White (1991-11-02):
 # Western Australia is still on "winter time". Some DH in Sydney
 # rang me at home a few days ago at 6.00am. (He had just arrived at
 # work at 9.00am.)
 # W.A. is switching to Summer Time on Nov 17th just to confuse
 # everybody again.
 
 # From Arthur David Olson (1992-03-08):
 # The 1992 ending date used in the rules is a best guess;
 # it matches what was used in the past.
 
 # 
 # The Australian Bureau of Meteorology FAQ
 #  (1999-09-27) writes that Giles Meteorological Station uses
 # South Australian time even though it's located in Western Australia.
 
 # Queensland
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # #   The state of QUEENSLAND.. [ Courtesy Qld. Dept Premier Econ&Trade Devel ]
 # #						[ Dec 1990 ]
 # ...
 # Zone	Australia/Queensland	10:00	AQ	%sST
 # ...
 # Rule	AQ	1971	only	-	Oct	lastSun	2:00	1:00	D
 # Rule	AQ	1972	only	-	Feb	lastSun	3:00	0	E
 # Rule	AQ	1989	max	-	Oct	lastSun	2:00	1:00	D
 # Rule	AQ	1990	max	-	Mar	Sun>=1	3:00	0	E
 
 # From Bradley White (1989-12-24):
 # "Australia/Queensland" now observes daylight time (i.e. from
 # October 1989).
 
 # From Bradley White (1991-03-04):
 # A recent excerpt from an Australian newspaper...
 # ...Queensland...[has] agreed to end daylight saving
 # at 3am tomorrow (March 3)...
 
 # From John Mackin (1991-03-06):
 # I can certainly confirm for my part that Daylight Saving in NSW did in fact
 # end on Sunday, 3 March.  I don't know at what hour, though.  (It surprised
 # me.)
 
 # From Bradley White (1992-03-08):
 # ...there was recently a referendum in Queensland which resulted
 # in the experimental daylight saving system being abandoned. So, ...
 # ...
 # Rule	QLD	1989	1991	-	Oct	lastSun	2:00	1:00	D
 # Rule	QLD	1990	1992	-	Mar	Sun>=1	3:00	0	S
 # ...
 
 # From Arthur David Olson (1992-03-08):
 # The chosen rules the union of the 1971/1972 change and the 1989-1992 changes.
 
 # From Christopher Hunt (2006-11-21), after an advance warning
 # from Jesper Norgaard Welen (2006-11-01):
 # WA are trialing DST for three years.
 # 
 
 # From Rives McDow (2002-04-09):
 # The most interesting region I have found consists of three towns on the
 # southern coast....  South Australia observes daylight saving time; Western
 # Australia does not.  The two states are one and a half hours apart.  The
 # residents decided to forget about this nonsense of changing the clock so
 # much and set the local time 20 hours and 45 minutes from the
 # international date line, or right in the middle of the time of South
 # Australia and Western Australia....
 #
 # From Paul Eggert (2002-04-09):
 # This is confirmed by the section entitled
 # "What's the deal with time zones???" in
 # .
 #
 # From Alex Livingston (2006-12-07):
 # ... it was just on four years ago that I drove along the Eyre Highway,
 # which passes through eastern Western Australia close to the southern
 # coast of the continent.
 #
 # I paid particular attention to the time kept there. There can be no
 # dispute that UTC+08:45 was considered "the time" from the border
 # village just inside the border with South Australia to as far west
 # as just east of Caiguna. There can also be no dispute that Eucla is
 # the largest population centre in this zone....
 #
 # Now that Western Australia is observing daylight saving, the
 # question arose whether this part of the state would follow suit. I
 # just called the border village and confirmed that indeed they have,
 # meaning that they are now observing UTC+09:45.
 #
 # (2006-12-09):
 # I personally doubt that either experimentation with daylight saving
 # in WA or its introduction in SA had anything to do with the genesis
 # of this time zone.  My hunch is that it's been around since well
 # before 1975.  I remember seeing it noted on road maps decades ago.
 
 # From Paul Eggert (2006-12-15):
 # For lack of better info, assume the tradition dates back to the
 # introduction of standard time in 1895.
 
 
 # southeast Australia
 #
 # From Paul Eggert (2007-07-23):
 # Starting autumn 2008 Victoria, NSW, South Australia, Tasmania and the ACT
 # end DST the first Sunday in April and start DST the first Sunday in October.
 # http://www.theage.com.au/news/national/daylight-savings-to-span-six-months/2007/06/27/1182623966703.html
 
 
 # South Australia
 
 # From Bradley White (1991-03-04):
 # A recent excerpt from an Australian newspaper...
 # ...South Australia...[has] agreed to end daylight saving
 # at 3am tomorrow (March 3)...
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # #   The state of SOUTH AUSTRALIA....[ Courtesy of S.A. Dept of Labour ]
 # #						[ Nov 1990 ]
 # ...
 # Zone	Australia/South		9:30	AS	%sST
 # ...
 # Rule	 AS	1971	max	-	Oct	lastSun	2:00	1:00	D
 # Rule	 AS	1972	1985	-	Mar	Sun>=1	3:00	0	C
 # Rule	 AS	1986	1990	-	Mar	Sun>=15	3:00	0	C
 # Rule	 AS	1991	max	-	Mar	Sun>=1	3:00	0	C
 
 # From Bradley White (1992-03-11):
 # Recent correspondence with a friend in Adelaide
 # contained the following exchange:  "Due to the Adelaide Festival,
 # South Australia delays setting back our clocks for a few weeks."
 
 # From Robert Elz (1992-03-13):
 # I heard that apparently (or at least, it appears that)
 # South Aus will have an extra 3 weeks daylight saving every even
 # numbered year (from 1990).  That's when the Adelaide Festival
 # is on...
 
 # From Robert Elz (1992-03-16, 00:57:07 +1000):
 # DST didn't end in Adelaide today (yesterday)....
 # But whether it's "4th Sunday" or "2nd last Sunday" I have no idea whatever...
 # (it's just as likely to be "the Sunday we pick for this year"...).
 
 # From Bradley White (1994-04-11):
 # If Sun, 15 March, 1992 was at +1030 as kre asserts, but yet Sun, 20 March,
 # 1994 was at +0930 as John Connolly's customer seems to assert, then I can
 # only conclude that the actual rule is more complicated....
 
 # From John Warburton (1994-10-07):
 # The new Daylight Savings dates for South Australia ...
 # was gazetted in the Government Hansard on Sep 26 1994....
 # start on last Sunday in October and end in last sunday in March.
 
 # From Paul Eggert (2007-07-23):
 # See "southeast Australia" above for 2008 and later.
 
 # Tasmania
 
 # The rules for 1967 through 1991 were reported by George Shepherd
 # via Simon Woodhead via Robert Elz (1991-03-06):
 # #  The state of TASMANIA.. [Courtesy Tasmanian Dept of Premier + Cabinet ]
 # #					[ Nov 1990 ]
 
 # From Bill Hart via Guy Harris (1991-10-10):
 # Oh yes, the new daylight savings rules are uniquely tasmanian, we have
 # 6 weeks a year now when we are out of sync with the rest of Australia
 # (but nothing new about that).
 
 # From Alex Livingston (1999-10-04):
 # I heard on the ABC (Australian Broadcasting Corporation) radio news on the
 # (long) weekend that Tasmania, which usually goes its own way in this regard,
 # has decided to join with most of NSW, the ACT, and most of Victoria
 # (Australia) and start daylight saving on the last Sunday in August in 2000
 # instead of the first Sunday in October.
 
 # Sim Alam (2000-07-03) reported a legal citation for the 2000/2001 rules:
 # http://www.thelaw.tas.gov.au/fragview/42++1968+GS3A@EN+2000070300
 
 # From Paul Eggert (2007-07-23):
 # See "southeast Australia" above for 2008 and later.
 
 # Victoria
 
 # The rules for 1971 through 1991 were reported by George Shepherd
 # via Simon Woodhead via Robert Elz (1991-03-06):
 # #   The state of VICTORIA.. [ Courtesy of Vic. Dept of Premier + Cabinet ]
 # #						[ Nov 1990 ]
 
 # From Scott Harrington (2001-08-29):
 # On KQED's "City Arts and Lectures" program last night I heard an
 # interesting story about daylight savings time.  Dr. John Heilbron was
 # discussing his book "The Sun in the Church: Cathedrals as Solar
 # Observatories"[1], and in particular the Shrine of Remembrance[2] located
 # in Melbourne, Australia.
 #
 # Apparently the shrine's main purpose is a beam of sunlight which
 # illuminates a special spot on the floor at the 11th hour of the 11th day
 # of the 11th month (Remembrance Day) every year in memory of Australia's
 # fallen WWI soldiers.  And if you go there on Nov. 11, at 11am local time,
 # you will indeed see the sunbeam illuminate the special spot at the
 # expected time.
 #
 # However, that is only because of some special mirror contraption that had
 # to be employed, since due to daylight savings time, the true solar time of
 # the remembrance moment occurs one hour later (or earlier?).  Perhaps
 # someone with more information on this jury-rig can tell us more.
 #
 # [1] http://www.hup.harvard.edu/catalog/HEISUN.html
 # [2] http://www.shrine.org.au
 
 # From Paul Eggert (2007-07-23):
 # See "southeast Australia" above for 2008 and later.
 
 # New South Wales
 
 # From Arthur David Olson:
 # New South Wales and subjurisdictions have their own ideas of a fun time.
 # Based on law library research by John Mackin,
 # who notes:
 #	In Australia, time is not legislated federally, but rather by the
 #	individual states.  Thus, while such terms as ``Eastern Standard Time''
 #	[I mean, of course, Australian EST, not any other kind] are in common
 #	use, _they have NO REAL MEANING_, as they are not defined in the
 #	legislation.  This is very important to understand.
 #	I have researched New South Wales time only...
 
 # From Eric Ulevik (1999-05-26):
 # DST will start in NSW on the last Sunday of August, rather than the usual
 # October in 2000.  [See: Matthew Moore,
 # 
 # Two months more daylight saving
 # 
 # Sydney Morning Herald (1999-05-26).]
 
 # From Paul Eggert (1999-09-27):
 # See the following official NSW source:
 # 
 # Daylight Saving in New South Wales.
 # 
 #
 # Narrabri Shire (NSW) council has announced it will ignore the extension of
 # daylight saving next year.  See:
 # 
 # Narrabri Council to ignore daylight saving
 #  (1999-07-22).  For now, we'll wait to see if this really happens.
 #
 # Victoria will following NSW.  See:
 # 
 # Vic to extend daylight saving
 #  (1999-07-28).
 #
 # However, South Australia rejected the DST request.  See:
 # 
 # South Australia rejects Olympics daylight savings request
 #  (1999-07-19).
 #
 # Queensland also will not observe DST for the Olympics.  See:
 # 
 # Qld says no to daylight savings for Olympics
 #  (1999-06-01), which quotes Queensland Premier Peter Beattie as saying
 # ``Look you've got to remember in my family when this came up last time
 # I voted for it, my wife voted against it and she said to me it's all very
 # well for you, you don't have to worry about getting the children out of
 # bed, getting them to school, getting them to sleep at night.
 # I've been through all this argument domestically...my wife rules.''
 #
 # Broken Hill will stick with South Australian time in 2000.  See:
 # 
 # Broken Hill to be behind the times
 #  (1999-07-21).
 
 # IATA SSIM (1998-09) says that the spring 2000 change for Australian
 # Capital Territory, New South Wales except Lord Howe Island and Broken
 # Hill, and Victoria will be August 27, presumably due to the Sydney Olympics.
 
 # From Eric Ulevik, referring to Sydney's Sun Herald (2000-08-13), page 29:
 # The Queensland Premier Peter Beattie is encouraging northern NSW
 # towns to use Queensland time.
 
 # From Paul Eggert (2007-07-23):
 # See "southeast Australia" above for 2008 and later.
 
 # Yancowinna
 
 # From John Mackin (1989-01-04):
 # `Broken Hill' means the County of Yancowinna.
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # # YANCOWINNA..  [ Confirmation courtesy of Broken Hill Postmaster ]
 # #					[ Dec 1990 ]
 # ...
 # # Yancowinna uses Central Standard Time, despite [its] location on the
 # # New South Wales side of the S.A. border. Most business and social dealings
 # # are with CST zones, therefore CST is legislated by local government
 # # although the switch to Summer Time occurs in line with N.S.W. There have
 # # been years when this did not apply, but the historical data is not
 # # presently available.
 # Zone	Australia/Yancowinna	9:30	 AY	%sST
 # ...
 # Rule	 AY	1971	1985	-	Oct	lastSun	2:00	1:00	D
 # Rule	 AY	1972	only	-	Feb	lastSun	3:00	0	C
 # [followed by other Rules]
 
 # Lord Howe Island
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # LHI...		[ Courtesy of Pauline Van Winsen ]
 #					[ Dec 1990 ]
 # Lord Howe Island is located off the New South Wales coast, and is half an
 # hour ahead of NSW time.
 
 # From James Lonergan, Secretary, Lord Howe Island Board (2000-01-27):
 # Lord Howe Island summer time in 2000/2001 will commence on the same
 # date as the rest of NSW (i.e. 2000-08-27).  For your information the
 # Lord Howe Island Board (controlling authority for the Island) is
 # seeking the community's views on various options for summer time
 # arrangements on the Island, e.g. advance clocks by 1 full hour
 # instead of only 30 minutes.  [Dependent] on the wishes of residents
 # the Board may approach the NSW government to change the existing
 # arrangements.  The starting date for summer time on the Island will
 # however always coincide with the rest of NSW.
 
 # From James Lonergan, Secretary, Lord Howe Island Board (2000-10-25):
 # Lord Howe Island advances clocks by 30 minutes during DST in NSW and retards
 # clocks by 30 minutes when DST finishes. Since DST was most recently
 # introduced in NSW, the "changeover" time on the Island has been 02:00 as
 # shown on clocks on LHI. I guess this means that for 30 minutes at the start
 # of DST, LHI is actually 1 hour ahead of the rest of NSW.
 
 # From Paul Eggert (2006-03-22):
 # For Lord Howe dates we use Shanks & Pottenger through 1989, and
 # Lonergan thereafter.  For times we use Lonergan.
 
 # From Paul Eggert (2007-07-23):
 # See "southeast Australia" above for 2008 and later.
 
 # From Steffen Thorsen (2009-04-28):
 # According to the official press release, South Australia's extended daylight
 # saving period will continue with the same rules as used during the 2008-2009
 # summer (southern hemisphere).
 #
 # From
 # 
 # http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf
 # 
 # The extended daylight saving period that South Australia has been trialling
 # for over the last year is now set to be ongoing.
 # Daylight saving will continue to start on the first Sunday in October each
 # year and finish on the first Sunday in April the following year.
 # Industrial Relations Minister, Paul Caica, says this provides South Australia
 # with a consistent half hour time difference with NSW, Victoria, Tasmania and
 # the ACT for all 52 weeks of the year...
 #
 # We have a wrap-up here:
 # 
 # http://www.timeanddate.com/news/time/south-australia-extends-dst.html
 # 
 ###############################################################################
 
 # New Zealand
 
 # From Mark Davies (1990-10-03):
 # the 1989/90 year was a trial of an extended "daylight saving" period.
 # This trial was deemed successful and the extended period adopted for
 # subsequent years (with the addition of a further week at the start).
 # source -- phone call to Ministry of Internal Affairs Head Office.
 
 # From George Shepherd via Simon Woodhead via Robert Elz (1991-03-06):
 # # The Country of New Zealand   (Australia's east island -) Gee they hate that!
 # #				   or is Australia the west island of N.Z.
 # #	[ courtesy of Geoff Tribble.. Auckland N.Z. ]
 # #				[ Nov 1990 ]
 # ...
 # Rule	NZ      1974    1988	-	Oct	lastSun	2:00	1:00	D
 # Rule	NZ	1989	max	-	Oct	Sun>=1	2:00	1:00	D
 # Rule	NZ      1975    1989	-	Mar	Sun>=1	3:00	0	S
 # Rule	NZ	1990	max	-	Mar	lastSun	3:00	0	S
 # ...
 # Zone	NZ			12:00	NZ		NZ%sT	# New Zealand
 # Zone	NZ-CHAT			12:45	-		NZ-CHAT # Chatham Island
 
 # From Arthur David Olson (1992-03-08):
 # The chosen rules use the Davies October 8 values for the start of DST in 1989
 # rather than the October 1 value.
 
 # From Paul Eggert (1995-12-19);
 # Shank & Pottenger report 2:00 for all autumn changes in Australia and NZ.
 # Robert Uzgalis writes that the New Zealand Daylight
 # Savings Time Order in Council dated 1990-06-18 specifies 2:00 standard
 # time on both the first Sunday in October and the third Sunday in March.
 # As with Australia, we'll assume the tradition is 2:00s, not 2:00.
 #
 # From Paul Eggert (2006-03-22):
 # The Department of Internal Affairs (DIA) maintains a brief history,
 # as does Carol Squires; see tz-link.htm for the full references.
 # Use these sources in preference to Shanks & Pottenger.
 #
 # For Chatham, IATA SSIM (1991/1999) gives the NZ rules but with
 # transitions at 2:45 local standard time; this confirms that Chatham
 # is always exactly 45 minutes ahead of Auckland.
 
 # From Colin Sharples (2007-04-30):
 # DST will now start on the last Sunday in September, and end on the
 # first Sunday in April.  The changes take effect this year, meaning
 # that DST will begin on 2007-09-30 2008-04-06.
 # http://www.dia.govt.nz/diawebsite.nsf/wpg_URL/Services-Daylight-Saving-Daylight-saving-to-be-extended
 
 ###############################################################################
 
 
 # Fiji
 
 # Howse writes (p 153) that in 1879 the British governor of Fiji
 # enacted an ordinance standardizing the islands on Antipodean Time
 # instead of the American system (which was one day behind).
 
 # From Rives McDow (1998-10-08):
 # Fiji will introduce DST effective 0200 local time, 1998-11-01
 # until 0300 local time 1999-02-28.  Each year the DST period will
 # be from the first Sunday in November until the last Sunday in February.
 
 # From Paul Eggert (2000-01-08):
 # IATA SSIM (1999-09) says DST ends 0100 local time.  Go with McDow.
 
 # From the BBC World Service (1998-10-31 11:32 UTC):
 # The Fijiian government says the main reasons for the time change is to
 # improve productivity and reduce road accidents.  But correspondents say it
 # also hopes the move will boost Fiji's ability to compete with other pacific
 # islands in the effort to attract tourists to witness the dawning of the new
 # millenium.
 
 # http://www.fiji.gov.fj/press/2000_09/2000_09_13-05.shtml (2000-09-13)
 # reports that Fiji has discontinued DST.
 
 # Johnston
 
 # Johnston data is from usno1995.
 
 
 # Kiribati
 
 # From Paul Eggert (1996-01-22):
 # Today's _Wall Street Journal_ (page 1) reports that Kiribati
 # ``declared it the same day [throughout] the country as of Jan. 1, 1995''
 # as part of the competition to be first into the 21st century.
 
 
 # Kwajalein
 
 # In comp.risks 14.87 (26 August 1993), Peter Neumann writes:
 # I wonder what happened in Kwajalein, where there was NO Friday,
 # 1993-08-20.  Thursday night at midnight Kwajalein switched sides with
 # respect to the International Date Line, to rejoin its fellow islands,
 # going from 11:59 p.m. Thursday to 12:00 m. Saturday in a blink.
 
 
 # N Mariana Is, Guam
 
 # Howse writes (p 153) ``The Spaniards, on the other hand, reached the
 # Philippines and the Ladrones from America,'' and implies that the Ladrones
 # (now called the Marianas) kept American date for quite some time.
 # For now, we assume the Ladrones switched at the same time as the Philippines;
 # see Asia/Manila.
 
 # US Public Law 106-564 (2000-12-23) made UTC+10 the official standard time,
 # under the name "Chamorro Standard Time".  There is no official abbreviation,
 # but Congressman Robert A. Underwood, author of the bill that became law,
 # wrote in a press release (2000-12-27) that he will seek the use of "ChST".
 
 
 # Micronesia
 
 # Alan Eugene Davis writes (1996-03-16),
 # ``I am certain, having lived there for the past decade, that "Truk"
 # (now properly known as Chuuk) ... is in the time zone GMT+10.''
 #
 # Shanks & Pottenger write that Truk switched from UTC+10 to UTC+11
 # on 1978-10-01; ignore this for now.
 
 # From Paul Eggert (1999-10-29):
 # The Federated States of Micronesia Visitors Board writes in
 # 
 # The Federated States of Micronesia - Visitor Information
 #  (1999-01-26)
 # that Truk and Yap are UTC+10, and Ponape and Kosrae are UTC+11.
 # We don't know when Kosrae switched from UTC+12; assume January 1 for now.
 
 
 # Midway
 
 # From Charles T O'Connor, KMTH DJ (1956),
 # quoted in the KTMH section of the Radio Heritage Collection
 #  (2002-12-31):
 # For the past two months we've been on what is known as Daylight
 # Saving Time.  This time has put us on air at 5am in the morning,
 # your time down there in New Zealand.  Starting September 2, 1956
 # we'll again go back to Standard Time.  This'll mean that we'll go to
 # air at 6am your time.
 #
 # From Paul Eggert (2003-03-23):
 # We don't know the date of that quote, but we'll guess they
 # started DST on June 3.  Possibly DST was observed other years
 # in Midway, but we have no record of it.
 
 
 # Pitcairn
 
 # From Rives McDow (1999-11-08):
 # A Proclamation was signed by the Governor of Pitcairn on the 27th March 1998
 # with regard to Pitcairn Standard Time.  The Proclamation is as follows.
 #
 #	The local time for general purposes in the Islands shall be
 #	Co-ordinated Universal time minus 8 hours and shall be known
 #	as Pitcairn Standard Time.
 #
 # ... I have also seen Pitcairn listed as UTC minus 9 hours in several
 # references, and can only assume that this was an error in interpretation
 # somehow in light of this proclamation.
 
 # From Rives McDow (1999-11-09):
 # The Proclamation regarding Pitcairn time came into effect on 27 April 1998
 # ... at midnight.
 
 # From Howie Phelps (1999-11-10), who talked to a Pitcairner via shortwave:
 # Betty Christian told me yesterday that their local time is the same as
 # Pacific Standard Time. They used to be 1/2 hour different from us here in
 # Sacramento but it was changed a couple of years ago.
 
 
 # Samoa
 
 # Howse writes (p 153, citing p 10 of the 1883-11-18 New York Herald)
 # that in 1879 the King of Samoa decided to change
 # ``the date in his kingdom from the Antipodean to the American system,
 # ordaining -- by a masterpiece of diplomatic flattery -- that
 # the Fourth of July should be celebrated twice in that year.''
 
 
 # Tonga
 
 # From Paul Eggert (1996-01-22):
 # Today's _Wall Street Journal_ (p 1) reports that ``Tonga has been plotting
 # to sneak ahead of [New Zealanders] by introducing daylight-saving time.''
 # Since Kiribati has moved the Date Line it's not clear what Tonga will do.
 
 # Don Mundell writes in the 1997-02-20 Tonga Chronicle
 # 
 # How Tonga became `The Land where Time Begins'
 # :
 
 # Until 1941 Tonga maintained a standard time 50 minutes ahead of NZST
 # 12 hours and 20 minutes ahead of GMT.  When New Zealand adjusted its
 # standard time in 1940s, Tonga had the choice of subtracting from its
 # local time to come on the same standard time as New Zealand or of
 # advancing its time to maintain the differential of 13 degrees
 # (approximately 50 minutes ahead of New Zealand time).
 #
 # Because His Majesty King Taufa'ahau Tupou IV, then Crown Prince
 # Tungi, preferred to ensure Tonga's title as the land where time
 # begins, the Legislative Assembly approved the latter change.
 #
 # But some of the older, more conservative members from the outer
 # islands objected. "If at midnight on Dec. 31, we move ahead 40
 # minutes, as your Royal Highness wishes, what becomes of the 40
 # minutes we have lost?"
 #
 # The Crown Prince, presented an unanswerable argument: "Remember that
 # on the World Day of Prayer, you would be the first people on Earth
 # to say your prayers in the morning."
 
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger say the transition was on 1968-10-01; go with Mundell.
 
 # From Eric Ulevik (1999-05-03):
 # Tonga's director of tourism, who is also secretary of the National Millenium
 # Committee, has a plan to get Tonga back in front.
 # He has proposed a one-off move to tropical daylight saving for Tonga from
 # October to March, which has won approval in principle from the Tongan
 # Government.
 
 # From Steffen Thorsen (1999-09-09):
 # * Tonga will introduce DST in November
 #
 # I was given this link by John Letts:
 # 
 # http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm
 # 
 #
 # I have not been able to find exact dates for the transition in November
 # yet. By reading this article it seems like Fiji will be 14 hours ahead
 # of UTC as well, but as far as I know Fiji will only be 13 hours ahead
 # (12 + 1 hour DST).
 
 # From Arthur David Olson (1999-09-20):
 # According to 
 # http://www.tongaonline.com/news/sept1799.html
 # :
 # "Daylight Savings Time will take effect on Oct. 2 through April 15, 2000
 # and annually thereafter from the first Saturday in October through the
 # third Saturday of April.  Under the system approved by Privy Council on
 # Sept. 10, clocks must be turned ahead one hour on the opening day and
 # set back an hour on the closing date."
 # Alas, no indication of the time of day.
 
 # From Rives McDow (1999-10-06):
 # Tonga started its Daylight Saving on Saturday morning October 2nd at 0200am.
 # Daylight Saving ends on April 16 at 0300am which is Sunday morning.
 
 # From Steffen Thorsen (2000-10-31):
 # Back in March I found a notice on the website http://www.tongaonline.com
 # that Tonga changed back to standard time one month early, on March 19
 # instead of the original reported date April 16. Unfortunately, the article
 # is no longer available on the site, and I did not make a copy of the
 # text, and I have forgotten to report it here.
 # (Original URL was: http://www.tongaonline.com/news/march162000.htm )
 
 # From Rives McDow (2000-12-01):
 # Tonga is observing DST as of 2000-11-04 and will stop on 2001-01-27.
 
 # From Sione Moala-Mafi (2001-09-20) via Rives McDow:
 # At 2:00am on the first Sunday of November, the standard time in the Kingdom
 # shall be moved forward by one hour to 3:00am.  At 2:00am on the last Sunday
 # of January the standard time in the Kingdom shall be moved backward by one
 # hour to 1:00am.
 
 # From Pulu 'Anau (2002-11-05):
 # The law was for 3 years, supposedly to get renewed.  It wasn't.
 
 
 # Wake
 
 # From Vernice Anderson, Personal Secretary to Philip Jessup,
 # US Ambassador At Large (oral history interview, 1971-02-02):
 #
 # Saturday, the 14th [of October, 1950] -- ...  The time was all the
 # more confusing at that point, because we had crossed the
 # International Date Line, thus getting two Sundays.  Furthermore, we
 # discovered that Wake Island had two hours of daylight saving time
 # making calculation of time in Washington difficult if not almost
 # impossible.
 #
 # http://www.trumanlibrary.org/wake/meeting.htm
 
 # From Paul Eggert (2003-03-23):
 # We have no other report of DST in Wake Island, so omit this info for now.
 
 ###############################################################################
 
 # The International Date Line
 
 # From Gwillim Law (2000-01-03):
 #
 # The International Date Line is not defined by any international standard,
 # convention, or treaty.  Mapmakers are free to draw it as they please.
 # Reputable mapmakers will simply ensure that every point of land appears on
 # the correct side of the IDL, according to the date legally observed there.
 #
 # When Kiribati adopted a uniform date in 1995, thereby moving the Phoenix and
 # Line Islands to the west side of the IDL (or, if you prefer, moving the IDL
 # to the east side of the Phoenix and Line Islands), I suppose that most
 # mapmakers redrew the IDL following the boundary of Kiribati.  Even that line
 # has a rather arbitrary nature.  The straight-line boundaries between Pacific
 # island nations that are shown on many maps are based on an international
 # convention, but are not legally binding national borders.... The date is
 # governed by the IDL; therefore, even on the high seas, there may be some
 # places as late as fourteen hours later than UTC.  And, since the IDL is not
 # an international standard, there are some places on the high seas where the
 # correct date is ambiguous.
 
 # From Wikipedia  (2005-08-31):
 # Before 1920, all ships kept local apparent time on the high seas by setting
 # their clocks at night or at the morning sight so that, given the ship's
 # speed and direction, it would be 12 o'clock when the Sun crossed the ship's
 # meridian (12 o'clock = local apparent noon).  During 1917, at the
 # Anglo-French Conference on Time-keeping at Sea, it was recommended that all
 # ships, both military and civilian, should adopt hourly standard time zones
 # on the high seas.  Whenever a ship was within the territorial waters of any
 # nation it would use that nation's standard time.  The captain was permitted
 # to change his ship's clocks at a time of his choice following his ship's
 # entry into another zone time--he often chose midnight.  These zones were
 # adopted by all major fleets between 1920 and 1925 but not by many
 # independent merchant ships until World War II.
 
 # From Paul Eggert, using references suggested by Oscar van Vlijmen
 # (2005-03-20):
 #
 # The American Practical Navigator (2002)
 # 
 # talks only about the 180-degree meridian with respect to ships in
 # international waters; it ignores the international date line.
Index: user/attilio/vmcontention/contrib/tzdata/southamerica
===================================================================
--- user/attilio/vmcontention/contrib/tzdata/southamerica	(revision 249698)
+++ user/attilio/vmcontention/contrib/tzdata/southamerica	(revision 249699)
@@ -1,1727 +1,1727 @@
 # 
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
 # This data is by no means authoritative; if you think you know better,
 # go ahead and edit the file (and please send any changes to
 # tz@iana.org for general use in the future).
 
 # From Paul Eggert (2006-03-22):
 # A good source for time zone historical data outside the U.S. is
 # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
 # San Diego: ACS Publications, Inc. (2003).
 #
 # For data circa 1899, a common source is:
 # Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
 # .
 #
 # Gwillim Law writes that a good source
 # for recent time zone data is the International Air Transport
 # Association's Standard Schedules Information Manual (IATA SSIM),
 # published semiannually.  Law sent in several helpful summaries
 # of the IATA's data after 1990.
 #
 # Except where otherwise noted, Shanks & Pottenger is the source for
 # entries through 1990, and IATA SSIM is the source for entries afterwards.
 #
 # Earlier editions of these tables used the North American style (e.g. ARST and
 # ARDT for Argentine Standard and Daylight Time), but the following quote
 # suggests that it's better to use European style (e.g. ART and ARST).
 #	I suggest the use of _Summer time_ instead of the more cumbersome
 #	_daylight-saving time_.  _Summer time_ seems to be in general use
 #	in Europe and South America.
 #	-- E O Cutler, _New York Times_ (1937-02-14), quoted in
 #	H L Mencken, _The American Language: Supplement I_ (1960), p 466
 #
 # Earlier editions of these tables also used the North American style
 # for time zones in Brazil, but this was incorrect, as Brazilians say
 # "summer time".  Reinaldo Goulart, a Sao Paulo businessman active in
 # the railroad sector, writes (1999-07-06):
 #	The subject of time zones is currently a matter of discussion/debate in
 #	Brazil.  Let's say that "the Brasilia time" is considered the
 #	"official time" because Brasilia is the capital city.
 #	The other three time zones are called "Brasilia time "minus one" or
 #	"plus one" or "plus two".  As far as I know there is no such
 #	name/designation as "Eastern Time" or "Central Time".
 # So I invented the following (English-language) abbreviations for now.
 # Corrections are welcome!
 #		std	dst
 #	-2:00	FNT	FNST	Fernando de Noronha
 #	-3:00	BRT	BRST	Brasilia
 #	-4:00	AMT	AMST	Amazon
 #	-5:00	ACT	ACST	Acre
 
 ###############################################################################
 
 ###############################################################################
 
 # Argentina
 
 # From Bob Devine (1988-01-28):
 # Argentina: first Sunday in October to first Sunday in April since 1976.
 # Double Summer time from 1969 to 1974.  Switches at midnight.
 
 # From U. S. Naval Observatory (1988-01-199):
 # ARGENTINA           3 H BEHIND   UTC
 
 # From Hernan G. Otero (1995-06-26):
 # I am sending modifications to the Argentine time zone table...
 # AR was chosen because they are the ISO letters that represent Argentina.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Arg	1930	only	-	Dec	 1	0:00	1:00	S
 Rule	Arg	1931	only	-	Apr	 1	0:00	0	-
 Rule	Arg	1931	only	-	Oct	15	0:00	1:00	S
 Rule	Arg	1932	1940	-	Mar	 1	0:00	0	-
 Rule	Arg	1932	1939	-	Nov	 1	0:00	1:00	S
 Rule	Arg	1940	only	-	Jul	 1	0:00	1:00	S
 Rule	Arg	1941	only	-	Jun	15	0:00	0	-
 Rule	Arg	1941	only	-	Oct	15	0:00	1:00	S
 Rule	Arg	1943	only	-	Aug	 1	0:00	0	-
 Rule	Arg	1943	only	-	Oct	15	0:00	1:00	S
 Rule	Arg	1946	only	-	Mar	 1	0:00	0	-
 Rule	Arg	1946	only	-	Oct	 1	0:00	1:00	S
 Rule	Arg	1963	only	-	Oct	 1	0:00	0	-
 Rule	Arg	1963	only	-	Dec	15	0:00	1:00	S
 Rule	Arg	1964	1966	-	Mar	 1	0:00	0	-
 Rule	Arg	1964	1966	-	Oct	15	0:00	1:00	S
 Rule	Arg	1967	only	-	Apr	 2	0:00	0	-
 Rule	Arg	1967	1968	-	Oct	Sun>=1	0:00	1:00	S
 Rule	Arg	1968	1969	-	Apr	Sun>=1	0:00	0	-
 Rule	Arg	1974	only	-	Jan	23	0:00	1:00	S
 Rule	Arg	1974	only	-	May	 1	0:00	0	-
 Rule	Arg	1988	only	-	Dec	 1	0:00	1:00	S
 #
 # From Hernan G. Otero (1995-06-26):
 # These corrections were contributed by InterSoft Argentina S.A.,
 # obtaining the data from the:
 # Talleres de Hidrografia Naval Argentina
 # (Argentine Naval Hydrography Institute)
 Rule	Arg	1989	1993	-	Mar	Sun>=1	0:00	0	-
 Rule	Arg	1989	1992	-	Oct	Sun>=15	0:00	1:00	S
 #
 # From Hernan G. Otero (1995-06-26):
 # From this moment on, the law that mandated the daylight saving
 # time corrections was derogated and no more modifications
 # to the time zones (for daylight saving) are now made.
 #
 # From Rives McDow (2000-01-10):
 # On October 3, 1999, 0:00 local, Argentina implemented daylight savings time,
 # which did not result in the switch of a time zone, as they stayed 9 hours
 # from the International Date Line.
 Rule	Arg	1999	only	-	Oct	Sun>=1	0:00	1:00	S
 # From Paul Eggert (2007-12-28):
 # DST was set to expire on March 5, not March 3, but since it was converted
 # to standard time on March 3 it's more convenient for us to pretend that
 # it ended on March 3.
 Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 #
 # From Peter Gradelski via Steffen Thorsen (2000-03-01):
 # We just checked with our Sao Paulo office and they say the government of
 # Argentina decided not to become one of the countries that go on or off DST.
 # So Buenos Aires should be -3 hours from GMT at all times.
 #
 # From Fabian L. Arce Jofre (2000-04-04):
 # The law that claimed DST for Argentina was derogated by President Fernando
 # de la Rua on March 2, 2000, because it would make people spend more energy
 # in the winter time, rather than less.  The change took effect on March 3.
 #
 # From Mariano Absatz (2001-06-06):
 # one of the major newspapers here in Argentina said that the 1999
 # Timezone Law (which never was effectively applied) will (would?) be
 # in effect.... The article is at
 # http://ar.clarin.com/diario/2001-06-06/e-01701.htm
 # ... The Law itself is "Ley No 25155", sanctioned on 1999-08-25, enacted
 # 1999-09-17, and published 1999-09-21.  The official publication is at:
 # http://www.boletin.jus.gov.ar/BON/Primera/1999/09-Septiembre/21/PDF/BO21-09-99LEG.PDF
 # Regretfully, you have to subscribe (and pay) for the on-line version....
 #
 # (2001-06-12):
 # the timezone for Argentina will not change next Sunday.
 # Apparently it will do so on Sunday 24th....
 # http://ar.clarin.com/diario/2001-06-12/s-03501.htm
 #
 # (2001-06-25):
 # Last Friday (yes, the last working day before the date of the change), the
 # Senate annulled the 1999 law that introduced the changes later postponed.
 # http://www.clarin.com.ar/diario/2001-06-22/s-03601.htm
 # It remains the vote of the Deputies..., but it will be the same....
 # This kind of things had always been done this way in Argentina.
 # We are still -03:00 all year round in all of the country.
 #
 # From Steffen Thorsen (2007-12-21):
 # A user (Leonardo Chaim) reported that Argentina will adopt DST....
 # all of the country (all Zone-entries) are affected.  News reports like
 # http://www.lanacion.com.ar/opinion/nota.asp?nota_id=973037 indicate
 # that Argentina will use DST next year as well, from October to
 # March, although exact rules are not given.
 #
 # From Jesper Norgaard Welen (2007-12-26)
 # The last hurdle of Argentina DST is over, the proposal was approved in
 # the lower chamber too (Deputados) with a vote 192 for and 2 against.
 # By the way thanks to Mariano Absatz and Daniel Mario Vega for the link to
 # the original scanned proposal, where the dates and the zero hours are
 # clear and unambiguous...This is the article about final approval:
 # 
 # http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996
 # 
 #
 # From Paul Eggert (2007-12-22):
 # For dates after mid-2008, the following rules are my guesses and
 # are quite possibly wrong, but are more likely than no DST at all.
 
 # From Alexander Krivenyshev (2008-09-05):
 # As per message from Carlos Alberto Fonseca Arauz (Nicaragua),
 # Argentina will start DST on Sunday October 19, 2008.
 #
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_argentina03.html
 # 
 # OR
 # 
 # http://www.impulsobaires.com.ar/nota.php?id=57832 (in spanish)
 # 
 
 # From Rodrigo Severo (2008-10-06):
 # Here is some info available at a Gentoo bug related to TZ on Argentina's DST:
 # ...
 # ------- Comment #1 from [jmdocile]  2008-10-06 16:28 0000 -------
 # Hi, there is a problem with timezone-data-2008e and maybe with
 # timezone-data-2008f
 # Argentinian law [Number] 25.155 is no longer valid.
 # 
 # http://www.infoleg.gov.ar/infolegInternet/anexos/60000-64999/60036/norma.htm
 # 
 # The new one is law [Number] 26.350
 # 
 # http://www.infoleg.gov.ar/infolegInternet/anexos/135000-139999/136191/norma.htm
 # 
 # So there is no summer time in Argentina for now.
 
 # From Mariano Absatz (2008-10-20):
 # Decree 1693/2008 applies Law 26.350 for the summer 2008/2009 establishing DST in Argentina
 # From 2008-10-19 until 2009-03-15
 # 
 # http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=16102008&pi=3&pf=4&s=0&sec=01
 # 
 #
 # Decree 1705/2008 excepting 12 Provinces from applying DST in the summer 2008/2009:
 # Catamarca, La Rioja, Mendoza, Salta, San Juan, San Luis, La Pampa, Neuquen, Rio Negro, Chubut, Santa Cruz
 # and Tierra del Fuego
 # 
 # http://www.boletinoficial.gov.ar/Bora.Portal/CustomControls/PdfContent.aspx?fp=17102008&pi=1&pf=1&s=0&sec=01
 # 
 #
 # Press release 235 dated Saturday October 18th, from the Government of the Province of Jujuy saying
 # it will not apply DST either (even when it was not included in Decree 1705/2008)
 # 
 # http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
 # 
 
 # From fullinet (2009-10-18):
 # As announced in
 # 
 # http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356
 # 
 # (an official .gob.ar) under title: "Sin Cambio de Hora" (english: "No hour change")
 #
 # "Por el momento, el Gobierno Nacional resolvio no modificar la hora
 # oficial, decision que estaba en estudio para su implementacion el
 # domingo 18 de octubre. Desde el Ministerio de Planificacion se anuncio
 # que la Argentina hoy, en estas condiciones meteorologicas, no necesita
 # la modificacion del huso horario, ya que 2009 nos encuentra con
 # crecimiento en la produccion y distribucion energetica."
 
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
 Rule	Arg	2008	2009	-	Mar	Sun>=15	0:00	0	-
 Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
 
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
 # its timezone this winter... starting tomorrow night....
 # http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040521-27158-normas.pdf
 # From Paul Eggert (2004-05-24):
 # It's Law No. 7,210.  This change is due to a public power emergency, so for
 # now we'll assume it's for this year only.
 #
 # From Paul Eggert (2006-03-22):
 # 
 # Hora de verano para la Republica Argentina (2003-06-08)
 #  says that standard time in Argentina from 1894-10-31
 # to 1920-05-01 was -4:16:48.25.  Go with this more-precise value
 # over Shanks & Pottenger.
 #
 # From Mariano Absatz (2004-06-05):
 # These media articles from a major newspaper mostly cover the current state:
 # http://www.lanacion.com.ar/04/05/27/de_604825.asp
 # http://www.lanacion.com.ar/04/05/28/de_605203.asp
 #
 # The following eight (8) provinces pulled clocks back to UTC-04:00 at
 # midnight Monday May 31st. (that is, the night between 05/31 and 06/01).
 # Apparently, all nine provinces would go back to UTC-03:00 at the same
 # time in October 17th.
 #
 # Catamarca, Chubut, La Rioja, San Juan, San Luis, Santa Cruz,
 # Tierra del Fuego, Tucuman.
 #
 # From Mariano Absatz (2004-06-14):
 # ... this weekend, the Province of Tucuman decided it'd go back to UTC-03:00
 # yesterday midnight (that is, at 24:00 Saturday 12th), since the people's
 # annoyance with the change is much higher than the power savings obtained....
 #
 # From Gwillim Law (2004-06-14):
 # http://www.lanacion.com.ar/04/06/10/de_609078.asp ...
 #     "The time change in Tierra del Fuego was a conflicted decision from
 #   the start.  The government had decreed that the measure would take
 #   effect on June 1, but a normative error forced the new time to begin
 #   three days earlier, from a Saturday to a Sunday....
 # Our understanding was that the change was originally scheduled to take place
 # on June 1 at 00:00 in Chubut, Santa Cruz, Tierra del Fuego (and some other
 # provinces).  Sunday was May 30, only two days earlier.  So the article
 # contains a contradiction.  I would give more credence to the Saturday/Sunday
 # date than the "three days earlier" phrase, and conclude that Tierra del
 # Fuego set its clocks back at 2004-05-30 00:00.
 #
 # From Steffen Thorsen (2004-10-05):
 # The previous law 7210 which changed the province of Mendoza's time zone
 # back in May have been modified slightly in a new law 7277, which set the
 # new end date to 2004-09-26 (original date was 2004-10-17).
 # http://www.gobernac.mendoza.gov.ar/boletin/pdf/20040924-27244-normas.pdf
 #
 # From Mariano Absatz (2004-10-05):
 # San Juan changed from UTC-03:00 to UTC-04:00 at midnight between
 # Sunday, May 30th and Monday, May 31st.  It changed back to UTC-03:00
 # at midnight between Saturday, July 24th and Sunday, July 25th....
 # http://www.sanjuan.gov.ar/prensa/archivo/000329.html
 # http://www.sanjuan.gov.ar/prensa/archivo/000426.html
 # http://www.sanjuan.gov.ar/prensa/archivo/000441.html
 
 # From Alex Krivenyshev (2008-01-17):
 # Here are articles that Argentina Province San Luis is planning to end DST
 # as earlier as upcoming Monday January 21, 2008 or February 2008:
 #
 # Provincia argentina retrasa reloj y marca diferencia con resto del pais
 # (Argentine Province delayed clock and mark difference with the rest of the
 # country)
 # 
 # http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel
 # 
 #
 # Es inminente que en San Luis atrasen una hora los relojes
 # (It is imminent in San Luis clocks one hour delay)
 # 
 # http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414
 # 
 #
 # 
 # http://www.worldtimezone.net/dst_news/dst_news_argentina02.html
 # 
 
 # From Jesper Norgaard Welen (2008-01-18):
 # The page of the San Luis provincial government
 # 
 # http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812
 # 
 # confirms what Alex Krivenyshev has earlier sent to the tz
 # emailing list about that San Luis plans to return to standard
 # time much earlier than the rest of the country. It also
 # confirms that upon request the provinces San Juan and Mendoza
 # refused to follow San Luis in this change.
 #
 # The change is supposed to take place Monday the 21.st at 0:00
 # hours. As far as I understand it if this goes ahead, we need
 # a new timezone for San Luis (although there are also documented
 # independent changes in the southamerica file of San Luis in
 # 1990 and 1991 which has not been confirmed).
 
 # From Jesper Norgaard Welen (2008-01-25):
 # Unfortunately the below page has become defunct, about the San Luis
 # time change. Perhaps because it now is part of a group of pages "Most
 # important pages of 2008."
 #
 # You can use
 # 
 # http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834
 # 
 # instead it seems. Or use "Buscador" from the main page of the San Luis
 # government, and fill in "huso" and click OK, and you will get 3 pages
 # from which the first one is identical to the above.
 
 # From Mariano Absatz (2008-01-28):
 # I can confirm that the Province of San Luis (and so far only that
 # province) decided to go back to UTC-3 effective midnight Jan 20th 2008
 # (that is, Monday 21st at 0:00 is the time the clocks were delayed back
 # 1 hour), and they intend to keep UTC-3 as their timezone all year round
 # (that is, unless they change their mind any minute now).
 #
 # So we'll have to add yet another city to 'southamerica' (I think San
 # Luis city is the mos populated city in the Province, so it'd be
 # America/Argentina/San_Luis... of course I can't remember if San Luis's
 # history of particular changes goes along with Mendoza or San Juan :-(
 # (I only remember not being able to collect hard facts about San Luis
 # back in 2004, when these provinces changed to UTC-4 for a few days, I
 # mailed them personally and never got an answer).
 
 # From Paul Eggert (2008-06-30):
 # Unless otherwise specified, data are from Shanks & Pottenger through 1992,
 # from the IATA otherwise.  As noted below, Shanks & Pottenger say that
 # America/Cordoba split into 6 subregions during 1991/1992, one of which
 # was America/San_Luis, but we haven't verified this yet so for now we'll
 # keep America/Cordoba a single region rather than splitting it into the
 # other 5 subregions.
 
 # From Mariano Absatz (2009-03-13):
 # Yesterday (with our usual 2-day notice) the Province of San Luis
 # decided that next Sunday instead of "staying" @utc-03:00 they will go
 # to utc-04:00 until the second Saturday in October...
 #
 # The press release is at
 # 
 # http://www.sanluis.gov.ar/SL/Paginas/NoticiaDetalle.asp?TemaId=1&InfoPrensaId=3102
 # 
 # (I couldn't find the decree, but
 # 
 # www.sanluis.gov.ar
 # 
 # is the official page for the Province Government).
 #
 # There's also a note in only one of the major national papers ...
 # http://www.lanacion.com.ar/nota.asp?nota_id=1107912
 #
 # The press release says [quick and dirty translation]:
 # ... announced that next Sunday, at 00:00, Puntanos (the San Luis
 # inhabitants) will have to turn back one hour their clocks
 #
 # Since then, San Luis will establish its own Province timezone. Thus,
 # during 2009, this timezone change will run from 00:00 the third Sunday
 # in March until 24:00 of the second Saturday in October.
 
 # From Mariano Absatz (2009-10-16):
 # ...the Province of San Luis is a case in itself.
 #
 # The Law at
 # 
 # is ambiguous because establishes a calendar from the 2nd Sunday in
 # October at 0:00 thru the 2nd Saturday in March at 24:00 and the
 # complement of that starting on the 2nd Sunday of March at 0:00 and
 # ending on the 2nd Saturday of March at 24:00.
 #
 # This clearly breaks every time the 1st of March or October is a Sunday.
 #
 # IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd
 # Sunday of October and March.
 #
 # The problem is that the changes in the rest of the Provinces that did
 # change in 2007/2008, were made according to the Federal Law and Decrees
 # that did so on the 3rd Sunday of October and March.
 #
 # In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday
 # (October 11th) at 0:00.
 #
 # So I guess a new set of rules, besides "Arg", must be made and the last
 # America/Argentina/San_Luis entries should change to use these...
 #
 # I'm enclosing a patch that does what I say... regretfully, the San Luis
 # timezone must be called "WART/WARST" even when most of the time (like,
 # right now) WARST == ART... that is, since last Sunday, all the country
 # is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
 # of the country calls it "ART".
 # ...
 
 # From Alexander Krivenyshev (2010-04-09):
 # According to news reports from El Diario de la Republica Province San
 # Luis, Argentina (standard time UTC-04) will keep Daylight Saving Time
 # after April 11, 2010--will continue to have same time as rest of
 # Argentina (UTC-3) (no DST).
 #
 # Confirmaron la prórroga del huso horario de verano (Spanish)
 # 
 # http://www.eldiariodelarepublica.com/index.php?option=com_content&task=view&id=29383&Itemid=9
 # 
 # or (some English translation):
 # 
 # http://www.worldtimezone.com/dst_news/dst_news_argentina08.html
 # 
 
 # From Mariano Absatz (2010-04-12):
 # yes...I can confirm this...and given that San Luis keeps calling
 # UTC-03:00 "summer time", we should't just let San Luis go back to "Arg"
 # rules...San Luis is still using "Western ARgentina Time" and it got
 # stuck on Summer daylight savings time even though the summer is over.
 
 # From Paul Eggert (2013-02-21):
 # Milne says Cordoba time was -4:16:48.2.  Round to the nearest second.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Buenos Aires (BA), Capital Federal (CF),
 Zone America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 Oct 31
 			-4:16:48 -	CMT	1920 May # Cordoba Mean Time
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT
 #
 # Cordoba (CB), Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN),
 # Chaco (CC), Formosa (FM), Santiago del Estero (SE)
 #
 # Shanks & Pottenger also make the following claims, which we haven't verified:
 # - Formosa switched to -3:00 on 1991-01-07.
 # - Misiones switched to -3:00 on 1990-12-29.
 # - Chaco switched to -3:00 on 1991-01-04.
 # - Santiago del Estero switched to -4:00 on 1991-04-01,
 #   then to -3:00 on 1991-04-26.
 #
 Zone America/Argentina/Cordoba -4:16:48 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  3
 			-4:00	-	WART	1991 Oct 20
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT
 #
 # Salta (SA), La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
 Zone America/Argentina/Salta -4:21:40 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  3
 			-4:00	-	WART	1991 Oct 20
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # Tucuman (TM)
 Zone America/Argentina/Tucuman -4:20:52 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  3
 			-4:00	-	WART	1991 Oct 20
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 13
 			-3:00	Arg	AR%sT
 #
 # La Rioja (LR)
 Zone America/Argentina/La_Rioja -4:27:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  1
 			-4:00	-	WART	1991 May  7
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # San Juan (SJ)
 Zone America/Argentina/San_Juan -4:34:04 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  1
 			-4:00	-	WART	1991 May  7
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # Jujuy (JY)
 Zone America/Argentina/Jujuy -4:21:12 -	LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1990 Mar  4
 			-4:00	-	WART	1990 Oct 28
 			-4:00	1:00	WARST	1991 Mar 17
 			-4:00	-	WART	1991 Oct  6
 			-3:00	1:00	ARST	1992
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # Catamarca (CT), Chubut (CH)
 Zone America/Argentina/Catamarca -4:23:08 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1991 Mar  3
 			-4:00	-	WART	1991 Oct 20
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # Mendoza (MZ)
 Zone America/Argentina/Mendoza -4:35:16 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1990 Mar  4
 			-4:00	-	WART	1990 Oct 15
 			-4:00	1:00	WARST	1991 Mar  1
 			-4:00	-	WART	1991 Oct 15
 			-4:00	1:00	WARST	1992 Mar  1
 			-4:00	-	WART	1992 Oct 18
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 23
 			-4:00	-	WART	2004 Sep 26
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # San Luis (SL)
 
 Rule	SanLuis	2008	2009	-	Mar	Sun>=8	0:00	0	-
 Rule	SanLuis	2007	2009	-	Oct	Sun>=8	0:00	1:00	S
 
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1990
 			-3:00	1:00	ARST	1990 Mar 14
 			-4:00	-	WART	1990 Oct 15
 			-4:00	1:00	WARST	1991 Mar  1
 			-4:00	-	WART	1991 Jun  1
 			-3:00	-	ART	1999 Oct  3
 			-4:00	1:00	WARST	2000 Mar  3
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
 			-4:00	SanLuis	WAR%sT
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31
 			-4:16:48 -	CMT	1920 May # Cordoba Mean Time
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 #
 # Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF)
 Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
 			-4:16:48 -	CMT	1920 May # Cordoba Mean Time
 			-4:00	-	ART	1930 Dec
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 30
 			-4:00	-	WART	2004 Jun 20
 			-3:00	Arg	AR%sT	2008 Oct 18
 			-3:00	-	ART
 
 # Aruba
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Aruba	-4:40:24 -	LMT	1912 Feb 12	# Oranjestad
 			-4:30	-	ANT	1965 # Netherlands Antilles Time
 			-4:00	-	AST
 
 # Bolivia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/La_Paz	-4:32:36 -	LMT	1890
 			-4:32:36 -	CMT	1931 Oct 15 # Calamarca MT
 			-4:32:36 1:00	BOST	1932 Mar 21 # Bolivia ST
 			-4:00	-	BOT	# Bolivia Time
 
 # Brazil
 
 # From Paul Eggert (1993-11-18):
 # The mayor of Rio recently attempted to change the time zone rules
 # just in his city, in order to leave more summer time for the tourist trade.
 # The rule change lasted only part of the day;
 # the federal government refused to follow the city's rules, and business
 # was in a chaos, so the mayor backed down that afternoon.
 
 # From IATA SSIM (1996-02):
 # _Only_ the following states in BR1 observe DST: Rio Grande do Sul (RS),
 # Santa Catarina (SC), Parana (PR), Sao Paulo (SP), Rio de Janeiro (RJ),
 # Espirito Santo (ES), Minas Gerais (MG), Bahia (BA), Goias (GO),
 # Distrito Federal (DF), Tocantins (TO), Sergipe [SE] and Alagoas [AL].
 # [The last three states are new to this issue of the IATA SSIM.]
 
 # From Gwillim Law (1996-10-07):
 # Geography, history (Tocantins was part of Goias until 1989), and other
 # sources of time zone information lead me to believe that AL, SE, and TO were
 # always in BR1, and so the only change was whether or not they observed DST....
 # The earliest issue of the SSIM I have is 2/91.  Each issue from then until
 # 9/95 says that DST is observed only in the ten states I quoted from 9/95,
 # along with Mato Grosso (MT) and Mato Grosso do Sul (MS), which are in BR2
 # (UTC-4)....  The other two time zones given for Brazil are BR3, which is
 # UTC-5, no DST, and applies only in the state of Acre (AC); and BR4, which is
 # UTC-2, and applies to Fernando de Noronha (formerly FN, but I believe it's
 # become part of the state of Pernambuco).  The boundary between BR1 and BR2
 # has never been clearly stated.  They've simply been called East and West.
 # However, some conclusions can be drawn from another IATA manual: the Airline
 # Coding Directory, which lists close to 400 airports in Brazil.  For each
 # airport it gives a time zone which is coded to the SSIM.  From that
 # information, I'm led to conclude that the states of Amapa (AP), Ceara (CE),
 # Maranhao (MA), Paraiba (PR), Pernambuco (PE), Piaui (PI), and Rio Grande do
 # Norte (RN), and the eastern part of Para (PA) are all in BR1 without DST.
 
 # From Marcos Tadeu (1998-09-27):
 # 
 # Brazilian official page
 # 
 
 # From Jesper Norgaard (2000-11-03):
 # [For an official list of which regions in Brazil use which time zones, see:]
 # http://pcdsh01.on.br/Fusbr.htm
 # http://pcdsh01.on.br/Fusbrhv.htm
 
 # From Celso Doria via David Madeo (2002-10-09):
 # The reason for the delay this year has to do with elections in Brazil.
 #
 # Unlike in the United States, elections in Brazil are 100% computerized and
 # the results are known almost immediately.  Yesterday, it was the first
 # round of the elections when 115 million Brazilians voted for President,
 # Governor, Senators, Federal Deputies, and State Deputies.  Nobody is
 # counting (or re-counting) votes anymore and we know there will be a second
 # round for the Presidency and also for some Governors.  The 2nd round will
 # take place on October 27th.
 #
 # The reason why the DST will only begin November 3rd is that the thousands
 # of electoral machines used cannot have their time changed, and since the
 # Constitution says the elections must begin at 8:00 AM and end at 5:00 PM,
 # the Government decided to postpone DST, instead of changing the Constitution
 # (maybe, for the next elections, it will be possible to change the clock)...
 
 # From Rodrigo Severo (2004-10-04):
 # It's just the biannual change made necessary by the much hyped, supposedly
 # modern Brazilian eletronic voting machines which, apparently, can't deal
 # with a time change between the first and the second rounds of the elections.
 
 # From Steffen Thorsen (2007-09-20):
 # Brazil will start DST on 2007-10-14 00:00 and end on 2008-02-17 00:00:
 # http://www.mme.gov.br/site/news/detail.do;jsessionid=BBA06811AFCAAC28F0285210913513DA?newsId=13975
 
 # From Paul Schulze (2008-06-24):
 # ...by law number 11.662 of April 24, 2008 (published in the "Diario
 # Oficial da Uniao"...) in Brazil there are changes in the timezones,
 # effective today (00:00am at June 24, 2008) as follows:
 #
 # a) The timezone UTC+5 is e[x]tinguished, with all the Acre state and the
 # part of the Amazonas state that had this timezone now being put to the
 # timezone UTC+4
 # b) The whole Para state now is put at timezone UTC+3, instead of just
 # part of it, as was before.
 #
 # This change follows a proposal of senator Tiao Viana of Acre state, that
 # proposed it due to concerns about open television channels displaying
 # programs inappropriate to youths in the states that had the timezone
 # UTC+5 too early in the night. In the occasion, some more corrections
 # were proposed, trying to unify the timezones of any given state. This
 # change modifies timezone rules defined in decree 2.784 of 18 June,
 # 1913.
 
 # From Rodrigo Severo (2008-06-24):
 # Just correcting the URL:
 # 
 # https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=do&secao=1&pagina=1&data=25/04/2008
 # 
 #
 # As a result of the above Decree I believe the America/Rio_Branco
 # timezone shall be modified from UTC-5 to UTC-4 and a new timezone shall
 # be created to represent the...west side of the Para State. I
 # suggest this new timezone be called Santarem as the most
 # important/populated city in the affected area.
 #
 # This new timezone would be the same as the Rio_Branco timezone up to
 # the 2008/06/24 change which would be to UTC-3 instead of UTC-4.
 
 # From Alex Krivenyshev (2008-06-24):
 # This is a quick reference page for New and Old Brazil Time Zones map.
 # 
 # http://www.worldtimezone.com/brazil-time-new-old.php
 # 
 #
 # - 4 time zones replaced by 3 time zones-eliminating time zone UTC- 05
 # (state Acre and the part of the Amazonas will be UTC/GMT- 04) - western
 # part of Par state is moving to one timezone UTC- 03 (from UTC -04).
 
 # From Paul Eggert (2002-10-10):
 # The official decrees referenced below are mostly taken from
 # 
 # Decretos sobre o Horario de Verao no Brasil
 # .
 
 # From Steffen Thorsen (2008-08-29):
 # As announced by the government and many newspapers in Brazil late
 # yesterday, Brazil will start DST on 2008-10-19 (need to change rule) and
 # it will end on 2009-02-15 (current rule for Brazil is fine). Based on
 # past years experience with the elections, there was a good chance that
 # the start was postponed to November, but it did not happen this year.
 #
 # It has not yet been posted to http://pcdsh01.on.br/DecHV.html
 #
 # An official page about it:
 # 
 # http://www.mme.gov.br/site/news/detail.do?newsId=16722
 # 
 # Note that this link does not always work directly, but must be accessed
 # by going to
 # 
 # http://www.mme.gov.br/first
 # 
 #
 # One example link that works directly:
 # 
 # http://jornale.com.br/index.php?option=com_content&task=view&id=13530&Itemid=54
 # (Portuguese)
 # 
 #
 # We have a written a short article about it as well:
 # 
 # http://www.timeanddate.com/news/time/brazil-dst-2008-2009.html
 # 
 #
 # From Alexander Krivenyshev (2011-10-04):
 # State Bahia will return to Daylight savings time this year after 8 years off.
 # The announcement was made by Governor Jaques Wagner in an interview to a
 # television station in Salvador.
 
 # In Portuguese:
 # 
 # http://g1.globo.com/bahia/noticia/2011/10/governador-jaques-wagner-confirma-horario-de-verao-na-bahia.html
 #  and
 # 
 # http://noticias.terra.com.br/brasil/noticias/0,,OI5390887-EI8139,00-Bahia+volta+a+ter+horario+de+verao+apos+oito+anos.html
 # 
 
 # From Guilherme Bernardes Rodrigues (2011-10-07):
 # There is news in the media, however there is still no decree about it.
 # I just send a e-mail to Zulmira Brandao at
 # http://pcdsh01.on.br/ the
 # official agency about time in Brazil, and she confirmed that the old rule is
 # still in force.
 
 # From Guilherme Bernardes Rodrigues (2011-10-14)
 # It's official, the President signed a decree that includes Bahia in summer
 # time.
 #	 [ and in a second message (same day): ]
 # I found the decree.
 #
 # DECRETO No- 7.584, DE 13 DE OUTUBRO DE 2011
 # Link :
 # 
 # http://www.in.gov.br/visualiza/index.jsp?data=13/10/2011&jornal=1000&pagina=6&totalArquivos=6
 # 
 
 # From Kelley Cook (2012-10-16):
 # The governor of state of Bahia in Brazil announced on Thursday that
 # due to public pressure, he is reversing the DST policy they implemented
 # last year and will not be going to Summer Time on October 21st....
 # http://www.correio24horas.com.br/r/artigo/apos-pressoes-wagner-suspende-horario-de-verao-na-bahia
 
 # From Rodrigo Severo (2012-10-16):
 # Tocantins state will have DST.
 # http://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 # Decree 20,466 (1931-10-01)
 # Decree 21,896 (1932-01-10)
 Rule	Brazil	1931	only	-	Oct	 3	11:00	1:00	S
 Rule	Brazil	1932	1933	-	Apr	 1	 0:00	0	-
 Rule	Brazil	1932	only	-	Oct	 3	 0:00	1:00	S
 # Decree 23,195 (1933-10-10)
 # revoked DST.
 # Decree 27,496 (1949-11-24)
 # Decree 27,998 (1950-04-13)
 Rule	Brazil	1949	1952	-	Dec	 1	 0:00	1:00	S
 Rule	Brazil	1950	only	-	Apr	16	 1:00	0	-
 Rule	Brazil	1951	1952	-	Apr	 1	 0:00	0	-
 # Decree 32,308 (1953-02-24)
 Rule	Brazil	1953	only	-	Mar	 1	 0:00	0	-
 # Decree 34,724 (1953-11-30)
 # revoked DST.
 # Decree 52,700 (1963-10-18)
 # established DST from 1963-10-23 00:00 to 1964-02-29 00:00
 # in SP, RJ, GB, MG, ES, due to the prolongation of the drought.
 # Decree 53,071 (1963-12-03)
 # extended the above decree to all of the national territory on 12-09.
 Rule	Brazil	1963	only	-	Dec	 9	 0:00	1:00	S
 # Decree 53,604 (1964-02-25)
 # extended summer time by one day to 1964-03-01 00:00 (start of school).
 Rule	Brazil	1964	only	-	Mar	 1	 0:00	0	-
 # Decree 55,639 (1965-01-27)
 Rule	Brazil	1965	only	-	Jan	31	 0:00	1:00	S
 Rule	Brazil	1965	only	-	Mar	31	 0:00	0	-
 # Decree 57,303 (1965-11-22)
 Rule	Brazil	1965	only	-	Dec	 1	 0:00	1:00	S
 # Decree 57,843 (1966-02-18)
 Rule	Brazil	1966	1968	-	Mar	 1	 0:00	0	-
 Rule	Brazil	1966	1967	-	Nov	 1	 0:00	1:00	S
 # Decree 63,429 (1968-10-15)
 # revoked DST.
 # Decree 91,698 (1985-09-27)
 Rule	Brazil	1985	only	-	Nov	 2	 0:00	1:00	S
 # Decree 92,310 (1986-01-21)
 # Decree 92,463 (1986-03-13)
 Rule	Brazil	1986	only	-	Mar	15	 0:00	0	-
 # Decree 93,316 (1986-10-01)
 Rule	Brazil	1986	only	-	Oct	25	 0:00	1:00	S
 Rule	Brazil	1987	only	-	Feb	14	 0:00	0	-
 # Decree 94,922 (1987-09-22)
 Rule	Brazil	1987	only	-	Oct	25	 0:00	1:00	S
 Rule	Brazil	1988	only	-	Feb	 7	 0:00	0	-
 # Decree 96,676 (1988-09-12)
 # except for the states of AC, AM, PA, RR, RO, and AP (then a territory)
 Rule	Brazil	1988	only	-	Oct	16	 0:00	1:00	S
 Rule	Brazil	1989	only	-	Jan	29	 0:00	0	-
 # Decree 98,077 (1989-08-21)
 # with the same exceptions
 Rule	Brazil	1989	only	-	Oct	15	 0:00	1:00	S
 Rule	Brazil	1990	only	-	Feb	11	 0:00	0	-
 # Decree 99,530 (1990-09-17)
 # adopted by RS, SC, PR, SP, RJ, ES, MG, GO, MS, DF.
 # Decree 99,629 (1990-10-19) adds BA, MT.
 Rule	Brazil	1990	only	-	Oct	21	 0:00	1:00	S
 Rule	Brazil	1991	only	-	Feb	17	 0:00	0	-
 # Unnumbered decree (1991-09-25)
 # adopted by RS, SC, PR, SP, RJ, ES, MG, BA, GO, MT, MS, DF.
 Rule	Brazil	1991	only	-	Oct	20	 0:00	1:00	S
 Rule	Brazil	1992	only	-	Feb	 9	 0:00	0	-
 # Unnumbered decree (1992-10-16)
 # adopted by same states.
 Rule	Brazil	1992	only	-	Oct	25	 0:00	1:00	S
 Rule	Brazil	1993	only	-	Jan	31	 0:00	0	-
 # Decree 942 (1993-09-28)
 # adopted by same states, plus AM.
 # Decree 1,252 (1994-09-22;
 # web page corrected 2004-01-07) adopted by same states, minus AM.
 # Decree 1,636 (1995-09-14)
 # adopted by same states, plus MT and TO.
 # Decree 1,674 (1995-10-13)
 # adds AL, SE.
 Rule	Brazil	1993	1995	-	Oct	Sun>=11	 0:00	1:00	S
 Rule	Brazil	1994	1995	-	Feb	Sun>=15	 0:00	0	-
 Rule	Brazil	1996	only	-	Feb	11	 0:00	0	-
 # Decree 2,000 (1996-09-04)
 # adopted by same states, minus AL, SE.
 Rule	Brazil	1996	only	-	Oct	 6	 0:00	1:00	S
 Rule	Brazil	1997	only	-	Feb	16	 0:00	0	-
 # From Daniel C. Sobral (1998-02-12):
 # In 1997, the DS began on October 6. The stated reason was that
 # because international television networks ignored Brazil's policy on DS,
 # they bought the wrong times on satellite for coverage of Pope's visit.
 # This year, the ending date of DS was postponed to March 1
 # to help dealing with the shortages of electric power.
 #
 # Decree 2,317 (1997-09-04), adopted by same states.
 Rule	Brazil	1997	only	-	Oct	 6	 0:00	1:00	S
 # Decree 2,495
 # (1998-02-10)
 Rule	Brazil	1998	only	-	Mar	 1	 0:00	0	-
 # Decree 2,780 (1998-09-11)
 # adopted by the same states as before.
 Rule	Brazil	1998	only	-	Oct	11	 0:00	1:00	S
 Rule	Brazil	1999	only	-	Feb	21	 0:00	0	-
 # Decree 3,150
 # (1999-08-23) adopted by same states.
 # Decree 3,188 (1999-09-30)
 # adds SE, AL, PB, PE, RN, CE, PI, MA and RR.
 Rule	Brazil	1999	only	-	Oct	 3	 0:00	1:00	S
 Rule	Brazil	2000	only	-	Feb	27	 0:00	0	-
 # Decree 3,592 (2000-09-06)
 # adopted by the same states as before.
 # Decree 3,630 (2000-10-13)
 # repeals DST in PE and RR, effective 2000-10-15 00:00.
 # Decree 3,632 (2000-10-17)
 # repeals DST in SE, AL, PB, RN, CE, PI and MA, effective 2000-10-22 00:00.
 # Decree 3,916
 # (2001-09-13) reestablishes DST in AL, CE, MA, PB, PE, PI, RN, SE.
 Rule	Brazil	2000	2001	-	Oct	Sun>=8	 0:00	1:00	S
 Rule	Brazil	2001	2006	-	Feb	Sun>=15	 0:00	0	-
 # Decree 4,399 (2002-10-01) repeals DST in AL, CE, MA, PB, PE, PI, RN, SE.
 # 4,399
 Rule	Brazil	2002	only	-	Nov	 3	 0:00	1:00	S
 # Decree 4,844 (2003-09-24; corrected 2003-09-26) repeals DST in BA, MT, TO.
 # 4,844
 Rule	Brazil	2003	only	-	Oct	19	 0:00	1:00	S
 # Decree 5,223 (2004-10-01) reestablishes DST in MT.
 # 5,223
 Rule	Brazil	2004	only	-	Nov	 2	 0:00	1:00	S
 # Decree 5,539 (2005-09-19),
 # adopted by the same states as before.
 Rule	Brazil	2005	only	-	Oct	16	 0:00	1:00	S
 # Decree 5,920 (2006-10-03),
 # adopted by the same states as before.
 Rule	Brazil	2006	only	-	Nov	 5	 0:00	1:00	S
 Rule	Brazil	2007	only	-	Feb	25	 0:00	0	-
 # Decree 6,212 (2007-09-26),
 # adopted by the same states as before.
 Rule	Brazil	2007	only	-	Oct	Sun>=8	 0:00	1:00	S
 # From Frederico A. C. Neves (2008-09-10):
 # Acording to this decree
 # 
 # http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm
 # 
 # [t]he DST period in Brazil now on will be from the 3rd Oct Sunday to the
 # 3rd Feb Sunday. There is an exception on the return date when this is
 # the Carnival Sunday then the return date will be the next Sunday...
 Rule	Brazil	2008	max	-	Oct	Sun>=15	0:00	1:00	S
 Rule	Brazil	2008	2011	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2012	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2013	2014	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2015	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2016	2022	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2023	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2024	2025	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2026	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2027	2033	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2034	only	-	Feb	Sun>=22	0:00	0	-
 Rule	Brazil	2035	2036	-	Feb	Sun>=15	0:00	0	-
 Rule	Brazil	2037	only	-	Feb	Sun>=22	0:00	0	-
 # From Arthur David Olson (2008-09-29):
 # The next is wrong in some years but is better than nothing.
 Rule	Brazil	2038	max	-	Feb	Sun>=15	0:00	0	-
 
 # The latest ruleset listed above says that the following states observe DST:
 # DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP.
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Fernando de Noronha (administratively part of PE)
 Zone America/Noronha	-2:09:40 -	LMT	1914
 			-2:00	Brazil	FN%sT	1990 Sep 17
 			-2:00	-	FNT	1999 Sep 30
 			-2:00	Brazil	FN%sT	2000 Oct 15
 			-2:00	-	FNT	2001 Sep 13
 			-2:00	Brazil	FN%sT	2002 Oct  1
 			-2:00	-	FNT
 # Other Atlantic islands have no permanent settlement.
 # These include Trindade and Martin Vaz (administratively part of ES),
 # Atol das Rocas (RN), and Penedos de Sao Pedro e Sao Paulo (PE).
 # Fernando de Noronha was a separate territory from 1942-09-02 to 1989-01-01;
 # it also included the Penedos.
 #
 # Amapa (AP), east Para (PA)
 # East Para includes Belem, Maraba, Serra Norte, and Sao Felix do Xingu.
 # The division between east and west Para is the river Xingu.
 # In the north a very small part from the river Javary (now Jari I guess,
 # the border with Amapa) to the Amazon, then to the Xingu.
 Zone America/Belem	-3:13:56 -	LMT	1914
 			-3:00	Brazil	BR%sT	1988 Sep 12
 			-3:00	-	BRT
 #
 # west Para (PA)
 # West Para includes Altamira, Oribidos, Prainha, Oriximina, and Santarem.
 Zone America/Santarem	-3:38:48 -	LMT	1914
 			-4:00	Brazil	AM%sT	1988 Sep 12
 			-4:00	-	AMT	2008 Jun 24 00:00
 			-3:00	-	BRT
 #
 # Maranhao (MA), Piaui (PI), Ceara (CE), Rio Grande do Norte (RN),
 # Paraiba (PB)
 Zone America/Fortaleza	-2:34:00 -	LMT	1914
 			-3:00	Brazil	BR%sT	1990 Sep 17
 			-3:00	-	BRT	1999 Sep 30
 			-3:00	Brazil	BR%sT	2000 Oct 22
 			-3:00	-	BRT	2001 Sep 13
 			-3:00	Brazil	BR%sT	2002 Oct  1
 			-3:00	-	BRT
 #
 # Pernambuco (PE) (except Atlantic islands)
 Zone America/Recife	-2:19:36 -	LMT	1914
 			-3:00	Brazil	BR%sT	1990 Sep 17
 			-3:00	-	BRT	1999 Sep 30
 			-3:00	Brazil	BR%sT	2000 Oct 15
 			-3:00	-	BRT	2001 Sep 13
 			-3:00	Brazil	BR%sT	2002 Oct  1
 			-3:00	-	BRT
 #
 # Tocantins (TO)
 Zone America/Araguaina	-3:12:48 -	LMT	1914
 			-3:00	Brazil	BR%sT	1990 Sep 17
 			-3:00	-	BRT	1995 Sep 14
 			-3:00	Brazil	BR%sT	2003 Sep 24
 			-3:00	-	BRT	2012 Oct 21
 			-3:00	Brazil	BR%sT
 #
 # Alagoas (AL), Sergipe (SE)
 Zone America/Maceio	-2:22:52 -	LMT	1914
 			-3:00	Brazil	BR%sT	1990 Sep 17
 			-3:00	-	BRT	1995 Oct 13
 			-3:00	Brazil	BR%sT	1996 Sep  4
 			-3:00	-	BRT	1999 Sep 30
 			-3:00	Brazil	BR%sT	2000 Oct 22
 			-3:00	-	BRT	2001 Sep 13
 			-3:00	Brazil	BR%sT	2002 Oct  1
 			-3:00	-	BRT
 #
 # Bahia (BA)
 # There are too many Salvadors elsewhere, so use America/Bahia instead
 # of America/Salvador.
 Zone America/Bahia	-2:34:04 -	LMT	1914
 			-3:00	Brazil	BR%sT	2003 Sep 24
 			-3:00	-	BRT	2011 Oct 16
 			-3:00	Brazil	BR%sT	2012 Oct 21
 			-3:00	-	BRT
 #
 # Goias (GO), Distrito Federal (DF), Minas Gerais (MG),
 # Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR),
 # Santa Catarina (SC), Rio Grande do Sul (RS)
 Zone America/Sao_Paulo	-3:06:28 -	LMT	1914
 			-3:00	Brazil	BR%sT	1963 Oct 23 00:00
 			-3:00	1:00	BRST	1964
 			-3:00	Brazil	BR%sT
 #
 # Mato Grosso do Sul (MS)
 Zone America/Campo_Grande -3:38:28 -	LMT	1914
 			-4:00	Brazil	AM%sT
 #
 # Mato Grosso (MT)
 Zone America/Cuiaba	-3:44:20 -	LMT	1914
 			-4:00	Brazil	AM%sT	2003 Sep 24
 			-4:00	-	AMT	2004 Oct  1
 			-4:00	Brazil	AM%sT
 #
 # Rondonia (RO)
 Zone America/Porto_Velho -4:15:36 -	LMT	1914
 			-4:00	Brazil	AM%sT	1988 Sep 12
 			-4:00	-	AMT
 #
 # Roraima (RR)
 Zone America/Boa_Vista	-4:02:40 -	LMT	1914
 			-4:00	Brazil	AM%sT	1988 Sep 12
 			-4:00	-	AMT	1999 Sep 30
 			-4:00	Brazil	AM%sT	2000 Oct 15
 			-4:00	-	AMT
 #
 # east Amazonas (AM): Boca do Acre, Jutai, Manaus, Floriano Peixoto
 # The great circle line from Tabatinga to Porto Acre divides
 # east from west Amazonas.
 Zone America/Manaus	-4:00:04 -	LMT	1914
 			-4:00	Brazil	AM%sT	1988 Sep 12
 			-4:00	-	AMT	1993 Sep 28
 			-4:00	Brazil	AM%sT	1994 Sep 22
 			-4:00	-	AMT
 #
 # west Amazonas (AM): Atalaia do Norte, Boca do Maoco, Benjamin Constant,
 #	Eirunepe, Envira, Ipixuna
 Zone America/Eirunepe	-4:39:28 -	LMT	1914
 			-5:00	Brazil	AC%sT	1988 Sep 12
 			-5:00	-	ACT	1993 Sep 28
 			-5:00	Brazil	AC%sT	1994 Sep 22
 			-5:00	-	ACT	2008 Jun 24 00:00
 			-4:00	-	AMT
 #
 # Acre (AC)
 Zone America/Rio_Branco	-4:31:12 -	LMT	1914
 			-5:00	Brazil	AC%sT	1988 Sep 12
 			-5:00	-	ACT	2008 Jun 24 00:00
 			-4:00	-	AMT
 
 # Chile
 
 # From Eduardo Krell (1995-10-19):
 # The law says to switch to DST at midnight [24:00] on the second SATURDAY
 # of October....  The law is the same for March and October.
 # (1998-09-29):
 # Because of the drought this year, the government decided to go into
 # DST earlier (saturday 9/26 at 24:00). This is a one-time change only ...
 # (unless there's another dry season next year, I guess).
 
 # From Julio I. Pacheco Troncoso (1999-03-18):
 # Because of the same drought, the government decided to end DST later,
 # on April 3, (one-time change).
 
 # From Oscar van Vlijmen (2006-10-08):
 # http://www.horaoficial.cl/cambio.htm
 
 # From Jesper Norgaard Welen (2006-10-08):
 # I think that there are some obvious mistakes in the suggested link
 # from Oscar van Vlijmen,... for instance entry 66 says that GMT-4
 # ended 1990-09-12 while entry 67 only begins GMT-3 at 1990-09-15
 # (they should have been 1990-09-15 and 1990-09-16 respectively), but
 # anyhow it clears up some doubts too.
 
 # From Paul Eggert (2006-12-27):
 # The following data for Chile and America/Santiago are from
 #  (2006-09-20), transcribed by
 # Jesper Norgaard Welen.  The data for Pacific/Easter are from Shanks
 # & Pottenger, except with DST transitions after 1932 cloned from
 # America/Santiago.  The pre-1980 Pacific/Easter data are dubious,
 # but we have no other source.
 
 # From German Poo-Caaman~o (2008-03-03):
 # Due to drought, Chile extends Daylight Time in three weeks.  This
 # is one-time change (Saturday 3/29 at 24:00 for America/Santiago
 # and Saturday 3/29 at 22:00 for Pacific/Easter)
 # The Supreme Decree is located at
 # 
 # http://www.shoa.cl/servicios/supremo316.pdf
 # 
 # and the instructions for 2008 are located in:
 # 
 # http://www.horaoficial.cl/cambio.htm
 # .
 
 # From Jose Miguel Garrido (2008-03-05):
 # ...
 # You could see the announces of the change on
 # 
 # http://www.shoa.cl/noticias/2008/04hora/hora.htm
 # .
 
 # From Angel Chiang (2010-03-04):
 # Subject: DST in Chile exceptionally extended to 3 April due to earthquake
 # 
 # http://www.gobiernodechile.cl/viewNoticia.aspx?idArticulo=30098
 # 
 # (in Spanish, last paragraph).
 #
 # This is breaking news. There should be more information available later.
 
 # From Arthur Daivd Olson (2010-03-06):
 # Angel Chiang's message confirmed by Julio Pacheco; Julio provided a patch.
 
 # From Glenn Eychaner (2011-03-02): [geychaner@mac.com]
 # It appears that the Chilean government has decided to postpone the
 # change from summer time to winter time again, by three weeks to April
 # 2nd:
 # 
 # http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651
 # 
 #
 # This is not yet reflected in the offical "cambio de hora" site, but
 # probably will be soon:
 # 
 # http://www.horaoficial.cl/cambio.htm
 # 
 
 # From Arthur David Olson (2011-03-02):
 # The emol.com article mentions a water shortage as the cause of the
 # postponement, which may mean that it's not a permanent change.
 
 # From Glenn Eychaner (2011-03-28):
 # The article:
 # 
 # http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E}
 # 
 #
 # In English:
 # Chile's clocks will go back an hour this year on the 7th of May instead
 # of this Saturday. They will go forward again the 3rd Saturday in
 # August, not in October as they have since 1968. This is a pilot plan
 # which will be reevaluated in 2012.
 
 # From Mauricio Parada (2012-02-22), translated by Glenn Eychaner (2012-02-23):
 # As stated in the website of the Chilean Energy Ministry
 # http://www.minenergia.cl/ministerio/noticias/generales/gobierno-anuncia-fechas-de-cambio-de.html
 # The Chilean Government has decided to postpone the entrance into winter time
 # (to leave DST) from March 11 2012 to April 28th 2012. The decision has not
 # been yet formalized but it will within the next days.
 # Quote from the website communication:
 #
 # 6. For the year 2012, the dates of entry into winter time will be as follows:
 # a. Saturday April 28, 2012, clocks should go back 60 minutes; that is, at
 # 23:59:59, instead of passing to 0:00, the time should be adjusted to be 23:00
 # of the same day.
 # b. Saturday, September 1, 2012, clocks should go forward 60 minutes; that is,
 # at 23:59:59, instead of passing to 0:00, the time should be adjusted to be
 # 01:00 on September 2.
 
 # From Steffen Thorsen (2013-02-15):
 # According to several news sources, Chile has extended DST this year,
 # they will end DST later and start DST earlier than planned.  They
 # hope to save energy.  The new end date is 2013-04-28 00:00 and new
 # start date is 2013-09-08 00:00....
 # http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm
 
 # NOTE: ChileAQ rules for Antarctic bases are stored separately in the
 # 'antarctica' file.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1932	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
 Rule	Chile	1942	only	-	Jun	 1	4:00u	0	-
 Rule	Chile	1942	only	-	Aug	 1	5:00u	1:00	S
 Rule	Chile	1946	only	-	Jul	15	4:00u	1:00	S
 Rule	Chile	1946	only	-	Sep	 1	3:00u	0:00	-
 Rule	Chile	1947	only	-	Apr	 1	4:00u	0	-
 Rule	Chile	1968	only	-	Nov	 3	4:00u	1:00	S
 Rule	Chile	1969	only	-	Mar	30	3:00u	0	-
 Rule	Chile	1969	only	-	Nov	23	4:00u	1:00	S
 Rule	Chile	1970	only	-	Mar	29	3:00u	0	-
 Rule	Chile	1971	only	-	Mar	14	3:00u	0	-
 Rule	Chile	1970	1972	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	1972	1986	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	1973	only	-	Sep	30	4:00u	1:00	S
 Rule	Chile	1974	1987	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	1987	only	-	Apr	12	3:00u	0	-
 Rule	Chile	1988	1989	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	1988	only	-	Oct	Sun>=1	4:00u	1:00	S
 Rule	Chile	1989	only	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	1990	only	-	Mar	18	3:00u	0	-
 Rule	Chile	1990	only	-	Sep	16	4:00u	1:00	S
 Rule	Chile	1991	1996	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	1991	1997	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	1997	only	-	Mar	30	3:00u	0	-
 Rule	Chile	1998	only	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	1998	only	-	Sep	27	4:00u	1:00	S
 Rule	Chile	1999	only	-	Apr	 4	3:00u	0	-
 Rule	Chile	1999	2010	-	Oct	Sun>=9	4:00u	1:00	S
 Rule	Chile	2000	2007	-	Mar	Sun>=9	3:00u	0	-
 # N.B.: the end of March 29 in Chile is March 30 in Universal time,
 # which is used below in specifying the transition.
 Rule	Chile	2008	only	-	Mar	30	3:00u	0	-
 Rule	Chile	2009	only	-	Mar	Sun>=9	3:00u	0	-
 Rule	Chile	2010	only	-	Apr	Sun>=1	3:00u	0	-
 Rule	Chile	2011	only	-	May	Sun>=2	3:00u	0	-
 Rule	Chile	2011	only	-	Aug	Sun>=16	4:00u	1:00	S
 Rule	Chile	2012	max	-	Apr	Sun>=23	3:00u	0	-
 Rule	Chile	2012	max	-	Sep	Sun>=2	4:00u	1:00	S
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Santiago	-4:42:46 -	LMT	1890
 			-4:42:46 -	SMT	1910 	    # Santiago Mean Time
 			-5:00	-	CLT	1916 Jul  1 # Chile Time
 			-4:42:46 -	SMT	1918 Sep  1 # Santiago Mean Time
 			-4:00	-	CLT	1919 Jul  1 # Chile Time
 			-4:42:46 -	SMT	1927 Sep  1 # Santiago Mean Time
 			-5:00	Chile	CL%sT	1947 May 22 # Chile Time
 			-4:00	Chile	CL%sT
 Zone Pacific/Easter	-7:17:44 -	LMT	1890
 			-7:17:28 -	EMT	1932 Sep    # Easter Mean Time
 			-7:00	Chile	EAS%sT	1982 Mar 13 21:00 # Easter I Time
 			-6:00	Chile	EAS%sT
 #
 # Sala y Gomez Island is like Pacific/Easter.
 # Other Chilean locations, including Juan Fernandez Is, San Ambrosio,
 # San Felix, and Antarctic bases, are like America/Santiago.
 
 # Colombia
 
 # Milne gives 4:56:16.4 for Bogota time in 1899; round to nearest.  He writes,
 # "A variation of fifteen minutes in the public clocks of Bogota is not rare."
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	CO	1992	only	-	May	 3	0:00	1:00	S
 Rule	CO	1993	only	-	Apr	 4	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Bogota	-4:56:16 -	LMT	1884 Mar 13
 			-4:56:16 -	BMT	1914 Nov 23 # Bogota Mean Time
 			-5:00	CO	CO%sT	# Colombia Time
 # Malpelo, Providencia, San Andres
 # no information; probably like America/Bogota
 
 # Curacao
 
 # Milne gives 4:35:46.9 for Curacao mean time; round to nearest.
 #
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger say that The Bottom and Philipsburg have been at
 # -4:00 since standard time was introduced on 1912-03-02; and that
 # Kralendijk and Rincon used Kralendijk Mean Time (-4:33:08) from
 # 1912-02-02 to 1965-01-01.  The former is dubious, since S&P also say
 # Saba Island has been like Curacao.
 # This all predates our 1970 cutoff, though.
 #
 # By July 2007 Curacao and St Maarten are planned to become
 # associated states within the Netherlands, much like Aruba;
 # Bonaire, Saba and St Eustatius would become directly part of the
 # Netherlands as Kingdom Islands.  This won't affect their time zones
 # though, as far as we know.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Curacao	-4:35:47 -	LMT	1912 Feb 12	# Willemstad
 			-4:30	-	ANT	1965 # Netherlands Antilles Time
 			-4:00	-	AST
 
 # From Arthur David Olson (2011-06-15):
 # At least for now, use links for places with new iso3166 codes.
 # The name "Lower Prince's Quarter" is both longer than fourteen charaters
 # and contains an apostrophe; use "Lower_Princes" below.
 
 Link	America/Curacao	America/Lower_Princes # Sint Maarten
 Link	America/Curacao	America/Kralendijk # Bonaire, Sint Estatius and Saba
 
 # Ecuador
 #
 # Milne says the Sentral and South American Telegraph Company used -5:24:15.
 #
 # From Paul Eggert (2007-03-04):
 # Apparently Ecuador had a failed experiment with DST in 1992.
 #  (2007-02-27) and
 #  (2006-11-06) both
 # talk about "hora Sixto".  Leave this alone for now, as we have no data.
 #
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Guayaquil	-5:19:20 -	LMT	1890
 			-5:14:00 -	QMT	1931 # Quito Mean Time
 			-5:00	-	ECT	     # Ecuador Time
 Zone Pacific/Galapagos	-5:58:24 -	LMT	1931 # Puerto Baquerizo Moreno
 			-5:00	-	ECT	1986
 			-6:00	-	GALT	     # Galapagos Time
 
 # Falklands
 
 # From Paul Eggert (2006-03-22):
 # Between 1990 and 2000 inclusive, Shanks & Pottenger and the IATA agree except
 # the IATA gives 1996-09-08.  Go with Shanks & Pottenger.
 
 # From Falkland Islands Government Office, London (2001-01-22)
 # via Jesper Norgaard:
 # ... the clocks revert back to Local Mean Time at 2 am on Sunday 15
 # April 2001 and advance one hour to summer time at 2 am on Sunday 2
 # September.  It is anticipated that the clocks will revert back at 2
 # am on Sunday 21 April 2002 and advance to summer time at 2 am on
 # Sunday 1 September.
 
 # From Rives McDow (2001-02-13):
 #
 # I have communicated several times with people there, and the last
 # time I had communications that was helpful was in 1998.  Here is
 # what was said then:
 #
 # "The general rule was that Stanley used daylight saving and the Camp
 # did not. However for various reasons many people in the Camp have
 # started to use daylight saving (known locally as 'Stanley Time')
 # There is no rule as to who uses daylight saving - it is a matter of
 # personal choice and so it is impossible to draw a map showing who
 # uses it and who does not. Any list would be out of date as soon as
 # it was produced. This year daylight saving ended on April 18/19th
 # and started again on September 12/13th.  I do not know what the rule
 # is, but can find out if you like.  We do not change at the same time
 # as UK or Chile."
 #
 # I did have in my notes that the rule was "Second Saturday in Sep at
 # 0:00 until third Saturday in Apr at 0:00".  I think that this does
 # not agree in some cases with Shanks; is this true?
 #
 # Also, there is no mention in the list that some areas in the
 # Falklands do not use DST.  I have found in my communications there
 # that these areas are on the western half of East Falkland and all of
 # West Falkland.  Stanley is the only place that consistently observes
 # DST.  Again, as in other places in the world, the farmers don't like
 # it.  West Falkland is almost entirely sheep farmers.
 #
 # I know one lady there that keeps a list of which farm keeps DST and
 # which doesn't each year.  She runs a shop in Stanley, and says that
 # the list changes each year.  She uses it to communicate to her
 # customers, catching them when they are home for lunch or dinner.
 
 # From Paul Eggert (2001-03-05):
 # For now, we'll just record the time in Stanley, since we have no
 # better info.
 
 # From Steffen Thorsen (2011-04-01):
 # The Falkland Islands will not turn back clocks this winter, but stay on
 # daylight saving time.
 #
 # One source:
 # 
 # http://www.falklandnews.com/public/story.cfm?get=5914&source=3
 # 
 #
 # We have gotten this confirmed by a clerk of the legislative assembly:
 # Normally the clocks revert to Local Mean Time (UTC/GMT -4 hours) on the
 # third Sunday of April at 0200hrs and advance to Summer Time (UTC/GMT -3
 # hours) on the first Sunday of September at 0200hrs.
 #
 # IMPORTANT NOTE: During 2011, on a trial basis, the Falkland Islands
 # will not revert to local mean time, but clocks will remain on Summer
 # time (UTC/GMT - 3 hours) throughout the whole of 2011.  Any long term
 # change to local time following the trial period will be notified.
 #
 # From Andrew Newman (2012-02-24)
 # A letter from Justin McPhee, Chief Executive,
 # Cable & Wireless Falkland Islands (dated 2012-02-22)
 # states...
 #   The current Atlantic/Stanley entry under South America expects the
 #   clocks to go back to standard Falklands Time (FKT) on the 15th April.
 #   The database entry states that in 2011 Stanley was staying on fixed
 #   summer time on a trial basis only.  FIG need to contact IANA and/or
 #   the maintainers of the database to inform them we're adopting
 #   the same policy this year and suggest recommendations for future years.
 #
 # For now we will assume permanent summer time for the Falklands
 # until advised differently (to apply for 2012 and beyond, after the 2011
 # experiment was apparently successful.)
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Falk	1937	1938	-	Sep	lastSun	0:00	1:00	S
 Rule	Falk	1938	1942	-	Mar	Sun>=19	0:00	0	-
 Rule	Falk	1939	only	-	Oct	1	0:00	1:00	S
 Rule	Falk	1940	1942	-	Sep	lastSun	0:00	1:00	S
 Rule	Falk	1943	only	-	Jan	1	0:00	0	-
 Rule	Falk	1983	only	-	Sep	lastSun	0:00	1:00	S
 Rule	Falk	1984	1985	-	Apr	lastSun	0:00	0	-
 Rule	Falk	1984	only	-	Sep	16	0:00	1:00	S
 Rule	Falk	1985	2000	-	Sep	Sun>=9	0:00	1:00	S
 Rule	Falk	1986	2000	-	Apr	Sun>=16	0:00	0	-
 Rule	Falk	2001	2010	-	Apr	Sun>=15	2:00	0	-
 Rule	Falk	2001	2010	-	Sep	Sun>=1	2:00	1:00	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Stanley	-3:51:24 -	LMT	1890
 			-3:51:24 -	SMT	1912 Mar 12  # Stanley Mean Time
 			-4:00	Falk	FK%sT	1983 May     # Falkland Is Time
 			-3:00	Falk	FK%sT	1985 Sep 15
 			-4:00	Falk	FK%sT	2010 Sep 5 02:00
 			-3:00	-	FKST
 
 # French Guiana
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Cayenne	-3:29:20 -	LMT	1911 Jul
 			-4:00	-	GFT	1967 Oct # French Guiana Time
 			-3:00	-	GFT
 
 # Guyana
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Guyana	-3:52:40 -	LMT	1915 Mar	# Georgetown
 			-3:45	-	GBGT	1966 May 26 # Br Guiana Time
 			-3:45	-	GYT	1975 Jul 31 # Guyana Time
 			-3:00	-	GYT	1991
 # IATA SSIM (1996-06) says -4:00.  Assume a 1991 switch.
 			-4:00	-	GYT
 
 # Paraguay
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger say that spring transitions are from 01:00 -> 02:00,
 # and autumn transitions are from 00:00 -> 23:00.  Go with pre-1999
 # editions of Shanks, and with the IATA, who say transitions occur at 00:00.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Para	1975	1988	-	Oct	 1	0:00	1:00	S
 Rule	Para	1975	1978	-	Mar	 1	0:00	0	-
 Rule	Para	1979	1991	-	Apr	 1	0:00	0	-
 Rule	Para	1989	only	-	Oct	22	0:00	1:00	S
 Rule	Para	1990	only	-	Oct	 1	0:00	1:00	S
 Rule	Para	1991	only	-	Oct	 6	0:00	1:00	S
 Rule	Para	1992	only	-	Mar	 1	0:00	0	-
 Rule	Para	1992	only	-	Oct	 5	0:00	1:00	S
 Rule	Para	1993	only	-	Mar	31	0:00	0	-
 Rule	Para	1993	1995	-	Oct	 1	0:00	1:00	S
 Rule	Para	1994	1995	-	Feb	lastSun	0:00	0	-
 Rule	Para	1996	only	-	Mar	 1	0:00	0	-
 # IATA SSIM (2000-02) says 1999-10-10; ignore this for now.
 # From Steffen Thorsen (2000-10-02):
 # I have three independent reports that Paraguay changed to DST this Sunday
 # (10-01).
 #
 # Translated by Gwillim Law (2001-02-27) from
 # 
 # Noticias, a daily paper in Asuncion, Paraguay (2000-10-01)
 # :
 # Starting at 0:00 today, the clock will be set forward 60 minutes, in
 # fulfillment of Decree No. 7,273 of the Executive Power....  The time change
 # system has been operating for several years.  Formerly there was a separate
 # decree each year; the new law has the same effect, but permanently.  Every
 # year, the time will change on the first Sunday of October; likewise, the
 # clock will be set back on the first Sunday of March.
 #
 Rule	Para	1996	2001	-	Oct	Sun>=1	0:00	1:00	S
 # IATA SSIM (1997-09) says Mar 1; go with Shanks & Pottenger.
 Rule	Para	1997	only	-	Feb	lastSun	0:00	0	-
 # Shanks & Pottenger say 1999-02-28; IATA SSIM (1999-02) says 1999-02-27, but
 # (1999-09) reports no date; go with above sources and Gerd Knops (2001-02-27).
 Rule	Para	1998	2001	-	Mar	Sun>=1	0:00	0	-
 # From Rives McDow (2002-02-28):
 # A decree was issued in Paraguay (no. 16350) on 2002-02-26 that changed the
 # dst method to be from the first Sunday in September to the first Sunday in
 # April.
 Rule	Para	2002	2004	-	Apr	Sun>=1	0:00	0	-
 Rule	Para	2002	2003	-	Sep	Sun>=1	0:00	1:00	S
 #
 # From Jesper Norgaard Welen (2005-01-02):
 # There are several sources that claim that Paraguay made
 # a timezone rule change in autumn 2004.
 # From Steffen Thorsen (2005-01-05):
 # Decree 1,867 (2004-03-05)
 # From Carlos Raul Perasso via Jesper Norgaard Welen (2006-10-13)
 # 
 Rule	Para	2004	2009	-	Oct	Sun>=15	0:00	1:00	S
 Rule	Para	2005	2009	-	Mar	Sun>=8	0:00	0	-
 # From Carlos Raul Perasso (2010-02-18):
 # By decree number 3958 issued yesterday (
 # 
 # http://www.presidencia.gov.py/v1/wp-content/uploads/2010/02/decreto3958.pdf
 # 
 # )
 # Paraguay changes its DST schedule, postponing the March rule to April and
 # modifying the October date. The decree reads:
 # ...
 # Art. 1. It is hereby established that from the second Sunday of the month of
 # April of this year (2010), the official time is to be set back 60 minutes,
 # and that on the first Sunday of the month of October, it is to be set
 # forward 60 minutes, in all the territory of the Paraguayan Republic.
 # ...
 Rule	Para	2010	max	-	Oct	Sun>=1	0:00	1:00	S
-Rule	Para	2010	max	-	Apr	Sun>=8	0:00	0	-
+Rule	Para	2010	2012	-	Apr	Sun>=8	0:00	0	-
 #
 # From Steffen Thorsen (2013-03-07):
 # Paraguay will end DST on 2013-03-24 00:00....
-# They do not tell if this will be a permanent change or just this year....
 # http://www.ande.gov.py/interna.php?id=1075
 #
-# From Paul Eggert (2013-03-07):
-# For now, assume it's just this year.
-Rule	Para	2013	only	-	Mar	24	0:00	0	-
+# From Carlos Raul Perasso (2013-03-15):
+# The change in Paraguay is now final.  Decree number 10780
+# http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf
+Rule	Para	2013	max	-	Mar	Sun>=22	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Asuncion	-3:50:40 -	LMT	1890
 			-3:50:40 -	AMT	1931 Oct 10 # Asuncion Mean Time
 			-4:00	-	PYT	1972 Oct # Paraguay Time
 			-3:00	-	PYT	1974 Apr
 			-4:00	Para	PY%sT
 
 # Peru
 #
 # 
 # From Evelyn C. Leeper via Mark Brader (2003-10-26):
 # When we were in Peru in 1985-1986, they apparently switched over
 # sometime between December 29 and January 3 while we were on the Amazon.
 #
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger don't have this transition.  Assume 1986 was like 1987.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Peru	1938	only	-	Jan	 1	0:00	1:00	S
 Rule	Peru	1938	only	-	Apr	 1	0:00	0	-
 Rule	Peru	1938	1939	-	Sep	lastSun	0:00	1:00	S
 Rule	Peru	1939	1940	-	Mar	Sun>=24	0:00	0	-
 Rule	Peru	1986	1987	-	Jan	 1	0:00	1:00	S
 Rule	Peru	1986	1987	-	Apr	 1	0:00	0	-
 Rule	Peru	1990	only	-	Jan	 1	0:00	1:00	S
 Rule	Peru	1990	only	-	Apr	 1	0:00	0	-
 # IATA is ambiguous for 1993/1995; go with Shanks & Pottenger.
 Rule	Peru	1994	only	-	Jan	 1	0:00	1:00	S
 Rule	Peru	1994	only	-	Apr	 1	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Lima	-5:08:12 -	LMT	1890
 			-5:08:36 -	LMT	1908 Jul 28 # Lima Mean Time?
 			-5:00	Peru	PE%sT	# Peru Time
 
 # South Georgia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/South_Georgia -2:26:08 -	LMT	1890		# Grytviken
 			-2:00	-	GST	# South Georgia Time
 
 # South Sandwich Is
 # uninhabited; scientific personnel have wintered
 
 # Suriname
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Paramaribo	-3:40:40 -	LMT	1911
 			-3:40:52 -	PMT	1935     # Paramaribo Mean Time
 			-3:40:36 -	PMT	1945 Oct # The capital moved?
 			-3:30	-	NEGT	1975 Nov 20 # Dutch Guiana Time
 			-3:30	-	SRT	1984 Oct # Suriname Time
 			-3:00	-	SRT
 
 # Trinidad and Tobago
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Port_of_Spain -4:06:04 -	LMT	1912 Mar 2
 			-4:00	-	AST
 
 # Uruguay
 # From Paul Eggert (1993-11-18):
 # Uruguay wins the prize for the strangest peacetime manipulation of the rules.
 # From Shanks & Pottenger:
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 # Whitman gives 1923 Oct 1; go with Shanks & Pottenger.
 Rule	Uruguay	1923	only	-	Oct	 2	 0:00	0:30	HS
 Rule	Uruguay	1924	1926	-	Apr	 1	 0:00	0	-
 Rule	Uruguay	1924	1925	-	Oct	 1	 0:00	0:30	HS
 Rule	Uruguay	1933	1935	-	Oct	lastSun	 0:00	0:30	HS
 # Shanks & Pottenger give 1935 Apr 1 0:00 & 1936 Mar 30 0:00; go with Whitman.
 Rule	Uruguay	1934	1936	-	Mar	Sat>=25	23:30s	0	-
 Rule	Uruguay	1936	only	-	Nov	 1	 0:00	0:30	HS
 Rule	Uruguay	1937	1941	-	Mar	lastSun	 0:00	0	-
 # Whitman gives 1937 Oct 3; go with Shanks & Pottenger.
 Rule	Uruguay	1937	1940	-	Oct	lastSun	 0:00	0:30	HS
 # Whitman gives 1941 Oct 24 - 1942 Mar 27, 1942 Dec 14 - 1943 Apr 13,
 # and 1943 Apr 13 ``to present time''; go with Shanks & Pottenger.
 Rule	Uruguay	1941	only	-	Aug	 1	 0:00	0:30	HS
 Rule	Uruguay	1942	only	-	Jan	 1	 0:00	0	-
 Rule	Uruguay	1942	only	-	Dec	14	 0:00	1:00	S
 Rule	Uruguay	1943	only	-	Mar	14	 0:00	0	-
 Rule	Uruguay	1959	only	-	May	24	 0:00	1:00	S
 Rule	Uruguay	1959	only	-	Nov	15	 0:00	0	-
 Rule	Uruguay	1960	only	-	Jan	17	 0:00	1:00	S
 Rule	Uruguay	1960	only	-	Mar	 6	 0:00	0	-
 Rule	Uruguay	1965	1967	-	Apr	Sun>=1	 0:00	1:00	S
 Rule	Uruguay	1965	only	-	Sep	26	 0:00	0	-
 Rule	Uruguay	1966	1967	-	Oct	31	 0:00	0	-
 Rule	Uruguay	1968	1970	-	May	27	 0:00	0:30	HS
 Rule	Uruguay	1968	1970	-	Dec	 2	 0:00	0	-
 Rule	Uruguay	1972	only	-	Apr	24	 0:00	1:00	S
 Rule	Uruguay	1972	only	-	Aug	15	 0:00	0	-
 Rule	Uruguay	1974	only	-	Mar	10	 0:00	0:30	HS
 Rule	Uruguay	1974	only	-	Dec	22	 0:00	1:00	S
 Rule	Uruguay	1976	only	-	Oct	 1	 0:00	0	-
 Rule	Uruguay	1977	only	-	Dec	 4	 0:00	1:00	S
 Rule	Uruguay	1978	only	-	Apr	 1	 0:00	0	-
 Rule	Uruguay	1979	only	-	Oct	 1	 0:00	1:00	S
 Rule	Uruguay	1980	only	-	May	 1	 0:00	0	-
 Rule	Uruguay	1987	only	-	Dec	14	 0:00	1:00	S
 Rule	Uruguay	1988	only	-	Mar	14	 0:00	0	-
 Rule	Uruguay	1988	only	-	Dec	11	 0:00	1:00	S
 Rule	Uruguay	1989	only	-	Mar	12	 0:00	0	-
 Rule	Uruguay	1989	only	-	Oct	29	 0:00	1:00	S
 # Shanks & Pottenger say no DST was observed in 1990/1 and 1991/2,
 # and that 1992/3's DST was from 10-25 to 03-01.  Go with IATA.
 Rule	Uruguay	1990	1992	-	Mar	Sun>=1	 0:00	0	-
 Rule	Uruguay	1990	1991	-	Oct	Sun>=21	 0:00	1:00	S
 Rule	Uruguay	1992	only	-	Oct	18	 0:00	1:00	S
 Rule	Uruguay	1993	only	-	Feb	28	 0:00	0	-
 # From Eduardo Cota (2004-09-20):
 # The uruguayan government has decreed a change in the local time....
 # http://www.presidencia.gub.uy/decretos/2004091502.htm
 Rule	Uruguay	2004	only	-	Sep	19	 0:00	1:00	S
 # From Steffen Thorsen (2005-03-11):
 # Uruguay's DST was scheduled to end on Sunday, 2005-03-13, but in order to
 # save energy ... it was postponed two weeks....
 # http://www.presidencia.gub.uy/_Web/noticias/2005/03/2005031005.htm
 Rule	Uruguay	2005	only	-	Mar	27	 2:00	0	-
 # From Eduardo Cota (2005-09-27):
 # http://www.presidencia.gub.uy/_Web/decretos/2005/09/CM%20119_09%2009%202005_00001.PDF
 # This means that from 2005-10-09 at 02:00 local time, until 2006-03-12 at
 # 02:00 local time, official time in Uruguay will be at GMT -2.
 Rule	Uruguay	2005	only	-	Oct	 9	 2:00	1:00	S
 Rule	Uruguay	2006	only	-	Mar	12	 2:00	0	-
 # From Jesper Norgaard Welen (2006-09-06):
 # http://www.presidencia.gub.uy/_web/decretos/2006/09/CM%20210_08%2006%202006_00001.PDF
 Rule	Uruguay	2006	max	-	Oct	Sun>=1	 2:00	1:00	S
 Rule	Uruguay	2007	max	-	Mar	Sun>=8	 2:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Montevideo	-3:44:44 -	LMT	1898 Jun 28
 			-3:44:44 -	MMT	1920 May  1	# Montevideo MT
 			-3:30	Uruguay	UY%sT	1942 Dec 14	# Uruguay Time
 			-3:00	Uruguay	UY%sT
 
 # Venezuela
 #
 # From John Stainforth (2007-11-28):
 # ... the change for Venezuela originally expected for 2007-12-31 has
 # been brought forward to 2007-12-09.  The official announcement was
 # published today in the "Gaceta Oficial de la Republica Bolivariana
 # de Venezuela, numero 38.819" (official document for all laws or
 # resolution publication)
 # http://www.globovision.com/news.php?nid=72208
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Caracas	-4:27:44 -	LMT	1890
 			-4:27:40 -	CMT	1912 Feb 12 # Caracas Mean Time?
 			-4:30	-	VET	1965	     # Venezuela Time
 			-4:00	-	VET	2007 Dec  9 03:00
 			-4:30	-	VET
Index: user/attilio/vmcontention/contrib/tzdata/zone.tab
===================================================================
--- user/attilio/vmcontention/contrib/tzdata/zone.tab	(revision 249698)
+++ user/attilio/vmcontention/contrib/tzdata/zone.tab	(revision 249699)
@@ -1,444 +1,444 @@
 # 
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
 # TZ zone descriptions
 #
 # From Paul Eggert (1996-08-05):
 #
 # This file contains a table with the following columns:
 # 1.  ISO 3166 2-character country code.  See /usr/share/misc/iso3166.
 # 2.  Latitude and longitude of the zone's principal location
 #     in ISO 6709 sign-degrees-minutes-seconds format,
 #     either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
 #     first latitude (+ is north), then longitude (+ is east).
 # 3.  Zone name used in value of TZ environment variable.
 # 4.  Comments; present if and only if the country has multiple rows.
 #
 # Columns are separated by a single tab.
 # The table is sorted first by country, then an order within the country that
 # (1) makes some geographical sense, and
 # (2) puts the most populous zones first, where that does not contradict (1).
 #
 # Lines beginning with `#' are comments.
 #
 #country-
 #code	coordinates	TZ			comments
 AD	+4230+00131	Europe/Andorra
 AE	+2518+05518	Asia/Dubai
 AF	+3431+06912	Asia/Kabul
 AG	+1703-06148	America/Antigua
 AI	+1812-06304	America/Anguilla
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
 AO	-0848+01314	Africa/Luanda
 AQ	-7750+16636	Antarctica/McMurdo	McMurdo Station, Ross Island
 AQ	-9000+00000	Antarctica/South_Pole	Amundsen-Scott Station, South Pole
 AQ	-6734-06808	Antarctica/Rothera	Rothera Station, Adelaide Island
 AQ	-6448-06406	Antarctica/Palmer	Palmer Station, Anvers Island
 AQ	-6736+06253	Antarctica/Mawson	Mawson Station, Holme Bay
 AQ	-6835+07758	Antarctica/Davis	Davis Station, Vestfold Hills
 AQ	-6617+11031	Antarctica/Casey	Casey Station, Bailey Peninsula
 AQ	-7824+10654	Antarctica/Vostok	Vostok Station, Lake Vostok
 AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Terre Adelie
 AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
-AQ	-5430+15857	Antarctica/Macquarie	Macquarie Island Station, Macquarie Island
 AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
 AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, MN, SE, SF)
 AR	-2447-06525	America/Argentina/Salta	(SA, LP, NQ, RN)
 AR	-2411-06518	America/Argentina/Jujuy	Jujuy (JY)
 AR	-2649-06513	America/Argentina/Tucuman	Tucuman (TM)
 AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT), Chubut (CH)
 AR	-2926-06651	America/Argentina/La_Rioja	La Rioja (LR)
 AR	-3132-06831	America/Argentina/San_Juan	San Juan (SJ)
 AR	-3253-06849	America/Argentina/Mendoza	Mendoza (MZ)
 AR	-3319-06621	America/Argentina/San_Luis	San Luis (SL)
 AR	-5138-06913	America/Argentina/Rio_Gallegos	Santa Cruz (SC)
 AR	-5448-06818	America/Argentina/Ushuaia	Tierra del Fuego (TF)
 AS	-1416-17042	Pacific/Pago_Pago
 AT	+4813+01620	Europe/Vienna
 AU	-3133+15905	Australia/Lord_Howe	Lord Howe Island
+AU	-5430+15857	Antarctica/Macquarie	Macquarie Island
 AU	-4253+14719	Australia/Hobart	Tasmania - most locations
 AU	-3956+14352	Australia/Currie	Tasmania - King Island
 AU	-3749+14458	Australia/Melbourne	Victoria
 AU	-3352+15113	Australia/Sydney	New South Wales - most locations
 AU	-3157+14127	Australia/Broken_Hill	New South Wales - Yancowinna
 AU	-2728+15302	Australia/Brisbane	Queensland - most locations
 AU	-2016+14900	Australia/Lindeman	Queensland - Holiday Islands
 AU	-3455+13835	Australia/Adelaide	South Australia
 AU	-1228+13050	Australia/Darwin	Northern Territory
 AU	-3157+11551	Australia/Perth	Western Australia - most locations
 AU	-3143+12852	Australia/Eucla	Western Australia - Eucla area
 AW	+1230-06958	America/Aruba
 AX	+6006+01957	Europe/Mariehamn
 AZ	+4023+04951	Asia/Baku
 BA	+4352+01825	Europe/Sarajevo
 BB	+1306-05937	America/Barbados
 BD	+2343+09025	Asia/Dhaka
 BE	+5050+00420	Europe/Brussels
 BF	+1222-00131	Africa/Ouagadougou
 BG	+4241+02319	Europe/Sofia
 BH	+2623+05035	Asia/Bahrain
 BI	-0323+02922	Africa/Bujumbura
 BJ	+0629+00237	Africa/Porto-Novo
 BL	+1753-06251	America/St_Barthelemy
 BM	+3217-06446	Atlantic/Bermuda
 BN	+0456+11455	Asia/Brunei
 BO	-1630-06809	America/La_Paz
 BQ	+120903-0681636	America/Kralendijk
 BR	-0351-03225	America/Noronha	Atlantic islands
 BR	-0127-04829	America/Belem	Amapa, E Para
 BR	-0343-03830	America/Fortaleza	NE Brazil (MA, PI, CE, RN, PB)
 BR	-0803-03454	America/Recife	Pernambuco
 BR	-0712-04812	America/Araguaina	Tocantins
 BR	-0940-03543	America/Maceio	Alagoas, Sergipe
 BR	-1259-03831	America/Bahia	Bahia
 BR	-2332-04637	America/Sao_Paulo	S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
 BR	-2027-05437	America/Campo_Grande	Mato Grosso do Sul
 BR	-1535-05605	America/Cuiaba	Mato Grosso
 BR	-0226-05452	America/Santarem	W Para
 BR	-0846-06354	America/Porto_Velho	Rondonia
 BR	+0249-06040	America/Boa_Vista	Roraima
 BR	-0308-06001	America/Manaus	E Amazonas
 BR	-0640-06952	America/Eirunepe	W Amazonas
 BR	-0958-06748	America/Rio_Branco	Acre
 BS	+2505-07721	America/Nassau
 BT	+2728+08939	Asia/Thimphu
 BW	-2439+02555	Africa/Gaborone
 BY	+5354+02734	Europe/Minsk
 BZ	+1730-08812	America/Belize
 CA	+4734-05243	America/St_Johns	Newfoundland Time, including SE Labrador
 CA	+4439-06336	America/Halifax	Atlantic Time - Nova Scotia (most places), PEI
 CA	+4612-05957	America/Glace_Bay	Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971
 CA	+4606-06447	America/Moncton	Atlantic Time - New Brunswick
 CA	+5320-06025	America/Goose_Bay	Atlantic Time - Labrador - most locations
 CA	+5125-05707	America/Blanc-Sablon	Atlantic Standard Time - Quebec - Lower North Shore
 CA	+4531-07334	America/Montreal	Eastern Time - Quebec - most locations
 CA	+4339-07923	America/Toronto	Eastern Time - Ontario - most locations
 CA	+4901-08816	America/Nipigon	Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
 CA	+4823-08915	America/Thunder_Bay	Eastern Time - Thunder Bay, Ontario
 CA	+6344-06828	America/Iqaluit	Eastern Time - east Nunavut - most locations
 CA	+6608-06544	America/Pangnirtung	Eastern Time - Pangnirtung, Nunavut
 CA	+744144-0944945	America/Resolute	Central Standard Time - Resolute, Nunavut
 CA	+484531-0913718	America/Atikokan	Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut
 CA	+624900-0920459	America/Rankin_Inlet	Central Time - central Nunavut
 CA	+4953-09709	America/Winnipeg	Central Time - Manitoba & west Ontario
 CA	+4843-09434	America/Rainy_River	Central Time - Rainy River & Fort Frances, Ontario
 CA	+5024-10439	America/Regina	Central Standard Time - Saskatchewan - most locations
 CA	+5017-10750	America/Swift_Current	Central Standard Time - Saskatchewan - midwest
 CA	+5333-11328	America/Edmonton	Mountain Time - Alberta, east British Columbia & west Saskatchewan
 CA	+690650-1050310	America/Cambridge_Bay	Mountain Time - west Nunavut
 CA	+6227-11421	America/Yellowknife	Mountain Time - central Northwest Territories
 CA	+682059-1334300	America/Inuvik	Mountain Time - west Northwest Territories
 CA	+4906-11631	America/Creston	Mountain Standard Time - Creston, British Columbia
 CA	+5946-12014	America/Dawson_Creek	Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
 CA	+4916-12307	America/Vancouver	Pacific Time - west British Columbia
 CA	+6043-13503	America/Whitehorse	Pacific Time - south Yukon
 CA	+6404-13925	America/Dawson	Pacific Time - north Yukon
 CC	-1210+09655	Indian/Cocos
 CD	-0418+01518	Africa/Kinshasa	west Dem. Rep. of Congo
 CD	-1140+02728	Africa/Lubumbashi	east Dem. Rep. of Congo
 CF	+0422+01835	Africa/Bangui
 CG	-0416+01517	Africa/Brazzaville
 CH	+4723+00832	Europe/Zurich
 CI	+0519-00402	Africa/Abidjan
 CK	-2114-15946	Pacific/Rarotonga
 CL	-3327-07040	America/Santiago	most locations
 CL	-2709-10926	Pacific/Easter	Easter Island & Sala y Gomez
 CM	+0403+00942	Africa/Douala
 CN	+3114+12128	Asia/Shanghai	east China - Beijing, Guangdong, Shanghai, etc.
 CN	+4545+12641	Asia/Harbin	Heilongjiang (except Mohe), Jilin
 CN	+2934+10635	Asia/Chongqing	central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
 CN	+4348+08735	Asia/Urumqi	most of Tibet & Xinjiang
 CN	+3929+07559	Asia/Kashgar	west Tibet & Xinjiang
 CO	+0436-07405	America/Bogota
 CR	+0956-08405	America/Costa_Rica
 CU	+2308-08222	America/Havana
 CV	+1455-02331	Atlantic/Cape_Verde
 CW	+1211-06900	America/Curacao
 CX	-1025+10543	Indian/Christmas
 CY	+3510+03322	Asia/Nicosia
 CZ	+5005+01426	Europe/Prague
 DE	+5230+01322	Europe/Berlin	most locations
 DE	+4742+00841	Europe/Busingen	Busingen
 DJ	+1136+04309	Africa/Djibouti
 DK	+5540+01235	Europe/Copenhagen
 DM	+1518-06124	America/Dominica
 DO	+1828-06954	America/Santo_Domingo
 DZ	+3647+00303	Africa/Algiers
 EC	-0210-07950	America/Guayaquil	mainland
 EC	-0054-08936	Pacific/Galapagos	Galapagos Islands
 EE	+5925+02445	Europe/Tallinn
 EG	+3003+03115	Africa/Cairo
 EH	+2709-01312	Africa/El_Aaiun
 ER	+1520+03853	Africa/Asmara
 ES	+4024-00341	Europe/Madrid	mainland
 ES	+3553-00519	Africa/Ceuta	Ceuta & Melilla
 ES	+2806-01524	Atlantic/Canary	Canary Islands
 ET	+0902+03842	Africa/Addis_Ababa
 FI	+6010+02458	Europe/Helsinki
 FJ	-1808+17825	Pacific/Fiji
 FK	-5142-05751	Atlantic/Stanley
 FM	+0725+15147	Pacific/Chuuk	Chuuk (Truk) and Yap
 FM	+0658+15813	Pacific/Pohnpei	Pohnpei (Ponape)
 FM	+0519+16259	Pacific/Kosrae	Kosrae
 FO	+6201-00646	Atlantic/Faroe
 FR	+4852+00220	Europe/Paris
 GA	+0023+00927	Africa/Libreville
 GB	+513030-0000731	Europe/London
 GD	+1203-06145	America/Grenada
 GE	+4143+04449	Asia/Tbilisi
 GF	+0456-05220	America/Cayenne
 GG	+4927-00232	Europe/Guernsey
 GH	+0533-00013	Africa/Accra
 GI	+3608-00521	Europe/Gibraltar
 GL	+6411-05144	America/Godthab	most locations
 GL	+7646-01840	America/Danmarkshavn	east coast, north of Scoresbysund
 GL	+7029-02158	America/Scoresbysund	Scoresbysund / Ittoqqortoormiit
 GL	+7634-06847	America/Thule	Thule / Pituffik
 GM	+1328-01639	Africa/Banjul
 GN	+0931-01343	Africa/Conakry
 GP	+1614-06132	America/Guadeloupe
 GQ	+0345+00847	Africa/Malabo
 GR	+3758+02343	Europe/Athens
 GS	-5416-03632	Atlantic/South_Georgia
 GT	+1438-09031	America/Guatemala
 GU	+1328+14445	Pacific/Guam
 GW	+1151-01535	Africa/Bissau
 GY	+0648-05810	America/Guyana
 HK	+2217+11409	Asia/Hong_Kong
 HN	+1406-08713	America/Tegucigalpa
 HR	+4548+01558	Europe/Zagreb
 HT	+1832-07220	America/Port-au-Prince
 HU	+4730+01905	Europe/Budapest
 ID	-0610+10648	Asia/Jakarta	Java & Sumatra
 ID	-0002+10920	Asia/Pontianak	west & central Borneo
 ID	-0507+11924	Asia/Makassar	east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
 ID	-0232+14042	Asia/Jayapura	west New Guinea (Irian Jaya) & Malukus (Moluccas)
 IE	+5320-00615	Europe/Dublin
 IL	+3146+03514	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
 IN	+2232+08822	Asia/Kolkata
 IO	-0720+07225	Indian/Chagos
 IQ	+3321+04425	Asia/Baghdad
 IR	+3540+05126	Asia/Tehran
 IS	+6409-02151	Atlantic/Reykjavik
 IT	+4154+01229	Europe/Rome
 JE	+4912-00207	Europe/Jersey
 JM	+1800-07648	America/Jamaica
 JO	+3157+03556	Asia/Amman
 JP	+353916+1394441	Asia/Tokyo
 KE	-0117+03649	Africa/Nairobi
 KG	+4254+07436	Asia/Bishkek
 KH	+1133+10455	Asia/Phnom_Penh
 KI	+0125+17300	Pacific/Tarawa	Gilbert Islands
 KI	-0308-17105	Pacific/Enderbury	Phoenix Islands
 KI	+0152-15720	Pacific/Kiritimati	Line Islands
 KM	-1141+04316	Indian/Comoro
 KN	+1718-06243	America/St_Kitts
 KP	+3901+12545	Asia/Pyongyang
 KR	+3733+12658	Asia/Seoul
 KW	+2920+04759	Asia/Kuwait
 KY	+1918-08123	America/Cayman
 KZ	+4315+07657	Asia/Almaty	most locations
 KZ	+4448+06528	Asia/Qyzylorda	Qyzylorda (Kyzylorda, Kzyl-Orda)
 KZ	+5017+05710	Asia/Aqtobe	Aqtobe (Aktobe)
 KZ	+4431+05016	Asia/Aqtau	Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)
 KZ	+5113+05121	Asia/Oral	West Kazakhstan
 LA	+1758+10236	Asia/Vientiane
 LB	+3353+03530	Asia/Beirut
 LC	+1401-06100	America/St_Lucia
 LI	+4709+00931	Europe/Vaduz
 LK	+0656+07951	Asia/Colombo
 LR	+0618-01047	Africa/Monrovia
 LS	-2928+02730	Africa/Maseru
 LT	+5441+02519	Europe/Vilnius
 LU	+4936+00609	Europe/Luxembourg
 LV	+5657+02406	Europe/Riga
 LY	+3254+01311	Africa/Tripoli
 MA	+3339-00735	Africa/Casablanca
 MC	+4342+00723	Europe/Monaco
 MD	+4700+02850	Europe/Chisinau
 ME	+4226+01916	Europe/Podgorica
 MF	+1804-06305	America/Marigot
 MG	-1855+04731	Indian/Antananarivo
 MH	+0709+17112	Pacific/Majuro	most locations
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
 MK	+4159+02126	Europe/Skopje
 ML	+1239-00800	Africa/Bamako
 MM	+1647+09610	Asia/Rangoon
 MN	+4755+10653	Asia/Ulaanbaatar	most locations
 MN	+4801+09139	Asia/Hovd	Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan
 MN	+4804+11430	Asia/Choibalsan	Dornod, Sukhbaatar
 MO	+2214+11335	Asia/Macau
 MP	+1512+14545	Pacific/Saipan
 MQ	+1436-06105	America/Martinique
 MR	+1806-01557	Africa/Nouakchott
 MS	+1643-06213	America/Montserrat
 MT	+3554+01431	Europe/Malta
 MU	-2010+05730	Indian/Mauritius
 MV	+0410+07330	Indian/Maldives
 MW	-1547+03500	Africa/Blantyre
 MX	+1924-09909	America/Mexico_City	Central Time - most locations
 MX	+2105-08646	America/Cancun	Central Time - Quintana Roo
 MX	+2058-08937	America/Merida	Central Time - Campeche, Yucatan
 MX	+2540-10019	America/Monterrey	Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
 MX	+2550-09730	America/Matamoros	US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
 MX	+2313-10625	America/Mazatlan	Mountain Time - S Baja, Nayarit, Sinaloa
 MX	+2838-10605	America/Chihuahua	Mexican Mountain Time - Chihuahua away from US border
 MX	+2934-10425	America/Ojinaga	US Mountain Time - Chihuahua near US border
 MX	+2904-11058	America/Hermosillo	Mountain Standard Time - Sonora
 MX	+3232-11701	America/Tijuana	US Pacific Time - Baja California near US border
 MX	+3018-11452	America/Santa_Isabel	Mexican Pacific Time - Baja California away from US border
 MX	+2048-10515	America/Bahia_Banderas	Mexican Central Time - Bahia de Banderas
 MY	+0310+10142	Asia/Kuala_Lumpur	peninsular Malaysia
 MY	+0133+11020	Asia/Kuching	Sabah & Sarawak
 MZ	-2558+03235	Africa/Maputo
 NA	-2234+01706	Africa/Windhoek
 NC	-2216+16627	Pacific/Noumea
 NE	+1331+00207	Africa/Niamey
 NF	-2903+16758	Pacific/Norfolk
 NG	+0627+00324	Africa/Lagos
 NI	+1209-08617	America/Managua
 NL	+5222+00454	Europe/Amsterdam
 NO	+5955+01045	Europe/Oslo
 NP	+2743+08519	Asia/Kathmandu
 NR	-0031+16655	Pacific/Nauru
 NU	-1901-16955	Pacific/Niue
 NZ	-3652+17446	Pacific/Auckland	most locations
 NZ	-4357-17633	Pacific/Chatham	Chatham Islands
 OM	+2336+05835	Asia/Muscat
 PA	+0858-07932	America/Panama
 PE	-1203-07703	America/Lima
 PF	-1732-14934	Pacific/Tahiti	Society Islands
 PF	-0900-13930	Pacific/Marquesas	Marquesas Islands
 PF	-2308-13457	Pacific/Gambier	Gambier Islands
 PG	-0930+14710	Pacific/Port_Moresby
 PH	+1435+12100	Asia/Manila
 PK	+2452+06703	Asia/Karachi
 PL	+5215+02100	Europe/Warsaw
 PM	+4703-05620	America/Miquelon
 PN	-2504-13005	Pacific/Pitcairn
 PR	+182806-0660622	America/Puerto_Rico
 PS	+3130+03428	Asia/Gaza	Gaza Strip
 PS	+313200+0350542	Asia/Hebron	West Bank
 PT	+3843-00908	Europe/Lisbon	mainland
 PT	+3238-01654	Atlantic/Madeira	Madeira Islands
 PT	+3744-02540	Atlantic/Azores	Azores
 PW	+0720+13429	Pacific/Palau
 PY	-2516-05740	America/Asuncion
 QA	+2517+05132	Asia/Qatar
 RE	-2052+05528	Indian/Reunion
 RO	+4426+02606	Europe/Bucharest
 RS	+4450+02030	Europe/Belgrade
 RU	+5443+02030	Europe/Kaliningrad	Moscow-01 - Kaliningrad
 RU	+5545+03735	Europe/Moscow	Moscow+00 - west Russia
 RU	+4844+04425	Europe/Volgograd	Moscow+00 - Caspian Sea
 RU	+5312+05009	Europe/Samara	Moscow+00 - Samara, Udmurtia
 RU	+5651+06036	Asia/Yekaterinburg	Moscow+02 - Urals
 RU	+5500+07324	Asia/Omsk	Moscow+03 - west Siberia
 RU	+5502+08255	Asia/Novosibirsk	Moscow+03 - Novosibirsk
 RU	+5345+08707	Asia/Novokuznetsk	Moscow+03 - Novokuznetsk
 RU	+5601+09250	Asia/Krasnoyarsk	Moscow+04 - Yenisei River
 RU	+5216+10420	Asia/Irkutsk	Moscow+05 - Lake Baikal
 RU	+6200+12940	Asia/Yakutsk	Moscow+06 - Lena River
 RU	+623923+1353314	Asia/Khandyga	Moscow+06 - Tomponsky, Ust-Maysky
 RU	+4310+13156	Asia/Vladivostok	Moscow+07 - Amur River
 RU	+4658+14242	Asia/Sakhalin	Moscow+07 - Sakhalin Island
 RU	+643337+1431336	Asia/Ust-Nera	Moscow+07 - Oymyakonsky
 RU	+5934+15048	Asia/Magadan	Moscow+08 - Magadan
 RU	+5301+15839	Asia/Kamchatka	Moscow+08 - Kamchatka
 RU	+6445+17729	Asia/Anadyr	Moscow+08 - Bering Sea
 RW	-0157+03004	Africa/Kigali
 SA	+2438+04643	Asia/Riyadh
 SB	-0932+16012	Pacific/Guadalcanal
 SC	-0440+05528	Indian/Mahe
 SD	+1536+03232	Africa/Khartoum
 SE	+5920+01803	Europe/Stockholm
 SG	+0117+10351	Asia/Singapore
 SH	-1555-00542	Atlantic/St_Helena
 SI	+4603+01431	Europe/Ljubljana
 SJ	+7800+01600	Arctic/Longyearbyen
 SK	+4809+01707	Europe/Bratislava
 SL	+0830-01315	Africa/Freetown
 SM	+4355+01228	Europe/San_Marino
 SN	+1440-01726	Africa/Dakar
 SO	+0204+04522	Africa/Mogadishu
 SR	+0550-05510	America/Paramaribo
 SS	+0451+03136	Africa/Juba
 ST	+0020+00644	Africa/Sao_Tome
 SV	+1342-08912	America/El_Salvador
 SX	+180305-0630250	America/Lower_Princes
 SY	+3330+03618	Asia/Damascus
 SZ	-2618+03106	Africa/Mbabane
 TC	+2128-07108	America/Grand_Turk
 TD	+1207+01503	Africa/Ndjamena
 TF	-492110+0701303	Indian/Kerguelen
 TG	+0608+00113	Africa/Lome
 TH	+1345+10031	Asia/Bangkok
 TJ	+3835+06848	Asia/Dushanbe
 TK	-0922-17114	Pacific/Fakaofo
 TL	-0833+12535	Asia/Dili
 TM	+3757+05823	Asia/Ashgabat
 TN	+3648+01011	Africa/Tunis
 TO	-2110-17510	Pacific/Tongatapu
 TR	+4101+02858	Europe/Istanbul
 TT	+1039-06131	America/Port_of_Spain
 TV	-0831+17913	Pacific/Funafuti
 TW	+2503+12130	Asia/Taipei
 TZ	-0648+03917	Africa/Dar_es_Salaam
 UA	+5026+03031	Europe/Kiev	most locations
 UA	+4837+02218	Europe/Uzhgorod	Ruthenia
 UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
 UA	+4457+03406	Europe/Simferopol	central Crimea
 UG	+0019+03225	Africa/Kampala
 UM	+1645-16931	Pacific/Johnston	Johnston Atoll
 UM	+2813-17722	Pacific/Midway	Midway Islands
 UM	+1917+16637	Pacific/Wake	Wake Island
 US	+404251-0740023	America/New_York	Eastern Time
 US	+421953-0830245	America/Detroit	Eastern Time - Michigan - most locations
 US	+381515-0854534	America/Kentucky/Louisville	Eastern Time - Kentucky - Louisville area
 US	+364947-0845057	America/Kentucky/Monticello	Eastern Time - Kentucky - Wayne County
 US	+394606-0860929	America/Indiana/Indianapolis	Eastern Time - Indiana - most locations
 US	+384038-0873143	America/Indiana/Vincennes	Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
 US	+410305-0863611	America/Indiana/Winamac	Eastern Time - Indiana - Pulaski County
 US	+382232-0862041	America/Indiana/Marengo	Eastern Time - Indiana - Crawford County
 US	+382931-0871643	America/Indiana/Petersburg	Eastern Time - Indiana - Pike County
 US	+384452-0850402	America/Indiana/Vevay	Eastern Time - Indiana - Switzerland County
 US	+415100-0873900	America/Chicago	Central Time
 US	+375711-0864541	America/Indiana/Tell_City	Central Time - Indiana - Perry County
 US	+411745-0863730	America/Indiana/Knox	Central Time - Indiana - Starke County
 US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
 US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
 US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota - Morton County (except Mandan area)
 US	+471551-1014640	America/North_Dakota/Beulah	Central Time - North Dakota - Mercer County
 US	+394421-1045903	America/Denver	Mountain Time
 US	+433649-1161209	America/Boise	Mountain Time - south Idaho & east Oregon
 US	+364708-1084111	America/Shiprock	Mountain Time - Navajo
 US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona
 US	+340308-1181434	America/Los_Angeles	Pacific Time
 US	+611305-1495401	America/Anchorage	Alaska Time
 US	+581807-1342511	America/Juneau	Alaska Time - Alaska panhandle
 US	+571035-1351807	America/Sitka	Alaska Time - southeast Alaska panhandle
 US	+593249-1394338	America/Yakutat	Alaska Time - Alaska panhandle neck
 US	+643004-1652423	America/Nome	Alaska Time - west Alaska
 US	+515248-1763929	America/Adak	Aleutian Islands
 US	+550737-1313435	America/Metlakatla	Metlakatla Time - Annette Island
 US	+211825-1575130	Pacific/Honolulu	Hawaii
 UY	-3453-05611	America/Montevideo
 UZ	+3940+06648	Asia/Samarkand	west Uzbekistan
 UZ	+4120+06918	Asia/Tashkent	east Uzbekistan
 VA	+415408+0122711	Europe/Vatican
 VC	+1309-06114	America/St_Vincent
 VE	+1030-06656	America/Caracas
 VG	+1827-06437	America/Tortola
 VI	+1821-06456	America/St_Thomas
 VN	+1045+10640	Asia/Ho_Chi_Minh
 VU	-1740+16825	Pacific/Efate
 WF	-1318-17610	Pacific/Wallis
 WS	-1350-17144	Pacific/Apia
 YE	+1245+04512	Asia/Aden
 YT	-1247+04514	Indian/Mayotte
 ZA	-2615+02800	Africa/Johannesburg
 ZM	-1525+02817	Africa/Lusaka
 ZW	-1750+03103	Africa/Harare
Index: user/attilio/vmcontention/contrib/tzdata
===================================================================
--- user/attilio/vmcontention/contrib/tzdata	(revision 249698)
+++ user/attilio/vmcontention/contrib/tzdata	(revision 249699)

Property changes on: user/attilio/vmcontention/contrib/tzdata
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/contrib/tzdata:r248447-249698
   Merged /vendor/tzdata/dist:r249690
Index: user/attilio/vmcontention/lib/csu/Makefile.inc
===================================================================
--- user/attilio/vmcontention/lib/csu/Makefile.inc	(revision 249698)
+++ user/attilio/vmcontention/lib/csu/Makefile.inc	(revision 249699)
@@ -1,7 +1,9 @@
 # $FreeBSD$
 
 SSP_CFLAGS=
 
 SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/'
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include "../Makefile.inc"
Index: user/attilio/vmcontention/lib/libprocstat/Makefile
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/Makefile	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/Makefile	(revision 249699)
@@ -1,40 +1,41 @@
 # $FreeBSD$
 
 .include 
 
 LIB=	procstat
 
 SRCS=	cd9660.c	\
 	common_kvm.c	\
+	core.c		\
 	libprocstat.c	\
         msdosfs.c	\
 	udf.c
 
 VERSION_DEF=	${.CURDIR}/Versions.def
 SYMBOL_MAPS=	${.CURDIR}/Symbol.map
 
 INCS=		libprocstat.h
 CFLAGS+=	-I. -I${.CURDIR} -D_KVM_VNODE
 SHLIB_MAJOR=	1
 
-DPADD=		${LIBKVM} ${LIBUTIL}
-LDADD=		-lkvm -lutil
+DPADD=		${LIBELF} ${LIBKVM} ${LIBUTIL}
+LDADD=		-lelf -lkvm -lutil
 
 MAN=		libprocstat.3
 
 # XXX This is a hack.
 .if ${MK_CDDL} != "no"
 CFLAGS+=	-DLIBPROCSTAT_ZFS
 OBJS+=	zfs/zfs.o
 SOBJS+=	zfs/zfs.So
 POBJS+=	zfs/zfs.po
 SUBDIR=	zfs
 zfs/zfs.o: .PHONY
 	@cd ${.CURDIR}/zfs && ${MAKE} zfs.o
 zfs/zfs.So: .PHONY
 	@cd ${.CURDIR}/zfs && ${MAKE} zfs.So
 zfs/zfs.po: .PHONY
 	@cd ${.CURDIR}/zfs && ${MAKE} zfs.po
 .endif
 
 .include 
Index: user/attilio/vmcontention/lib/libprocstat/Symbol.map
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/Symbol.map	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/Symbol.map	(revision 249699)
@@ -1,20 +1,37 @@
 /*
  * $FreeBSD$
  */
 FBSD_1.2 {
 	procstat_close;
 	procstat_freefiles;
 	procstat_freeprocs;
 	procstat_get_pipe_info;
 	procstat_get_pts_info;
 	procstat_get_socket_info;
 	procstat_get_vnode_info;
 	procstat_getfiles;
 	procstat_getprocs;
 	procstat_open_kvm;
 	procstat_open_sysctl;
 };
 
 FBSD_1.3 {
+	procstat_freeargv;
+	procstat_freeauxv;
+	procstat_freeenvv;
+	procstat_freegroups;
+	procstat_freekstack;
+	procstat_freevmmap;
 	procstat_get_shm_info;
+	procstat_getargv;
+	procstat_getauxv;
+	procstat_getenvv;
+	procstat_getgroups;
+	procstat_getkstack;
+	procstat_getosrel;
+	procstat_getpathname;
+	procstat_getrlimit;
+	procstat_getumask;
+	procstat_getvmmap;
+	procstat_open_core;
 };
Index: user/attilio/vmcontention/lib/libprocstat/core.c
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/core.c	(nonexistent)
+++ user/attilio/vmcontention/lib/libprocstat/core.c	(revision 249699)
@@ -0,0 +1,432 @@
+/*-
+ * Copyright (c) 2013 Mikolaj Golub 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+
+#define PROCSTAT_CORE_MAGIC	0x012DADB8
+struct procstat_core
+{
+	int		pc_magic;
+	int		pc_fd;
+	Elf		*pc_elf;
+	GElf_Ehdr	pc_ehdr;
+	GElf_Phdr	pc_phdr;
+};
+
+static bool	core_offset(struct procstat_core *core, off_t offset);
+static bool	core_read(struct procstat_core *core, void *buf, size_t len);
+static ssize_t	core_read_mem(struct procstat_core *core, void *buf,
+    size_t len, vm_offset_t addr, bool readall);
+static void	*get_args(struct procstat_core *core, vm_offset_t psstrings,
+    enum psc_type type, void *buf, size_t *lenp);
+
+struct procstat_core *
+procstat_core_open(const char *filename)
+{
+	struct procstat_core *core;
+	Elf *e;
+	GElf_Ehdr ehdr;
+	GElf_Phdr phdr;
+	size_t nph;
+	int fd, i;
+
+	if (elf_version(EV_CURRENT) == EV_NONE) {
+		warnx("ELF library too old");
+		return (NULL);
+	}
+	fd = open(filename, O_RDONLY, 0);
+	if (fd == -1) {
+		warn("open(%s)", filename);
+		return (NULL);
+	}
+	e = elf_begin(fd, ELF_C_READ, NULL);
+	if (e == NULL) {
+		warnx("elf_begin: %s", elf_errmsg(-1));
+		goto fail;
+	}
+	if (elf_kind(e) != ELF_K_ELF) {
+		warnx("%s is not an ELF object", filename);
+		goto fail;
+	}
+	if (gelf_getehdr(e, &ehdr) == NULL) {
+		warnx("gelf_getehdr: %s", elf_errmsg(-1));
+		goto fail;
+	}
+	if (ehdr.e_type != ET_CORE) {
+		warnx("%s is not a CORE file", filename);
+		goto fail;
+	}
+	if (elf_getphnum(e, &nph) == 0) {
+		warnx("program headers not found");
+		goto fail;
+	}
+	for (i = 0; i < ehdr.e_phnum; i++) {
+		if (gelf_getphdr(e, i, &phdr) != &phdr) {
+			warnx("gelf_getphdr: %s", elf_errmsg(-1));
+			goto fail;
+		}
+		if (phdr.p_type == PT_NOTE)
+			break;
+	}
+	if (i == ehdr.e_phnum) {
+		warnx("NOTE program header not found");
+		goto fail;
+	}
+	core = malloc(sizeof(struct procstat_core));
+	if (core == NULL) {
+		warn("malloc(%zu)", sizeof(struct procstat_core));
+		goto fail;
+	}
+	core->pc_magic = PROCSTAT_CORE_MAGIC;
+	core->pc_fd = fd;
+	core->pc_elf = e;
+	core->pc_ehdr = ehdr;
+	core->pc_phdr = phdr;
+
+	return (core);
+fail:
+	if (e != NULL)
+		elf_end(e);
+	close(fd);
+
+	return (NULL);
+}
+
+void
+procstat_core_close(struct procstat_core *core)
+{
+
+	assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+	elf_end(core->pc_elf);
+	close(core->pc_fd);
+	free(core);
+}
+
+void *
+procstat_core_get(struct procstat_core *core, enum psc_type type, void *buf,
+    size_t *lenp)
+{
+	Elf_Note nhdr;
+	off_t offset, eoffset;
+	vm_offset_t psstrings;
+	void *freebuf;
+	size_t len;
+	u_int32_t n_type;
+	int cstructsize, structsize;
+	char nbuf[8];
+
+	assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+	switch(type) {
+	case PSC_TYPE_PROC:
+		n_type = NT_PROCSTAT_PROC;
+		structsize = sizeof(struct kinfo_proc);
+		break;
+	case PSC_TYPE_FILES:
+		n_type = NT_PROCSTAT_FILES;
+		structsize = sizeof(struct kinfo_file);
+		break;
+	case PSC_TYPE_VMMAP:
+		n_type = NT_PROCSTAT_VMMAP;
+		structsize = sizeof(struct kinfo_vmentry);
+		break;
+	case PSC_TYPE_GROUPS:
+		n_type = NT_PROCSTAT_GROUPS;
+		structsize = sizeof(gid_t);
+		break;
+	case PSC_TYPE_UMASK:
+		n_type = NT_PROCSTAT_UMASK;
+		structsize = sizeof(u_short);
+		break;
+	case PSC_TYPE_RLIMIT:
+		n_type = NT_PROCSTAT_RLIMIT;
+		structsize = sizeof(struct rlimit) * RLIM_NLIMITS;
+		break;
+	case PSC_TYPE_OSREL:
+		n_type = NT_PROCSTAT_OSREL;
+		structsize = sizeof(int);
+		break;
+	case PSC_TYPE_PSSTRINGS:
+	case PSC_TYPE_ARGV:
+	case PSC_TYPE_ENVV:
+		n_type = NT_PROCSTAT_PSSTRINGS;
+		structsize = sizeof(vm_offset_t);
+		break;
+	case PSC_TYPE_AUXV:
+		n_type = NT_PROCSTAT_AUXV;
+		structsize = sizeof(Elf_Auxinfo);
+		break;
+	default:
+		warnx("unknown core stat type: %d", type);
+		return (NULL);
+	}
+
+	offset = core->pc_phdr.p_offset;
+	eoffset = offset + core->pc_phdr.p_filesz;
+
+	while (offset < eoffset) {
+		if (!core_offset(core, offset))
+			return (NULL);
+		if (!core_read(core, &nhdr, sizeof(nhdr)))
+			return (NULL);
+
+		offset += sizeof(nhdr) +
+		    roundup2(nhdr.n_namesz, sizeof(Elf32_Size)) +
+		    roundup2(nhdr.n_descsz, sizeof(Elf32_Size));
+
+		if (nhdr.n_namesz == 0 && nhdr.n_descsz == 0)
+			break;
+		if (nhdr.n_type != n_type)
+			continue;
+		if (nhdr.n_namesz != 8)
+			continue;
+		if (!core_read(core, nbuf, sizeof(nbuf)))
+			return (NULL);
+		if (strcmp(nbuf, "FreeBSD") != 0)
+			continue;
+		if (nhdr.n_descsz < sizeof(cstructsize)) {
+			warnx("corrupted core file");
+			return (NULL);
+		}
+		if (!core_read(core, &cstructsize, sizeof(cstructsize)))
+			return (NULL);
+		if (cstructsize != structsize) {
+			warnx("version mismatch");
+			return (NULL);
+		}
+		len = nhdr.n_descsz - sizeof(cstructsize);
+		if (len == 0)
+			return (NULL);
+		if (buf != NULL) {
+			len = MIN(len, *lenp);
+			freebuf = NULL;
+		} else {
+			freebuf = buf = malloc(len);
+			if (buf == NULL) {
+				warn("malloc(%zu)", len);
+				return (NULL);
+			}
+		}
+		if (!core_read(core, buf, len)) {
+			free(freebuf);
+			return (NULL);
+		}
+		if (type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV) {
+			if (len < sizeof(psstrings)) {
+				free(freebuf);
+				return (NULL);
+			}
+			psstrings = *(vm_offset_t *)buf;
+			if (freebuf == NULL)
+				len = *lenp;
+			else
+				buf = NULL;
+			free(freebuf);
+			buf = get_args(core, psstrings, type, buf, &len);
+		}
+		*lenp = len;
+		return (buf);
+        }
+
+	return (NULL);
+}
+
+static bool
+core_offset(struct procstat_core *core, off_t offset)
+{
+
+	assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+	if (lseek(core->pc_fd, offset, SEEK_SET) == -1) {
+		warn("core: lseek(%jd)", (intmax_t)offset);
+		return (false);
+	}
+	return (true);
+}
+
+static bool
+core_read(struct procstat_core *core, void *buf, size_t len)
+{
+	ssize_t n;
+
+	assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+	n = read(core->pc_fd, buf, len);
+	if (n == -1) {
+		warn("core: read");
+		return (false);
+	}
+	if (n < (ssize_t)len) {
+		warnx("core: short read");
+		return (false);
+	}
+	return (true);
+}
+
+static ssize_t
+core_read_mem(struct procstat_core *core, void *buf, size_t len,
+    vm_offset_t addr, bool readall)
+{
+	GElf_Phdr phdr;
+	off_t offset;
+	int i;
+
+	assert(core->pc_magic == PROCSTAT_CORE_MAGIC);
+
+	for (i = 0; i < core->pc_ehdr.e_phnum; i++) {
+		if (gelf_getphdr(core->pc_elf, i, &phdr) != &phdr) {
+			warnx("gelf_getphdr: %s", elf_errmsg(-1));
+			return (-1);
+		}
+		if (phdr.p_type != PT_LOAD)
+			continue;
+		if (addr < phdr.p_vaddr || addr > phdr.p_vaddr + phdr.p_memsz)
+			continue;
+		offset = phdr.p_offset + (addr - phdr.p_vaddr);
+		if ((phdr.p_vaddr + phdr.p_memsz) - addr < len) {
+			if (readall) {
+				warnx("format error: "
+				    "attempt to read out of segment");
+				return (-1);
+			}
+			len = (phdr.p_vaddr + phdr.p_memsz) - addr;
+		}
+		if (!core_offset(core, offset))
+			return (-1);
+		if (!core_read(core, buf, len))
+			return (-1);
+		return (len);
+	}
+	warnx("format error: address %ju not found", (uintmax_t)addr);
+	return (-1);
+}
+
+#define ARGS_CHUNK_SZ	256	/* Chunk size (bytes) for get_args operations. */
+
+static void *
+get_args(struct procstat_core *core, vm_offset_t psstrings, enum psc_type type,
+     void *args, size_t *lenp)
+{
+	struct ps_strings pss;
+	void *freeargs;
+	vm_offset_t addr;
+	char **argv, *p;
+	size_t chunksz, done, len, nchr, size;
+	ssize_t n;
+	u_int i, nstr;
+
+	assert(type == PSC_TYPE_ARGV || type == PSC_TYPE_ENVV);
+
+	if (core_read_mem(core, &pss, sizeof(pss), psstrings, true) == -1)
+		return (NULL);
+	if (type == PSC_TYPE_ARGV) {
+		addr = (vm_offset_t)pss.ps_argvstr;
+		nstr = pss.ps_nargvstr;
+	} else /* type == PSC_TYPE_ENVV */ {
+		addr = (vm_offset_t)pss.ps_envstr;
+		nstr = pss.ps_nenvstr;
+	}
+	if (addr == 0 || nstr == 0)
+		return (NULL);
+	if (nstr > ARG_MAX) {
+		warnx("format error");
+		return (NULL);
+	}
+	size = nstr * sizeof(char *);
+	argv = malloc(size);
+	if (argv == NULL) {
+		warn("malloc(%zu)", size);
+		return (NULL);
+	}
+	done = 0;
+	freeargs = NULL;
+	if (core_read_mem(core, argv, size, addr, true) == -1)
+		goto fail;
+	if (args != NULL) {
+		nchr = MIN(ARG_MAX, *lenp);
+	} else {
+		nchr = ARG_MAX;
+		freeargs = args = malloc(nchr);
+		if (args == NULL) {
+			warn("malloc(%zu)", nchr);
+			goto fail;
+		}
+	}
+	p = args;
+	for (i = 0; ; i++) {
+		if (i == nstr)
+			goto done;
+		/*
+		 * The program may have scribbled into its argv array, e.g. to
+		 * remove some arguments.  If that has happened, break out
+		 * before trying to read from NULL.
+		 */
+		if (argv[i] == NULL)
+			goto done;
+		for (addr = (vm_offset_t)argv[i]; ; addr += chunksz) {
+			chunksz = MIN(ARGS_CHUNK_SZ, nchr - 1 - done);
+			if (chunksz <= 0)
+				goto done;
+			n = core_read_mem(core, p, chunksz, addr, false);
+			if (n == -1)
+				goto fail;
+			len = strnlen(p, chunksz);
+			p += len;
+			done += len;
+			if (len != chunksz)
+				break;
+		}
+		*p++ = '\0';
+		done++;
+	}
+fail:
+	free(freeargs);
+	args = NULL;
+done:
+	*lenp = done;
+	free(argv);
+	return (args);
+}

Property changes on: user/attilio/vmcontention/lib/libprocstat/core.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: user/attilio/vmcontention/lib/libprocstat/core.h
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/core.h	(nonexistent)
+++ user/attilio/vmcontention/lib/libprocstat/core.h	(revision 249699)
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2013 Mikolaj Golub 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _CORE_H
+#define _CORE_H
+
+enum psc_type {
+	PSC_TYPE_PROC,
+	PSC_TYPE_FILES,
+	PSC_TYPE_VMMAP,
+	PSC_TYPE_GROUPS,
+	PSC_TYPE_UMASK,
+	PSC_TYPE_RLIMIT,
+	PSC_TYPE_OSREL,
+	PSC_TYPE_PSSTRINGS,
+	PSC_TYPE_ARGV,
+	PSC_TYPE_ENVV,
+	PSC_TYPE_AUXV,
+};
+
+struct procstat_core;
+
+void procstat_core_close(struct procstat_core *core);
+void *procstat_core_get(struct procstat_core *core, enum psc_type type,
+    void * buf, size_t *lenp);
+struct procstat_core *procstat_core_open(const char *filename);
+
+#endif 	/* !_CORE_H_ */

Property changes on: user/attilio/vmcontention/lib/libprocstat/core.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: user/attilio/vmcontention/lib/libprocstat/libprocstat.3
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/libprocstat.3	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/libprocstat.3	(revision 249699)
@@ -1,271 +1,537 @@
 .\" Copyright (c) 2011 Sergey Kandaurov 
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
 .\" 1. Redistributions of source code must retain the above copyright
 .\"    notice, this list of conditions and the following disclaimer.
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\"
 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 1, 2012
+.Dd April 20, 2013
 .Dt LIBPROCSTAT 3
 .Os
 .Sh NAME
+.Nm procstat_open_core ,
 .Nm procstat_open_kvm ,
 .Nm procstat_open_sysctl ,
 .Nm procstat_close ,
+.Nm procstat_getargv ,
+.Nm procstat_getauxv ,
+.Nm procstat_getenvv ,
 .Nm procstat_getfiles ,
+.Nm procstat_getgroups ,
+.Nm procstat_getkstack ,
+.Nm procstat_getosrel ,
+.Nm procstat_getpathname ,
 .Nm procstat_getprocs ,
+.Nm procstat_getumask ,
+.Nm procstat_getvmmap ,
+.Nm procstat_freeargv ,
+.Nm procstat_freeauxv ,
+.Nm procstat_freeenvv ,
 .Nm procstat_freefiles ,
+.Nm procstat_freegroups ,
+.Nm procstat_freekstack ,
 .Nm procstat_freeprocs ,
+.Nm procstat_freevmmap ,
 .Nm procstat_get_pipe_info ,
 .Nm procstat_get_pts_info ,
 .Nm procstat_get_shm_info ,
 .Nm procstat_get_socket_info ,
 .Nm procstat_get_vnode_info
 .Nd library interface for file and process information retrieval
 .Sh LIBRARY
 .Lb libprocstat
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/queue.h
 .In libprocstat.h
 .Ft void
 .Fn procstat_close "struct procstat *procstat"
+.Fc
 .Ft void
+.Fo procstat_freeargv
+.Fa "struct procstat *procstat"
+.Fc
+.Ft void
+.Fo procstat_freeauxv
+.Fa "struct procstat *procstat"
+.Fa "Elf_Auxinfo *auxv"
+.Fc
+.Ft void
+.Fo procstat_freeenvv
+.Fa "struct procstat *procstat"
+.Fc
+.Ft void
 .Fo procstat_freefiles
 .Fa "struct procstat *procstat"
 .Fa "struct filestat_list *head"
 .Fc
 .Ft void
+.Fo procstat_freegroups
+.Fa "struct procstat *procstat"
+.Fa "gid_t *groups"
+.Fc
+.Ft void
+.Fo procstat_freekstack
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_kstack *kkstp"
+.Fc
+.Ft void
 .Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p"
+.Ft void
+.Fo procstat_freevmmap
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_vmentry *vmmap"
+.Fc
 .Ft int
 .Fo procstat_get_pipe_info
 .Fa "struct procstat *procstat"
 .Fa "struct filestat *fst"
 .Fa "struct pipestat *pipe"
 .Fa "char *errbuf"
 .Fc
 .Ft int
 .Fo procstat_get_pts_info
 .Fa "struct procstat *procstat"
 .Fa "struct filestat *fst"
 .Fa "struct ptsstat *pts"
 .Fa "char *errbuf"
 .Fc
 .Ft int
 .Fo procstat_get_shm_info
 .Fa "struct procstat *procstat"
 .Fa "struct filestat *fst"
 .Fa "struct shmstat *shm"
 .Fa "char *errbuf"
 .Fc
 .Ft int
 .Fo procstat_get_socket_info
 .Fa "struct procstat *procstat"
 .Fa "struct filestat *fst"
 .Fa "struct sockstat *sock"
 .Fa "char *errbuf"
 .Fc
 .Ft int
 .Fo procstat_get_vnode_info
 .Fa "struct procstat *procstat"
 .Fa "struct filestat *fst"
 .Fa "struct vnstat *vn"
 .Fa "char *errbuf"
 .Fc
+.Ft "char **"
+.Fo procstat_getargv
+.Fa "struct procstat *procstat"
+.Fa "const struct kinfo_proc *kp"
+.Fa "size_t nchr"
+.Fa "char *errbuf"
+.Fc
+.Ft "Elf_Auxinfo *"
+.Fo procstat_getauxv
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
+.Ft "char **"
+.Fo procstat_getenvv
+.Fa "struct procstat *procstat"
+.Fa "const struct kinfo_proc *kp"
+.Fa "size_t nchr"
+.Fa "char *errbuf"
+.Fc
 .Ft "struct filestat_list *"
 .Fo procstat_getfiles
 .Fa "struct procstat *procstat"
 .Fa "struct kinfo_proc *kp"
 .Fa "int mmapped"
 .Fc
+.Ft "gid_t *"
+.Fo procstat_getgroups
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Ft int
+.Fo procstat_getosrel
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "int *osrelp"
+.Fc
+.Ft "struct kinfo_kstack *"
+.Fo procstat_getkstack
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
 .Ft "struct kinfo_proc *"
 .Fo procstat_getprocs
 .Fa "struct procstat *procstat"
 .Fa "int what"
 .Fa "int arg"
 .Fa "unsigned int *count"
 .Fc
+.Ft "int"
+.Fo procstat_getpathname
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "char *pathname"
+.Fa "size_t maxlen"
+.Fc
+.Ft "int"
+.Fo procstat_getrlimit
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "int which"
+.Fa "struct rlimit* rlimit"
+.Fc
+.Ft "int"
+.Fo procstat_getumask
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned short *maskp"
+.Fc
+.Ft "struct kinfo_vmentry *"
+.Fo procstat_getvmmap
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
 .Ft "struct procstat *"
+.Fn procstat_open_core "const char *filename"
+.Ft "struct procstat *"
 .Fn procstat_open_kvm "const char *nlistf" "const char *memf"
 .Ft "struct procstat *"
 .Fn procstat_open_sysctl void
 .Sh DESCRIPTION
 The
 .Nm libprocstat
 library contains the API for runtime file and process information
 retrieval from the running kernel via the
 .Xr sysctl 3
 library backend, and for post-mortem analysis via the
 .Xr kvm 3
-library backend.
+library backend, or from the process
+.Xr core 5
+file, searching for statistics in special
+.Xr elf 3
+note sections.
 .Pp
 The
 .Fn procstat_open_kvm
 and
 .Fn procstat_open_sysctl
 functions use the
 .Xr kvm 3
 or
 .Xr sysctl 3
 library routines, respectively, to access kernel state information
 used to retrieve processes and files states.
 The
+.Fn procstat_open_core
+uses
+.Xr elf 3
+routines to access statistics stored as a set of notes in a process
+.Xr core 5
+file, written by the kernel at the moment of the process abnormal termination.
+The
+.Fa filename
+argument is the process core file name.
+The
 .Fa nlistf
 argument is the executable image of the kernel being examined.
 If this argument is
 .Dv NULL ,
 the currently running kernel is assumed.
 The
 .Fa memf
 argument is the kernel memory device file.
 If this argument is
 .Dv NULL ,
 then
 .Pa /dev/mem
 is assumed.
 See
 .Xr kvm_open 3
 for more details.
-Both functions dynamically allocate and return a
+The functions dynamically allocate and return a
 .Vt procstat
 structure pointer used in the rest of the
 .Nm libprocstat
 library routines until the corresponding
 .Fn procstat_close
 call that cleans up the resources allocated by the
 .Fn procstat_open_*
 functions.
 .Pp
 The
 .Fn procstat_getprocs
 function gets a pointer to the
 .Vt procstat
 structure from one of the
 .Fn procstat_open_*
 functions and returns a dynamically allocated (sub-)set of active processes
 in the kernel filled in to array of
 .Vt kinfo_proc
 structures.
 The
 .Fa what
 and
 .Fa arg
 arguments constitute a filtering predicate as described in the
 .Xr kvm_getprocs 3
 function.
 The number of processes found is returned in the reference parameter
 .Fa cnt .
 The caller is responsible to free the allocated memory with a subsequent
 .Fn procstat_freeprocs
 function call.
 .Pp
 The
+.Fn procstat_getargv
+function gets a pointer to the
+.Vt procstat
+structure from one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure from the array obtained from the
+.Fn kvm_getprocs
+function, and returns a null-terminated argument vector that corresponds to
+the command line arguments passed to the process.
+The
+.Fa nchr
+argument indicates the maximum number of characters, including null bytes,
+to use in building the strings.
+If this amount is exceeded, the string causing the overflow is truncated and
+the partial result is returned.
+This is handy for programs that print only a one line summary of a
+command and should not copy out large amounts of text only to ignore it.
+If
+.Fa nchr
+is zero, no limit is imposed and all argument strings are returned.
+The values of the returned argument vector refer the strings stored
+in the
+.Vt procstat
+internal buffer.
+A subsequent call of the function with the same
+.Vt procstat
+argument will reuse the buffer.
+To free the allocated memory
+.Fn procstat_freeargv
+function call can be used, or it will be released on
+.Fn procstat_close .
+.Pp
+The
+.Fn procstat_getenvv
+function is similar to
+.Fn procstat_getargv
+but returns the vector of environment strings.
+The caller may free the allocated memory with a subsequent
+.Fn procstat_freeenv
+function call.
+.Pp
+The
+.Fn procstat_getauxv
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the auxiliary vector as a dynamically allocated array of
+.Vt Elf_Auxinfo
+elements.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freeauxv
+function call.
+.Pp
+The
 .Fn procstat_getfiles
 function gets a pointer to the
 .Vt procstat
 structure initialized with one of the
 .Fn procstat_open_*
 functions, a pointer to
 .Vt kinfo_proc
 structure from the array obtained from the
 .Fn kvm_getprocs
 function, and returns a dynamically allocated linked list of filled in
 .Vt filestat_list
 structures using the STAILQ macros defined in
 .Xr queue 3 .
 The caller is responsible to free the allocated memory with a subsequent
 .Fn procstat_freefiles
 function call.
 .Pp
 The
+.Fn procstat_getgroups
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the process groups as a dynamically allocated array of
+.Vt gid_t
+elements.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freegroups
+function call.
+.Pp
+The
+.Fn procstat_getkstack
+function gets a pointer to the
+.Vt procstat
+structure initialized with one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure, and returns kernel stacks of the process as a dynamically allocated
+array of
+.Vt kinfo_kstack
+structures.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freekstack
+function call.
+.Pp
+The
+.Fn procstat_getosrel
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns osrel date in the 3rd reference parameter.
+.Pp
+The
+.Fn procstat_getpathname
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and copies the path of the process executable to
+.Fa pathname
+buffer, limiting to
+.Fa maxlen
+characters.
+.Pp
+The
+.Fn procstat_getrlimit
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, resource index
+.Fa which ,
+and returns the actual resource limit in the 4th reference parameter.
+.Pp
+The
+.Fn procstat_getumask
+function gets a pointer to the
+.Vt procstat
+structure, a pointer to
+.Vt kinfo_proc
+structure, and returns the process umask in the 3rd reference parameter.
+.Pp
+The
+.Fn procstat_getvmmap
+function gets a pointer to the
+.Vt procstat
+structure initialized with one of the
+.Fn procstat_open_*
+functions, a pointer to
+.Vt kinfo_proc
+structure, and returns VM layout of the process as a dynamically allocated
+array of
+.Vt kinfo_vmentry
+structures.
+The caller is responsible to free the allocated memory with a subsequent
+.Fn procstat_freevmmap
+function call.
+.Pp
+The
 .Fn procstat_get_pipe_info ,
 .Fn procstat_get_pts_info ,
 .Fn procstat_get_shm_info ,
 .Fn procstat_get_socket_info
 and
 .Fn procstat_get_vnode_info
 functions are used to retrieve information about pipes, pseudo-terminals,
 shared memory objects,
 sockets, and vnodes, respectively.
 Each of them have a similar interface API.
 The
 .Fa procstat
 argument is a pointer obtained from one of
 .Fn procstat_open_*
 functions.
 The
 .Ft filestat Fa fst
 argument is an element of STAILQ linked list as obtained from the
 .Fn procstat_getfiles
 function.
 The
 .Ft filestat
 structure contains a
 .Fa fs_type
 field that specifies a file type and a corresponding function to be
 called among the
 .Nm procstat_get_*_info
 function family.
 The actual object is returned in the 3rd reference parameter.
 The
 .Fa errbuf
 argument indicates an actual error message in case of failure.
 .Pp
 .Bl -tag -width 20n -compact -offset indent
 .It Li PS_FST_TYPE_FIFO
 .Nm procstat_get_vnode_info
 .It Li PS_FST_TYPE_VNODE
 .Nm procstat_get_vnode_info
 .It Li PS_FST_TYPE_SOCKET
 .Nm procstat_get_socket_info
 .It Li PS_FST_TYPE_PIPE
 .Nm procstat_get_pipe_info
 .It Li PS_FST_TYPE_PTS
 .Nm procstat_get_pts_info
 .It Li PS_FST_TYPE_SHM
 .Nm procstat_get_shm_info
 .El
 .Sh SEE ALSO
 .Xr fstat 1 ,
 .Xr fuser 1 ,
 .Xr pipe 2 ,
 .Xr shm_open 2 ,
 .Xr socket 2 ,
+.Xr elf 3 ,
 .Xr kvm 3 ,
 .Xr queue 3 ,
 .Xr sysctl 3 ,
 .Xr pts 4 ,
+.Xr core 5 ,
 .Xr vnode 9
 .Sh HISTORY
 The
 .Nm libprocstat
 library appeared in
 .Fx 9.0 .
 .Sh AUTHORS
 .An -nosplit
 The
 .Nm libprocstat
 library was written by
 .An Stanislav Sedov Aq stas@FreeBSD.org .
 .Pp
 This manual page was written by
 .An Sergey Kandaurov Aq pluknet@FreeBSD.org .
Index: user/attilio/vmcontention/lib/libprocstat/libprocstat.c
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/libprocstat.c	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/libprocstat.c	(revision 249699)
@@ -1,1403 +1,2299 @@
 /*-
  * Copyright (c) 2009 Stanislav Sedov 
  * Copyright (c) 1988, 1993
  *      The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
  *      This product includes software developed by the University of
  *      California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #define	_WANT_FILE
 #include 
 #include 
 #include 
 #define	_KERNEL
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #undef _KERNEL
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include "libprocstat_internal.h"
 #include "common_kvm.h"
+#include "core.h"
 
 int     statfs(const char *, struct statfs *);	/* XXX */
 
 #define	PROCSTAT_KVM	1
 #define	PROCSTAT_SYSCTL	2
+#define	PROCSTAT_CORE	3
 
+static char	**getargv(struct procstat *procstat, struct kinfo_proc *kp,
+    size_t nchr, int env);
 static char	*getmnton(kvm_t *kd, struct mount *m);
+static struct kinfo_vmentry *	kinfo_getvmmap_core(struct procstat_core *core,
+    int *cntp);
+static Elf_Auxinfo	*procstat_getauxv_core(struct procstat_core *core,
+    unsigned int *cntp);
+static Elf_Auxinfo	*procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp);
 static struct filestat_list	*procstat_getfiles_kvm(
     struct procstat *procstat, struct kinfo_proc *kp, int mmapped);
 static struct filestat_list	*procstat_getfiles_sysctl(
     struct procstat *procstat, struct kinfo_proc *kp, int mmapped);
 static int	procstat_get_pipe_info_sysctl(struct filestat *fst,
     struct pipestat *pipe, char *errbuf);
 static int	procstat_get_pipe_info_kvm(kvm_t *kd, struct filestat *fst,
     struct pipestat *pipe, char *errbuf);
 static int	procstat_get_pts_info_sysctl(struct filestat *fst,
     struct ptsstat *pts, char *errbuf);
 static int	procstat_get_pts_info_kvm(kvm_t *kd, struct filestat *fst,
     struct ptsstat *pts, char *errbuf);
 static int	procstat_get_shm_info_sysctl(struct filestat *fst,
     struct shmstat *shm, char *errbuf);
 static int	procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
     struct shmstat *shm, char *errbuf);
 static int	procstat_get_socket_info_sysctl(struct filestat *fst,
     struct sockstat *sock, char *errbuf);
 static int	procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
     struct sockstat *sock, char *errbuf);
 static int	to_filestat_flags(int flags);
 static int	procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
     struct vnstat *vn, char *errbuf);
 static int	procstat_get_vnode_info_sysctl(struct filestat *fst,
     struct vnstat *vn, char *errbuf);
+static gid_t	*procstat_getgroups_core(struct procstat_core *core,
+    unsigned int *count);
+static gid_t	*procstat_getgroups_sysctl(pid_t pid, unsigned int *count);
+static struct kinfo_kstack	*procstat_getkstack_sysctl(pid_t pid,
+    int *cntp);
+static int	procstat_getpathname_core(struct procstat_core *core,
+    char *pathname, size_t maxlen);
+static int	procstat_getpathname_sysctl(pid_t pid, char *pathname,
+    size_t maxlen);
+static int	procstat_getrlimit_core(struct procstat_core *core, int which,
+    struct rlimit* rlimit);
+static int	procstat_getrlimit_sysctl(pid_t pid, int which,
+    struct rlimit* rlimit);
+static int	procstat_getumask_core(struct procstat_core *core,
+    unsigned short *maskp);
+static int	procstat_getumask_sysctl(pid_t pid, unsigned short *maskp);
 static int	vntype2psfsttype(int type);
 
 void
 procstat_close(struct procstat *procstat)
 {
 
 	assert(procstat);
 	if (procstat->type == PROCSTAT_KVM)
 		kvm_close(procstat->kd);
+	else if (procstat->type == PROCSTAT_CORE)
+		procstat_core_close(procstat->core);
+	procstat_freeargv(procstat);
+	procstat_freeenvv(procstat);
 	free(procstat);
 }
 
 struct procstat *
 procstat_open_sysctl(void)
 {
 	struct procstat *procstat;
 
 	procstat = calloc(1, sizeof(*procstat));
 	if (procstat == NULL) {
 		warn("malloc()");
 		return (NULL);
 	}
 	procstat->type = PROCSTAT_SYSCTL;
 	return (procstat);
 }
 
 struct procstat *
 procstat_open_kvm(const char *nlistf, const char *memf)
 {
 	struct procstat *procstat;
 	kvm_t *kd;
 	char buf[_POSIX2_LINE_MAX];
 
 	procstat = calloc(1, sizeof(*procstat));
 	if (procstat == NULL) {
 		warn("malloc()");
 		return (NULL);
 	}
 	kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf);
 	if (kd == NULL) {
 		warnx("kvm_openfiles(): %s", buf);
 		free(procstat);
 		return (NULL);
 	}
 	procstat->type = PROCSTAT_KVM;
 	procstat->kd = kd;
 	return (procstat);
 }
 
+struct procstat *
+procstat_open_core(const char *filename)
+{
+	struct procstat *procstat;
+	struct procstat_core *core;
+
+	procstat = calloc(1, sizeof(*procstat));
+	if (procstat == NULL) {
+		warn("malloc()");
+		return (NULL);
+	}
+	core = procstat_core_open(filename);
+	if (core == NULL) {
+		free(procstat);
+		return (NULL);
+	}
+	procstat->type = PROCSTAT_CORE;
+	procstat->core = core;
+	return (procstat);
+}
+
 struct kinfo_proc *
 procstat_getprocs(struct procstat *procstat, int what, int arg,
     unsigned int *count)
 {
 	struct kinfo_proc *p0, *p;
 	size_t len;
 	int name[4];
 	int cnt;
 	int error;
 
 	assert(procstat);
 	assert(count);
 	p = NULL;
 	if (procstat->type == PROCSTAT_KVM) {
 		*count = 0;
 		p0 = kvm_getprocs(procstat->kd, what, arg, &cnt);
 		if (p0 == NULL || cnt <= 0)
 			return (NULL);
 		*count = cnt;
 		len = *count * sizeof(*p);
 		p = malloc(len);
 		if (p == NULL) {
 			warnx("malloc(%zu)", len);
 			goto fail;
 		}
 		bcopy(p0, p, len);
 		return (p);
 	} else if (procstat->type == PROCSTAT_SYSCTL) {
 		len = 0;
 		name[0] = CTL_KERN;
 		name[1] = KERN_PROC;
 		name[2] = what;
 		name[3] = arg;
 		error = sysctl(name, 4, NULL, &len, NULL, 0);
 		if (error < 0 && errno != EPERM) {
 			warn("sysctl(kern.proc)");
 			goto fail;
 		}
 		if (len == 0) {
 			warnx("no processes?");
 			goto fail;
 		}
 		p = malloc(len);
 		if (p == NULL) {
 			warnx("malloc(%zu)", len);
 			goto fail;
 		}
 		error = sysctl(name, 4, p, &len, NULL, 0);
 		if (error < 0 && errno != EPERM) {
 			warn("sysctl(kern.proc)");
 			goto fail;
 		}
 		/* Perform simple consistency checks. */
 		if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) {
+			warnx("kinfo_proc structure size mismatch (len = %zu)", len);
+			goto fail;
+		}
+		*count = len / sizeof(*p);
+		return (p);
+	} else if (procstat->type == PROCSTAT_CORE) {
+		p = procstat_core_get(procstat->core, PSC_TYPE_PROC, NULL,
+		    &len);
+		if ((len % sizeof(*p)) != 0 || p->ki_structsize != sizeof(*p)) {
 			warnx("kinfo_proc structure size mismatch");
 			goto fail;
 		}
 		*count = len / sizeof(*p);
 		return (p);
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		return (NULL);
 	}
 fail:
 	if (p)
 		free(p);
 	return (NULL);
 }
 
 void
 procstat_freeprocs(struct procstat *procstat __unused, struct kinfo_proc *p)
 {
 
 	if (p != NULL)
 		free(p);
 	p = NULL;
 }
 
 struct filestat_list *
 procstat_getfiles(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
 {
-	
-	if (procstat->type == PROCSTAT_SYSCTL)
-		return (procstat_getfiles_sysctl(procstat, kp, mmapped));
-	else if (procstat->type == PROCSTAT_KVM)
+
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
 		return (procstat_getfiles_kvm(procstat, kp, mmapped));
-	else
+	case PROCSTAT_SYSCTL:
+	case PROCSTAT_CORE:
+		return (procstat_getfiles_sysctl(procstat, kp, mmapped));
+	default:
+		warnx("unknown access method: %d", procstat->type);
 		return (NULL);
+	}
 }
 
 void
 procstat_freefiles(struct procstat *procstat, struct filestat_list *head)
 {
 	struct filestat *fst, *tmp;
 
 	STAILQ_FOREACH_SAFE(fst, head, next, tmp) {
 		if (fst->fs_path != NULL)
 			free(fst->fs_path);
 		free(fst);
 	}
 	free(head);
 	if (procstat->vmentries != NULL) {
 		free(procstat->vmentries);
 		procstat->vmentries = NULL;
 	}
 	if (procstat->files != NULL) {
 		free(procstat->files);
 		procstat->files = NULL;
 	}
 }
 
 static struct filestat *
 filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
     int refcount, off_t offset, char *path, cap_rights_t cap_rights)
 {
 	struct filestat *entry;
 
 	entry = calloc(1, sizeof(*entry));
 	if (entry == NULL) {
 		warn("malloc()");
 		return (NULL);
 	}
 	entry->fs_typedep = typedep;
 	entry->fs_fflags = fflags;
 	entry->fs_uflags = uflags;
 	entry->fs_fd = fd;
 	entry->fs_type = type;
 	entry->fs_ref_count = refcount;
 	entry->fs_offset = offset;
 	entry->fs_path = path;
 	entry->fs_cap_rights = cap_rights;
 	return (entry);
 }
 
 static struct vnode *
 getctty(kvm_t *kd, struct kinfo_proc *kp)
 {
 	struct pgrp pgrp;
 	struct proc proc;
 	struct session sess;
 	int error;
                         
 	assert(kp);
 	error = kvm_read_all(kd, (unsigned long)kp->ki_paddr, &proc,
 	    sizeof(proc));
 	if (error == 0) {
 		warnx("can't read proc struct at %p for pid %d",
 		    kp->ki_paddr, kp->ki_pid);
 		return (NULL);
 	}
 	if (proc.p_pgrp == NULL)
 		return (NULL);
 	error = kvm_read_all(kd, (unsigned long)proc.p_pgrp, &pgrp,
 	    sizeof(pgrp));
 	if (error == 0) {
 		warnx("can't read pgrp struct at %p for pid %d",
 		    proc.p_pgrp, kp->ki_pid);
 		return (NULL);
 	}
 	error = kvm_read_all(kd, (unsigned long)pgrp.pg_session, &sess,
 	    sizeof(sess));
 	if (error == 0) {
 		warnx("can't read session struct at %p for pid %d",
 		    pgrp.pg_session, kp->ki_pid);
 		return (NULL);
 	}
 	return (sess.s_ttyvp);
 }
 
 static struct filestat_list *
 procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
 {
 	struct file file;
 	struct filedesc filed;
 	struct vm_map_entry vmentry;
 	struct vm_object object;
 	struct vmspace vmspace;
 	vm_map_entry_t entryp;
 	vm_map_t map;
 	vm_object_t objp;
 	struct vnode *vp;
 	struct file **ofiles;
 	struct filestat *entry;
 	struct filestat_list *head;
 	kvm_t *kd;
 	void *data;
 	int i, fflags;
 	int prot, type;
 	unsigned int nfiles;
 
 	assert(procstat);
 	kd = procstat->kd;
 	if (kd == NULL)
 		return (NULL);
 	if (kp->ki_fd == NULL)
 		return (NULL);
 	if (!kvm_read_all(kd, (unsigned long)kp->ki_fd, &filed,
 	    sizeof(filed))) {
 		warnx("can't read filedesc at %p", (void *)kp->ki_fd);
 		return (NULL);
 	}
 
 	/*
 	 * Allocate list head.
 	 */
 	head = malloc(sizeof(*head));
 	if (head == NULL)
 		return (NULL);
 	STAILQ_INIT(head);
 
 	/* root directory vnode, if one. */
 	if (filed.fd_rdir) {
 		entry = filestat_new_entry(filed.fd_rdir, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	/* current working directory vnode. */
 	if (filed.fd_cdir) {
 		entry = filestat_new_entry(filed.fd_cdir, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	/* jail root, if any. */
 	if (filed.fd_jdir) {
 		entry = filestat_new_entry(filed.fd_jdir, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	/* ktrace vnode, if one */
 	if (kp->ki_tracep) {
 		entry = filestat_new_entry(kp->ki_tracep, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
 		    PS_FST_UFLAG_TRACE, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	/* text vnode, if one */
 	if (kp->ki_textvp) {
 		entry = filestat_new_entry(kp->ki_textvp, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	/* Controlling terminal. */
 	if ((vp = getctty(kd, kp)) != NULL) {
 		entry = filestat_new_entry(vp, PS_FST_TYPE_VNODE, -1,
 		    PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
 		    PS_FST_UFLAG_CTTY, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 
 	nfiles = filed.fd_lastfile + 1;
 	ofiles = malloc(nfiles * sizeof(struct file *));
 	if (ofiles == NULL) {
 		warn("malloc(%zu)", nfiles * sizeof(struct file *));
 		goto do_mmapped;
 	}
 	if (!kvm_read_all(kd, (unsigned long)filed.fd_ofiles, ofiles,
 	    nfiles * sizeof(struct file *))) {
 		warnx("cannot read file structures at %p",
 		    (void *)filed.fd_ofiles);
 		free(ofiles);
 		goto do_mmapped;
 	}
 	for (i = 0; i <= filed.fd_lastfile; i++) {
 		if (ofiles[i] == NULL)
 			continue;
 		if (!kvm_read_all(kd, (unsigned long)ofiles[i], &file,
 		    sizeof(struct file))) {
 			warnx("can't read file %d at %p", i,
 			    (void *)ofiles[i]);
 			continue;
 		}
 		switch (file.f_type) {
 		case DTYPE_VNODE:
 			type = PS_FST_TYPE_VNODE;
 			data = file.f_vnode;
 			break;
 		case DTYPE_SOCKET:
 			type = PS_FST_TYPE_SOCKET;
 			data = file.f_data;
 			break;
 		case DTYPE_PIPE:
 			type = PS_FST_TYPE_PIPE;
 			data = file.f_data;
 			break;
 		case DTYPE_FIFO:
 			type = PS_FST_TYPE_FIFO;
 			data = file.f_vnode;
 			break;
 #ifdef DTYPE_PTS
 		case DTYPE_PTS:
 			type = PS_FST_TYPE_PTS;
 			data = file.f_data;
 			break;
 #endif
 		case DTYPE_SHM:
 			type = PS_FST_TYPE_SHM;
 			data = file.f_data;
 			break;
 		default:
 			continue;
 		}
 		/* XXXRW: No capability rights support for kvm yet. */
 		entry = filestat_new_entry(data, type, i,
 		    to_filestat_flags(file.f_flag), 0, 0, 0, NULL, 0);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	free(ofiles);
 
 do_mmapped:
 
 	/*
 	 * Process mmapped files if requested.
 	 */
 	if (mmapped) {
 		if (!kvm_read_all(kd, (unsigned long)kp->ki_vmspace, &vmspace,
 		    sizeof(vmspace))) {
 			warnx("can't read vmspace at %p",
 			    (void *)kp->ki_vmspace);
 			goto exit;
 		}
 		map = &vmspace.vm_map;
 
 		for (entryp = map->header.next;
 		    entryp != &kp->ki_vmspace->vm_map.header;
 		    entryp = vmentry.next) {
 			if (!kvm_read_all(kd, (unsigned long)entryp, &vmentry,
 			    sizeof(vmentry))) {
 				warnx("can't read vm_map_entry at %p",
 				    (void *)entryp);
 				continue;
 			}
 			if (vmentry.eflags & MAP_ENTRY_IS_SUB_MAP)
 				continue;
 			if ((objp = vmentry.object.vm_object) == NULL)
 				continue;
 			for (; objp; objp = object.backing_object) {
 				if (!kvm_read_all(kd, (unsigned long)objp,
 				    &object, sizeof(object))) {
 					warnx("can't read vm_object at %p",
 					    (void *)objp);
 					break;
 				}
 			}
 
 			/* We want only vnode objects. */
 			if (object.type != OBJT_VNODE)
 				continue;
 
 			prot = vmentry.protection;
 			fflags = 0;
 			if (prot & VM_PROT_READ)
 				fflags = PS_FST_FFLAG_READ;
 			if ((vmentry.eflags & MAP_ENTRY_COW) == 0 &&
 			    prot & VM_PROT_WRITE)
 				fflags |= PS_FST_FFLAG_WRITE;
 
 			/*
 			 * Create filestat entry.
 			 */
 			entry = filestat_new_entry(object.handle,
 			    PS_FST_TYPE_VNODE, -1, fflags,
 			    PS_FST_UFLAG_MMAP, 0, 0, NULL, 0);
 			if (entry != NULL)
 				STAILQ_INSERT_TAIL(head, entry, next);
 		}
 	}
 exit:
 	return (head);
 }
 
 /*
  * kinfo types to filestat translation.
  */
 static int
 kinfo_type2fst(int kftype)
 {
 	static struct {
 		int	kf_type;
 		int	fst_type;
 	} kftypes2fst[] = {
 		{ KF_TYPE_CRYPTO, PS_FST_TYPE_CRYPTO },
 		{ KF_TYPE_FIFO, PS_FST_TYPE_FIFO },
 		{ KF_TYPE_KQUEUE, PS_FST_TYPE_KQUEUE },
 		{ KF_TYPE_MQUEUE, PS_FST_TYPE_MQUEUE },
 		{ KF_TYPE_NONE, PS_FST_TYPE_NONE },
 		{ KF_TYPE_PIPE, PS_FST_TYPE_PIPE },
 		{ KF_TYPE_PTS, PS_FST_TYPE_PTS },
 		{ KF_TYPE_SEM, PS_FST_TYPE_SEM },
 		{ KF_TYPE_SHM, PS_FST_TYPE_SHM },
 		{ KF_TYPE_SOCKET, PS_FST_TYPE_SOCKET },
 		{ KF_TYPE_VNODE, PS_FST_TYPE_VNODE },
 		{ KF_TYPE_UNKNOWN, PS_FST_TYPE_UNKNOWN }
 	};
 #define NKFTYPES	(sizeof(kftypes2fst) / sizeof(*kftypes2fst))
 	unsigned int i;
 
 	for (i = 0; i < NKFTYPES; i++)
 		if (kftypes2fst[i].kf_type == kftype)
 			break;
 	if (i == NKFTYPES)
 		return (PS_FST_TYPE_UNKNOWN);
 	return (kftypes2fst[i].fst_type);
 }
 
 /*
  * kinfo flags to filestat translation.
  */
 static int
 kinfo_fflags2fst(int kfflags)
 {
 	static struct {
 		int	kf_flag;
 		int	fst_flag;
 	} kfflags2fst[] = {
 		{ KF_FLAG_APPEND, PS_FST_FFLAG_APPEND },
 		{ KF_FLAG_ASYNC, PS_FST_FFLAG_ASYNC },
 		{ KF_FLAG_CREAT, PS_FST_FFLAG_CREAT },
 		{ KF_FLAG_DIRECT, PS_FST_FFLAG_DIRECT },
 		{ KF_FLAG_EXCL, PS_FST_FFLAG_EXCL },
 		{ KF_FLAG_EXEC, PS_FST_FFLAG_EXEC },
 		{ KF_FLAG_EXLOCK, PS_FST_FFLAG_EXLOCK },
 		{ KF_FLAG_FSYNC, PS_FST_FFLAG_SYNC },
 		{ KF_FLAG_HASLOCK, PS_FST_FFLAG_HASLOCK },
 		{ KF_FLAG_NOFOLLOW, PS_FST_FFLAG_NOFOLLOW },
 		{ KF_FLAG_NONBLOCK, PS_FST_FFLAG_NONBLOCK },
 		{ KF_FLAG_READ, PS_FST_FFLAG_READ },
 		{ KF_FLAG_SHLOCK, PS_FST_FFLAG_SHLOCK },
 		{ KF_FLAG_TRUNC, PS_FST_FFLAG_TRUNC },
 		{ KF_FLAG_WRITE, PS_FST_FFLAG_WRITE }
 	};
 #define NKFFLAGS	(sizeof(kfflags2fst) / sizeof(*kfflags2fst))
 	unsigned int i;
 	int flags;
 
 	flags = 0;
 	for (i = 0; i < NKFFLAGS; i++)
 		if ((kfflags & kfflags2fst[i].kf_flag) != 0)
 			flags |= kfflags2fst[i].fst_flag;
 	return (flags);
 }
 
 static int
 kinfo_uflags2fst(int fd)
 {
 
 	switch (fd) {
 	case KF_FD_TYPE_CTTY:
 		return (PS_FST_UFLAG_CTTY);
 	case KF_FD_TYPE_CWD:
 		return (PS_FST_UFLAG_CDIR);
 	case KF_FD_TYPE_JAIL:
 		return (PS_FST_UFLAG_JAIL);
 	case KF_FD_TYPE_TEXT:
 		return (PS_FST_UFLAG_TEXT);
 	case KF_FD_TYPE_TRACE:
 		return (PS_FST_UFLAG_TRACE);
 	case KF_FD_TYPE_ROOT:
 		return (PS_FST_UFLAG_RDIR);
 	}
 	return (0);
 }
 
+static struct kinfo_file *
+kinfo_getfile_core(struct procstat_core *core, int *cntp)
+{
+	int cnt;
+	size_t len;
+	char *buf, *bp, *eb;
+	struct kinfo_file *kif, *kp, *kf;
+
+	buf = procstat_core_get(core, PSC_TYPE_FILES, NULL, &len);
+	if (buf == NULL)
+		return (NULL);
+	/*
+	 * XXXMG: The code below is just copy&past from libutil.
+	 * The code duplication can be avoided if libutil
+	 * is extended to provide something like:
+	 *   struct kinfo_file *kinfo_getfile_from_buf(const char *buf,
+	 *       size_t len, int *cntp);
+	 */
+
+	/* Pass 1: count items */
+	cnt = 0;
+	bp = buf;
+	eb = buf + len;
+	while (bp < eb) {
+		kf = (struct kinfo_file *)(uintptr_t)bp;
+		bp += kf->kf_structsize;
+		cnt++;
+	}
+
+	kif = calloc(cnt, sizeof(*kif));
+	if (kif == NULL) {
+		free(buf);
+		return (NULL);
+	}
+	bp = buf;
+	eb = buf + len;
+	kp = kif;
+	/* Pass 2: unpack */
+	while (bp < eb) {
+		kf = (struct kinfo_file *)(uintptr_t)bp;
+		/* Copy/expand into pre-zeroed buffer */
+		memcpy(kp, kf, kf->kf_structsize);
+		/* Advance to next packed record */
+		bp += kf->kf_structsize;
+		/* Set field size to fixed length, advance */
+		kp->kf_structsize = sizeof(*kp);
+		kp++;
+	}
+	free(buf);
+	*cntp = cnt;
+	return (kif);	/* Caller must free() return value */
+}
+
 static struct filestat_list *
-procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
+procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
+    int mmapped)
 {
 	struct kinfo_file *kif, *files;
 	struct kinfo_vmentry *kve, *vmentries;
 	struct filestat_list *head;
 	struct filestat *entry;
 	char *path;
 	off_t offset;
 	int cnt, fd, fflags;
 	int i, type, uflags;
 	int refcount;
 	cap_rights_t cap_rights;
 
 	assert(kp);
 	if (kp->ki_fd == NULL)
 		return (NULL);
-
-	files = kinfo_getfile(kp->ki_pid, &cnt);
+	switch(procstat->type) {
+	case PROCSTAT_SYSCTL:
+		files = kinfo_getfile(kp->ki_pid, &cnt);
+		break;
+	case PROCSTAT_CORE:
+		files = kinfo_getfile_core(procstat->core, &cnt);
+		break;
+	default:
+		assert(!"invalid type");
+	}
 	if (files == NULL && errno != EPERM) {
 		warn("kinfo_getfile()");
 		return (NULL);
 	}
 	procstat->files = files;
 
 	/*
 	 * Allocate list head.
 	 */
 	head = malloc(sizeof(*head));
 	if (head == NULL)
 		return (NULL);
 	STAILQ_INIT(head);
 	for (i = 0; i < cnt; i++) {
 		kif = &files[i];
 
 		type = kinfo_type2fst(kif->kf_type);
 		fd = kif->kf_fd >= 0 ? kif->kf_fd : -1;
 		fflags = kinfo_fflags2fst(kif->kf_flags);
 		uflags = kinfo_uflags2fst(kif->kf_fd);
 		refcount = kif->kf_ref_count;
 		offset = kif->kf_offset;
 		if (*kif->kf_path != '\0')
 			path = strdup(kif->kf_path);
 		else
 			path = NULL;
 		cap_rights = kif->kf_cap_rights;
 
 		/*
 		 * Create filestat entry.
 		 */
 		entry = filestat_new_entry(kif, type, fd, fflags, uflags,
 		    refcount, offset, path, cap_rights);
 		if (entry != NULL)
 			STAILQ_INSERT_TAIL(head, entry, next);
 	}
 	if (mmapped != 0) {
-		vmentries = kinfo_getvmmap(kp->ki_pid, &cnt);
+		vmentries = procstat_getvmmap(procstat, kp, &cnt);
 		procstat->vmentries = vmentries;
 		if (vmentries == NULL || cnt == 0)
 			goto fail;
 		for (i = 0; i < cnt; i++) {
 			kve = &vmentries[i];
 			if (kve->kve_type != KVME_TYPE_VNODE)
 				continue;
 			fflags = 0;
 			if (kve->kve_protection & KVME_PROT_READ)
 				fflags = PS_FST_FFLAG_READ;
 			if ((kve->kve_flags & KVME_FLAG_COW) == 0 &&
 			    kve->kve_protection & KVME_PROT_WRITE)
 				fflags |= PS_FST_FFLAG_WRITE;
 			offset = kve->kve_offset;
 			refcount = kve->kve_ref_count;
 			if (*kve->kve_path != '\0')
 				path = strdup(kve->kve_path);
 			else
 				path = NULL;
 			entry = filestat_new_entry(kve, PS_FST_TYPE_VNODE, -1,
 			    fflags, PS_FST_UFLAG_MMAP, refcount, offset, path,
 			    0);
 			if (entry != NULL)
 				STAILQ_INSERT_TAIL(head, entry, next);
 		}
 	}
 fail:
 	return (head);
 }
 
 int
 procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
     struct pipestat *ps, char *errbuf)
 {
 
 	assert(ps);
 	if (procstat->type == PROCSTAT_KVM) {
 		return (procstat_get_pipe_info_kvm(procstat->kd, fst, ps,
 		    errbuf));
-	} else if (procstat->type == PROCSTAT_SYSCTL) {
+	} else if (procstat->type == PROCSTAT_SYSCTL ||
+		procstat->type == PROCSTAT_CORE) {
 		return (procstat_get_pipe_info_sysctl(fst, ps, errbuf));
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 		return (1);
 	}
 }
 
 static int
 procstat_get_pipe_info_kvm(kvm_t *kd, struct filestat *fst,
     struct pipestat *ps, char *errbuf)
 {
 	struct pipe pi;
 	void *pipep;
 
 	assert(kd);
 	assert(ps);
 	assert(fst);
 	bzero(ps, sizeof(*ps));
 	pipep = fst->fs_typedep;
 	if (pipep == NULL)
 		goto fail;
 	if (!kvm_read_all(kd, (unsigned long)pipep, &pi, sizeof(struct pipe))) {
 		warnx("can't read pipe at %p", (void *)pipep);
 		goto fail;
 	}
 	ps->addr = (uintptr_t)pipep;
 	ps->peer = (uintptr_t)pi.pipe_peer;
 	ps->buffer_cnt = pi.pipe_buffer.cnt;
 	return (0);
 
 fail:
 	snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 	return (1);
 }
 
 static int
 procstat_get_pipe_info_sysctl(struct filestat *fst, struct pipestat *ps,
     char *errbuf __unused)
 {
 	struct kinfo_file *kif;
 
 	assert(ps);
 	assert(fst);
 	bzero(ps, sizeof(*ps));
 	kif = fst->fs_typedep;
 	if (kif == NULL)
 		return (1);
 	ps->addr = kif->kf_un.kf_pipe.kf_pipe_addr;
 	ps->peer = kif->kf_un.kf_pipe.kf_pipe_peer;
 	ps->buffer_cnt = kif->kf_un.kf_pipe.kf_pipe_buffer_cnt;
 	return (0);
 }
 
 int
 procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
     struct ptsstat *pts, char *errbuf)
 {
 
 	assert(pts);
 	if (procstat->type == PROCSTAT_KVM) {
 		return (procstat_get_pts_info_kvm(procstat->kd, fst, pts,
 		    errbuf));
-	} else if (procstat->type == PROCSTAT_SYSCTL) {
+	} else if (procstat->type == PROCSTAT_SYSCTL ||
+		procstat->type == PROCSTAT_CORE) {
 		return (procstat_get_pts_info_sysctl(fst, pts, errbuf));
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 		return (1);
 	}
 }
 
 static int
 procstat_get_pts_info_kvm(kvm_t *kd, struct filestat *fst,
     struct ptsstat *pts, char *errbuf)
 {
 	struct tty tty;
 	void *ttyp;
 
 	assert(kd);
 	assert(pts);
 	assert(fst);
 	bzero(pts, sizeof(*pts));
 	ttyp = fst->fs_typedep;
 	if (ttyp == NULL)
 		goto fail;
 	if (!kvm_read_all(kd, (unsigned long)ttyp, &tty, sizeof(struct tty))) {
 		warnx("can't read tty at %p", (void *)ttyp);
 		goto fail;
 	}
 	pts->dev = dev2udev(kd, tty.t_dev);
 	(void)kdevtoname(kd, tty.t_dev, pts->devname);
 	return (0);
 
 fail:
 	snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 	return (1);
 }
 
 static int
 procstat_get_pts_info_sysctl(struct filestat *fst, struct ptsstat *pts,
     char *errbuf __unused)
 {
 	struct kinfo_file *kif;
 
 	assert(pts);
 	assert(fst);
 	bzero(pts, sizeof(*pts));
 	kif = fst->fs_typedep;
 	if (kif == NULL)
 		return (0);
 	pts->dev = kif->kf_un.kf_pts.kf_pts_dev;
 	strlcpy(pts->devname, kif->kf_path, sizeof(pts->devname));
 	return (0);
 }
 
 int
 procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
     struct shmstat *shm, char *errbuf)
 {
 
 	assert(shm);
 	if (procstat->type == PROCSTAT_KVM) {
 		return (procstat_get_shm_info_kvm(procstat->kd, fst, shm,
 		    errbuf));
-	} else if (procstat->type == PROCSTAT_SYSCTL) {
+	} else if (procstat->type == PROCSTAT_SYSCTL ||
+	    procstat->type == PROCSTAT_CORE) {
 		return (procstat_get_shm_info_sysctl(fst, shm, errbuf));
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 		return (1);
 	}
 }
 
 static int
 procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
     struct shmstat *shm, char *errbuf)
 {
 	struct shmfd shmfd;
 	void *shmfdp;
 	char *path;
 	int i;
 
 	assert(kd);
 	assert(shm);
 	assert(fst);
 	bzero(shm, sizeof(*shm));
 	shmfdp = fst->fs_typedep;
 	if (shmfdp == NULL)
 		goto fail;
 	if (!kvm_read_all(kd, (unsigned long)shmfdp, &shmfd,
 	    sizeof(struct shmfd))) {
 		warnx("can't read shmfd at %p", (void *)shmfdp);
 		goto fail;
 	}
 	shm->mode = S_IFREG | shmfd.shm_mode;
 	shm->size = shmfd.shm_size;
 	if (fst->fs_path == NULL && shmfd.shm_path != NULL) {
 		path = malloc(MAXPATHLEN);
 		for (i = 0; i < MAXPATHLEN - 1; i++) {
 			if (!kvm_read_all(kd, (unsigned long)shmfd.shm_path + i,
 			    path + i, 1))
 				break;
 			if (path[i] == '\0')
 				break;
 		}
 		path[i] = '\0';
 		if (i == 0)
 			free(path);
 		else
 			fst->fs_path = path;
 	}
 	return (0);
 
 fail:
 	snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 	return (1);
 }
 
 static int
 procstat_get_shm_info_sysctl(struct filestat *fst, struct shmstat *shm,
     char *errbuf __unused)
 {
 	struct kinfo_file *kif;
 
 	assert(shm);
 	assert(fst);
 	bzero(shm, sizeof(*shm));
 	kif = fst->fs_typedep;
 	if (kif == NULL)
 		return (0);
 	shm->size = kif->kf_un.kf_file.kf_file_size;
 	shm->mode = kif->kf_un.kf_file.kf_file_mode;
 	return (0);
 }
 
 int
 procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
     struct vnstat *vn, char *errbuf)
 {
 
 	assert(vn);
 	if (procstat->type == PROCSTAT_KVM) {
 		return (procstat_get_vnode_info_kvm(procstat->kd, fst, vn,
 		    errbuf));
-	} else if (procstat->type == PROCSTAT_SYSCTL) {
+	} else if (procstat->type == PROCSTAT_SYSCTL ||
+		procstat->type == PROCSTAT_CORE) {
 		return (procstat_get_vnode_info_sysctl(fst, vn, errbuf));
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 		return (1);
 	}
 }
 
 static int
 procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst,
     struct vnstat *vn, char *errbuf)
 {
 	/* Filesystem specific handlers. */
 	#define FSTYPE(fst)     {#fst, fst##_filestat}
 	struct {
 		const char	*tag;
 		int		(*handler)(kvm_t *kd, struct vnode *vp,
 		    struct vnstat *vn);
 	} fstypes[] = {
 		FSTYPE(devfs),
 		FSTYPE(isofs),
 		FSTYPE(msdosfs),
 		FSTYPE(nfs),
 		FSTYPE(udf), 
 		FSTYPE(ufs),
 #ifdef LIBPROCSTAT_ZFS
 		FSTYPE(zfs),
 #endif
 	};
 #define	NTYPES	(sizeof(fstypes) / sizeof(*fstypes))
 	struct vnode vnode;
 	char tagstr[12];
 	void *vp;
 	int error, found;
 	unsigned int i;
 
 	assert(kd);
 	assert(vn);
 	assert(fst);
 	vp = fst->fs_typedep;
 	if (vp == NULL)
 		goto fail;
 	error = kvm_read_all(kd, (unsigned long)vp, &vnode, sizeof(vnode));
 	if (error == 0) {
 		warnx("can't read vnode at %p", (void *)vp);
 		goto fail;
 	}
 	bzero(vn, sizeof(*vn));
 	vn->vn_type = vntype2psfsttype(vnode.v_type);
 	if (vnode.v_type == VNON || vnode.v_type == VBAD)
 		return (0);
 	error = kvm_read_all(kd, (unsigned long)vnode.v_tag, tagstr,
 	    sizeof(tagstr));
 	if (error == 0) {
 		warnx("can't read v_tag at %p", (void *)vp);
 		goto fail;
 	}
 	tagstr[sizeof(tagstr) - 1] = '\0';
 
 	/*
 	 * Find appropriate handler.
 	 */
 	for (i = 0, found = 0; i < NTYPES; i++)
 		if (!strcmp(fstypes[i].tag, tagstr)) {
 			if (fstypes[i].handler(kd, &vnode, vn) != 0) {
 				goto fail;
 			}
 			break;
 		}
 	if (i == NTYPES) {
 		snprintf(errbuf, _POSIX2_LINE_MAX, "?(%s)", tagstr);
 		return (1);
 	}
 	vn->vn_mntdir = getmnton(kd, vnode.v_mount);
 	if ((vnode.v_type == VBLK || vnode.v_type == VCHR) &&
 	    vnode.v_rdev != NULL){
 		vn->vn_dev = dev2udev(kd, vnode.v_rdev);
 		(void)kdevtoname(kd, vnode.v_rdev, vn->vn_devname);
 	} else {
 		vn->vn_dev = -1;
 	}
 	return (0);
 
 fail:
 	snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 	return (1);
 }
 
 /*
  * kinfo vnode type to filestat translation.
  */
 static int
 kinfo_vtype2fst(int kfvtype)
 {
 	static struct {
 		int	kf_vtype; 
 		int	fst_vtype;
 	} kfvtypes2fst[] = {
 		{ KF_VTYPE_VBAD, PS_FST_VTYPE_VBAD },
 		{ KF_VTYPE_VBLK, PS_FST_VTYPE_VBLK },
 		{ KF_VTYPE_VCHR, PS_FST_VTYPE_VCHR },
 		{ KF_VTYPE_VDIR, PS_FST_VTYPE_VDIR },
 		{ KF_VTYPE_VFIFO, PS_FST_VTYPE_VFIFO },
 		{ KF_VTYPE_VLNK, PS_FST_VTYPE_VLNK },
 		{ KF_VTYPE_VNON, PS_FST_VTYPE_VNON },
 		{ KF_VTYPE_VREG, PS_FST_VTYPE_VREG },
 		{ KF_VTYPE_VSOCK, PS_FST_VTYPE_VSOCK }
 	};
 #define	NKFVTYPES	(sizeof(kfvtypes2fst) / sizeof(*kfvtypes2fst))
 	unsigned int i;
 
 	for (i = 0; i < NKFVTYPES; i++)
 		if (kfvtypes2fst[i].kf_vtype == kfvtype)
 			break;
 	if (i == NKFVTYPES)
 		return (PS_FST_VTYPE_UNKNOWN);
 	return (kfvtypes2fst[i].fst_vtype);
 }
 
 static int
 procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn,
     char *errbuf)
 {
 	struct statfs stbuf;
 	struct kinfo_file *kif;
 	struct kinfo_vmentry *kve;
 	uint64_t fileid;
 	uint64_t size;
 	char *name, *path;
 	uint32_t fsid;
 	uint16_t mode;
 	uint32_t rdev;
 	int vntype;
 	int status;
 
 	assert(fst);
 	assert(vn);
 	bzero(vn, sizeof(*vn));
 	if (fst->fs_typedep == NULL)
 		return (1);
 	if (fst->fs_uflags & PS_FST_UFLAG_MMAP) {
 		kve = fst->fs_typedep;
 		fileid = kve->kve_vn_fileid;
 		fsid = kve->kve_vn_fsid;
 		mode = kve->kve_vn_mode;
 		path = kve->kve_path;
 		rdev = kve->kve_vn_rdev;
 		size = kve->kve_vn_size;
 		vntype = kinfo_vtype2fst(kve->kve_vn_type);
 		status = kve->kve_status;
 	} else {
 		kif = fst->fs_typedep;
 		fileid = kif->kf_un.kf_file.kf_file_fileid;
 		fsid = kif->kf_un.kf_file.kf_file_fsid;
 		mode = kif->kf_un.kf_file.kf_file_mode;
 		path = kif->kf_path;
 		rdev = kif->kf_un.kf_file.kf_file_rdev;
 		size = kif->kf_un.kf_file.kf_file_size;
 		vntype = kinfo_vtype2fst(kif->kf_vnode_type);
 		status = kif->kf_status;
 	}
 	vn->vn_type = vntype;
 	if (vntype == PS_FST_VTYPE_VNON || vntype == PS_FST_VTYPE_VBAD)
 		return (0);
 	if ((status & KF_ATTR_VALID) == 0) {
 		snprintf(errbuf, _POSIX2_LINE_MAX, "? (no info available)");
 		return (1);
 	}
 	if (path && *path) {
 		statfs(path, &stbuf);
 		vn->vn_mntdir = strdup(stbuf.f_mntonname);
 	} else
 		vn->vn_mntdir = strdup("-");
 	vn->vn_dev = rdev;
 	if (vntype == PS_FST_VTYPE_VBLK) {
 		name = devname(rdev, S_IFBLK);
 		if (name != NULL)
 			strlcpy(vn->vn_devname, name,
 			    sizeof(vn->vn_devname));
 	} else if (vntype == PS_FST_VTYPE_VCHR) {
 		name = devname(vn->vn_dev, S_IFCHR);
 		if (name != NULL)
 			strlcpy(vn->vn_devname, name,
 			    sizeof(vn->vn_devname));
 	}
 	vn->vn_fsid = fsid;
 	vn->vn_fileid = fileid;
 	vn->vn_size = size;
 	vn->vn_mode = mode;
 	return (0);
 }
 
 int
 procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
     struct sockstat *sock, char *errbuf)
 {
 
 	assert(sock);
 	if (procstat->type == PROCSTAT_KVM) {
 		return (procstat_get_socket_info_kvm(procstat->kd, fst, sock,
 		    errbuf));
-	} else if (procstat->type == PROCSTAT_SYSCTL) {
+	} else if (procstat->type == PROCSTAT_SYSCTL ||
+		procstat->type == PROCSTAT_CORE) {
 		return (procstat_get_socket_info_sysctl(fst, sock, errbuf));
 	} else {
 		warnx("unknown access method: %d", procstat->type);
 		snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 		return (1);
 	}
 }
 
 static int
 procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
     struct sockstat *sock, char *errbuf)
 {
 	struct domain dom;
 	struct inpcb inpcb;
 	struct protosw proto;
 	struct socket s;
 	struct unpcb unpcb;
 	ssize_t len;
 	void *so;
 
 	assert(kd);
 	assert(sock);
 	assert(fst);
 	bzero(sock, sizeof(*sock));
 	so = fst->fs_typedep;
 	if (so == NULL)
 		goto fail;
 	sock->so_addr = (uintptr_t)so;
 	/* fill in socket */
 	if (!kvm_read_all(kd, (unsigned long)so, &s,
 	    sizeof(struct socket))) {
 		warnx("can't read sock at %p", (void *)so);
 		goto fail;
 	}
 	/* fill in protosw entry */
 	if (!kvm_read_all(kd, (unsigned long)s.so_proto, &proto,
 	    sizeof(struct protosw))) {
 		warnx("can't read protosw at %p", (void *)s.so_proto);
 		goto fail;
 	}
 	/* fill in domain */
 	if (!kvm_read_all(kd, (unsigned long)proto.pr_domain, &dom,
 	    sizeof(struct domain))) {
 		warnx("can't read domain at %p",
 		    (void *)proto.pr_domain);
 		goto fail;
 	}
 	if ((len = kvm_read(kd, (unsigned long)dom.dom_name, sock->dname,
 	    sizeof(sock->dname) - 1)) < 0) {
 		warnx("can't read domain name at %p", (void *)dom.dom_name);
 		sock->dname[0] = '\0';
 	}
 	else
 		sock->dname[len] = '\0';
 	
 	/*
 	 * Fill in known data.
 	 */
 	sock->type = s.so_type;
 	sock->proto = proto.pr_protocol;
 	sock->dom_family = dom.dom_family;
 	sock->so_pcb = (uintptr_t)s.so_pcb;
 
 	/*
 	 * Protocol specific data.
 	 */
 	switch(dom.dom_family) {
 	case AF_INET:
 	case AF_INET6:
 		if (proto.pr_protocol == IPPROTO_TCP) {
 			if (s.so_pcb) {
 				if (kvm_read(kd, (u_long)s.so_pcb,
 				    (char *)&inpcb, sizeof(struct inpcb))
 				    != sizeof(struct inpcb)) {
 					warnx("can't read inpcb at %p",
 					    (void *)s.so_pcb);
 				} else
 					sock->inp_ppcb =
 					    (uintptr_t)inpcb.inp_ppcb;
 			}
 		}
 		break;
 	case AF_UNIX:
 		if (s.so_pcb) {
 			if (kvm_read(kd, (u_long)s.so_pcb, (char *)&unpcb,
 			    sizeof(struct unpcb)) != sizeof(struct unpcb)){
 				warnx("can't read unpcb at %p",
 				    (void *)s.so_pcb);
 			} else if (unpcb.unp_conn) {
 				sock->so_rcv_sb_state = s.so_rcv.sb_state;
 				sock->so_snd_sb_state = s.so_snd.sb_state;
 				sock->unp_conn = (uintptr_t)unpcb.unp_conn;
 			}
 		}
 		break;
 	default:
 		break;
 	}
 	return (0);
 
 fail:
 	snprintf(errbuf, _POSIX2_LINE_MAX, "error");
 	return (1);
 }
 
 static int
 procstat_get_socket_info_sysctl(struct filestat *fst, struct sockstat *sock,
     char *errbuf __unused)
 {
 	struct kinfo_file *kif;
 
 	assert(sock);
 	assert(fst);
 	bzero(sock, sizeof(*sock));
 	kif = fst->fs_typedep;
 	if (kif == NULL)
 		return (0);
 
 	/*
 	 * Fill in known data.
 	 */
 	sock->type = kif->kf_sock_type;
 	sock->proto = kif->kf_sock_protocol;
 	sock->dom_family = kif->kf_sock_domain;
 	sock->so_pcb = kif->kf_un.kf_sock.kf_sock_pcb;
 	strlcpy(sock->dname, kif->kf_path, sizeof(sock->dname));
 	bcopy(&kif->kf_sa_local, &sock->sa_local, kif->kf_sa_local.ss_len);
 	bcopy(&kif->kf_sa_peer, &sock->sa_peer, kif->kf_sa_peer.ss_len);
 
 	/*
 	 * Protocol specific data.
 	 */
 	switch(sock->dom_family) {
 	case AF_INET:
 	case AF_INET6:
 		if (sock->proto == IPPROTO_TCP)
 			sock->inp_ppcb = kif->kf_un.kf_sock.kf_sock_inpcb;
 		break;
 	case AF_UNIX:
 		if (kif->kf_un.kf_sock.kf_sock_unpconn != 0) {
 				sock->so_rcv_sb_state =
 				    kif->kf_un.kf_sock.kf_sock_rcv_sb_state;
 				sock->so_snd_sb_state =
 				    kif->kf_un.kf_sock.kf_sock_snd_sb_state;
 				sock->unp_conn =
 				    kif->kf_un.kf_sock.kf_sock_unpconn;
 		}
 		break;
 	default:
 		break;
 	}
 	return (0);
 }
 
 /*
  * Descriptor flags to filestat translation.
  */
 static int
 to_filestat_flags(int flags)
 {
 	static struct {
 		int flag;
 		int fst_flag;
 	} fstflags[] = {
 		{ FREAD, PS_FST_FFLAG_READ },
 		{ FWRITE, PS_FST_FFLAG_WRITE },
 		{ O_APPEND, PS_FST_FFLAG_APPEND },
 		{ O_ASYNC, PS_FST_FFLAG_ASYNC },
 		{ O_CREAT, PS_FST_FFLAG_CREAT },
 		{ O_DIRECT, PS_FST_FFLAG_DIRECT },
 		{ O_EXCL, PS_FST_FFLAG_EXCL },
 		{ O_EXEC, PS_FST_FFLAG_EXEC },
 		{ O_EXLOCK, PS_FST_FFLAG_EXLOCK },
 		{ O_NOFOLLOW, PS_FST_FFLAG_NOFOLLOW },
 		{ O_NONBLOCK, PS_FST_FFLAG_NONBLOCK },
 		{ O_SHLOCK, PS_FST_FFLAG_SHLOCK },
 		{ O_SYNC, PS_FST_FFLAG_SYNC },
 		{ O_TRUNC, PS_FST_FFLAG_TRUNC }
 	};
 #define NFSTFLAGS	(sizeof(fstflags) / sizeof(*fstflags))
 	int fst_flags;
 	unsigned int i;
 
 	fst_flags = 0;
 	for (i = 0; i < NFSTFLAGS; i++)
 		if (flags & fstflags[i].flag)
 			fst_flags |= fstflags[i].fst_flag;
 	return (fst_flags);
 }
 
 /*
  * Vnode type to filestate translation.
  */
 static int
 vntype2psfsttype(int type)
 {
 	static struct {
 		int	vtype; 
 		int	fst_vtype;
 	} vt2fst[] = {
 		{ VBAD, PS_FST_VTYPE_VBAD },
 		{ VBLK, PS_FST_VTYPE_VBLK },
 		{ VCHR, PS_FST_VTYPE_VCHR },
 		{ VDIR, PS_FST_VTYPE_VDIR },
 		{ VFIFO, PS_FST_VTYPE_VFIFO },
 		{ VLNK, PS_FST_VTYPE_VLNK },
 		{ VNON, PS_FST_VTYPE_VNON },
 		{ VREG, PS_FST_VTYPE_VREG },
 		{ VSOCK, PS_FST_VTYPE_VSOCK }
 	};
 #define	NVFTYPES	(sizeof(vt2fst) / sizeof(*vt2fst))
 	unsigned int i, fst_type;
 
 	fst_type = PS_FST_VTYPE_UNKNOWN;
 	for (i = 0; i < NVFTYPES; i++) {
 		if (type == vt2fst[i].vtype) {
 			fst_type = vt2fst[i].fst_vtype;
 			break;
 		}
 	}
 	return (fst_type);
 }
 
 static char *
 getmnton(kvm_t *kd, struct mount *m)
 {
 	struct mount mnt;
 	static struct mtab {
 		struct mtab *next;
 		struct mount *m;
 		char mntonname[MNAMELEN + 1];
 	} *mhead = NULL;
 	struct mtab *mt;
 
 	for (mt = mhead; mt != NULL; mt = mt->next)
 		if (m == mt->m)
 			return (mt->mntonname);
 	if (!kvm_read_all(kd, (unsigned long)m, &mnt, sizeof(struct mount))) {
 		warnx("can't read mount table at %p", (void *)m);
 		return (NULL);
 	}
 	if ((mt = malloc(sizeof (struct mtab))) == NULL)
 		err(1, NULL);
 	mt->m = m;
 	bcopy(&mnt.mnt_stat.f_mntonname[0], &mt->mntonname[0], MNAMELEN);
 	mt->mntonname[MNAMELEN] = '\0';
 	mt->next = mhead;
 	mhead = mt;
 	return (mt->mntonname);
+}
+
+/*
+ * Auxiliary structures and functions to get process environment or
+ * command line arguments.
+ */
+struct argvec {
+	char	*buf;
+	size_t	bufsize;
+	char	**argv;
+	size_t	argc;
+};
+
+static struct argvec *
+argvec_alloc(size_t bufsize)
+{
+	struct argvec *av;
+
+	av = malloc(sizeof(*av));
+	if (av == NULL)
+		return (NULL);
+	av->bufsize = bufsize;
+	av->buf = malloc(av->bufsize);
+	if (av->buf == NULL) {
+		free(av);
+		return (NULL);
+	}
+	av->argc = 32;
+	av->argv = malloc(sizeof(char *) * av->argc);
+	if (av->argv == NULL) {
+		free(av->buf);
+		free(av);
+		return (NULL);
+	}
+	return av;
+}
+
+static void
+argvec_free(struct argvec * av)
+{
+
+	free(av->argv);
+	free(av->buf);
+	free(av);
+}
+
+static char **
+getargv(struct procstat *procstat, struct kinfo_proc *kp, size_t nchr, int env)
+{
+	int error, name[4], argc, i;
+	struct argvec *av, **avp;
+	enum psc_type type;
+	size_t len;
+	char *p, **argv;
+
+	assert(procstat);
+	assert(kp);
+	if (procstat->type == PROCSTAT_KVM) {
+		warnx("can't use kvm access method");
+		return (NULL);
+	}
+	if (procstat->type != PROCSTAT_SYSCTL &&
+	    procstat->type != PROCSTAT_CORE) {
+		warnx("unknown access method: %d", procstat->type);
+		return (NULL);
+	}
+
+	if (nchr == 0 || nchr > ARG_MAX)
+		nchr = ARG_MAX;
+
+	avp = (struct argvec **)(env ? &procstat->argv : &procstat->envv);
+	av = *avp;
+
+	if (av == NULL)
+	{
+		av = argvec_alloc(nchr);
+		if (av == NULL)
+		{
+			warn("malloc(%zu)", nchr);
+			return (NULL);
+		}
+		*avp = av;
+	} else if (av->bufsize < nchr) {
+		av->buf = reallocf(av->buf, nchr);
+		if (av->buf == NULL) {
+			warn("malloc(%zu)", nchr);
+			return (NULL);
+		}
+	}
+	if (procstat->type == PROCSTAT_SYSCTL) {
+		name[0] = CTL_KERN;
+		name[1] = KERN_PROC;
+		name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
+		name[3] = kp->ki_pid;
+		len = nchr;
+		error = sysctl(name, 4, av->buf, &len, NULL, 0);
+		if (error != 0 && errno != ESRCH && errno != EPERM)
+			warn("sysctl(kern.proc.%s)", env ? "env" : "args");
+		if (error != 0 || len == 0)
+			return (NULL);
+	} else /* procstat->type == PROCSTAT_CORE */ {
+		type = env ? PSC_TYPE_ENVV : PSC_TYPE_ARGV;
+		len = nchr;
+		if (procstat_core_get(procstat->core, type, av->buf, &len)
+		    == NULL) {
+			return (NULL);
+		}
+	}
+
+	argv = av->argv;
+	argc = av->argc;
+	i = 0;
+	for (p = av->buf; p < av->buf + len; p += strlen(p) + 1) {
+		argv[i++] = p;
+		if (i < argc)
+			continue;
+		/* Grow argv. */
+		argc += argc;
+		argv = realloc(argv, sizeof(char *) * argc);
+		if (argv == NULL) {
+			warn("malloc(%zu)", sizeof(char *) * argc);
+			return (NULL);
+		}
+		av->argv = argv;
+		av->argc = argc;
+	}
+	argv[i] = NULL;
+
+	return (argv);
+}
+
+/*
+ * Return process command line arguments.
+ */
+char **
+procstat_getargv(struct procstat *procstat, struct kinfo_proc *p, size_t nchr)
+{
+
+	return (getargv(procstat, p, nchr, 0));
+}
+
+/*
+ * Free the buffer allocated by procstat_getargv().
+ */
+void
+procstat_freeargv(struct procstat *procstat)
+{
+
+	if (procstat->argv != NULL) {
+		argvec_free(procstat->argv);
+		procstat->argv = NULL;
+	}
+}
+
+/*
+ * Return process environment.
+ */
+char **
+procstat_getenvv(struct procstat *procstat, struct kinfo_proc *p, size_t nchr)
+{
+
+	return (getargv(procstat, p, nchr, 1));
+}
+
+/*
+ * Free the buffer allocated by procstat_getenvv().
+ */
+void
+procstat_freeenvv(struct procstat *procstat)
+{
+	if (procstat->envv != NULL) {
+		argvec_free(procstat->envv);
+		procstat->envv = NULL;
+	}
+}
+
+static struct kinfo_vmentry *
+kinfo_getvmmap_core(struct procstat_core *core, int *cntp)
+{
+	int cnt;
+	size_t len;
+	char *buf, *bp, *eb;
+	struct kinfo_vmentry *kiv, *kp, *kv;
+
+	buf = procstat_core_get(core, PSC_TYPE_VMMAP, NULL, &len);
+	if (buf == NULL)
+		return (NULL);
+
+	/*
+	 * XXXMG: The code below is just copy&past from libutil.
+	 * The code duplication can be avoided if libutil
+	 * is extended to provide something like:
+	 *   struct kinfo_vmentry *kinfo_getvmmap_from_buf(const char *buf,
+	 *       size_t len, int *cntp);
+	 */
+
+	/* Pass 1: count items */
+	cnt = 0;
+	bp = buf;
+	eb = buf + len;
+	while (bp < eb) {
+		kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+		bp += kv->kve_structsize;
+		cnt++;
+	}
+
+	kiv = calloc(cnt, sizeof(*kiv));
+	if (kiv == NULL) {
+		free(buf);
+		return (NULL);
+	}
+	bp = buf;
+	eb = buf + len;
+	kp = kiv;
+	/* Pass 2: unpack */
+	while (bp < eb) {
+		kv = (struct kinfo_vmentry *)(uintptr_t)bp;
+		/* Copy/expand into pre-zeroed buffer */
+		memcpy(kp, kv, kv->kve_structsize);
+		/* Advance to next packed record */
+		bp += kv->kve_structsize;
+		/* Set field size to fixed length, advance */
+		kp->kve_structsize = sizeof(*kp);
+		kp++;
+	}
+	free(buf);
+	*cntp = cnt;
+	return (kiv);	/* Caller must free() return value */
+}
+
+struct kinfo_vmentry *
+procstat_getvmmap(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned int *cntp)
+{
+
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (NULL);
+	case PROCSTAT_SYSCTL:
+		return (kinfo_getvmmap(kp->ki_pid, cntp));
+	case PROCSTAT_CORE:
+		return (kinfo_getvmmap_core(procstat->core, cntp));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (NULL);
+	}
+}
+
+void
+procstat_freevmmap(struct procstat *procstat __unused,
+    struct kinfo_vmentry *vmmap)
+{
+
+	free(vmmap);
+}
+
+static gid_t *
+procstat_getgroups_sysctl(pid_t pid, unsigned int *cntp)
+{
+	int mib[4];
+	size_t len;
+	gid_t *groups;
+
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_PROC;
+	mib[2] = KERN_PROC_GROUPS;
+	mib[3] = pid;
+	len = (sysconf(_SC_NGROUPS_MAX) + 1) * sizeof(gid_t);
+	groups = malloc(len);
+	if (groups == NULL) {
+		warn("malloc(%zu)", len);
+		return (NULL);
+	}
+	if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
+		warn("sysctl: kern.proc.groups: %d", pid);
+		free(groups);
+		return (NULL);
+	}
+	*cntp = len / sizeof(gid_t);
+	return (groups);
+}
+
+static gid_t *
+procstat_getgroups_core(struct procstat_core *core, unsigned int *cntp)
+{
+	size_t len;
+	gid_t *groups;
+
+	groups = procstat_core_get(core, PSC_TYPE_GROUPS, NULL, &len);
+	if (groups == NULL)
+		return (NULL);
+	*cntp = len / sizeof(gid_t);
+	return (groups);
+}
+
+gid_t *
+procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned int *cntp)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (NULL);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getgroups_sysctl(kp->ki_pid, cntp));
+	case PROCSTAT_CORE:
+		return (procstat_getgroups_core(procstat->core, cntp));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (NULL);
+	}
+}
+
+void
+procstat_freegroups(struct procstat *procstat __unused, gid_t *groups)
+{
+
+	free(groups);
+}
+
+static int
+procstat_getumask_sysctl(pid_t pid, unsigned short *maskp)
+{
+	int error;
+	int mib[4];
+	size_t len;
+
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_PROC;
+	mib[2] = KERN_PROC_UMASK;
+	mib[3] = pid;
+	len = sizeof(*maskp);
+	error = sysctl(mib, 4, maskp, &len, NULL, 0);
+	if (error != 0 && errno != ESRCH)
+		warn("sysctl: kern.proc.umask: %d", pid);
+	return (error);
+}
+
+static int
+procstat_getumask_core(struct procstat_core *core, unsigned short *maskp)
+{
+	size_t len;
+	unsigned short *buf;
+
+	buf = procstat_core_get(core, PSC_TYPE_UMASK, NULL, &len);
+	if (buf == NULL)
+		return (-1);
+	if (len < sizeof(*maskp)) {
+		free(buf);
+		return (-1);
+	}
+	*maskp = *buf;
+	free(buf);
+	return (0);
+}
+
+int
+procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned short *maskp)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (-1);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getumask_sysctl(kp->ki_pid, maskp));
+	case PROCSTAT_CORE:
+		return (procstat_getumask_core(procstat->core, maskp));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (-1);
+	}
+}
+
+static int
+procstat_getrlimit_sysctl(pid_t pid, int which, struct rlimit* rlimit)
+{
+	int error, name[5];
+	size_t len;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_RLIMIT;
+	name[3] = pid;
+	name[4] = which;
+	len = sizeof(struct rlimit);
+	error = sysctl(name, 5, rlimit, &len, NULL, 0);
+	if (error < 0 && errno != ESRCH) {
+		warn("sysctl: kern.proc.rlimit: %d", pid);
+		return (-1);
+	}
+	if (error < 0 || len != sizeof(struct rlimit))
+		return (-1);
+	return (0);
+}
+
+static int
+procstat_getrlimit_core(struct procstat_core *core, int which,
+    struct rlimit* rlimit)
+{
+	size_t len;
+	struct rlimit* rlimits;
+
+	if (which < 0 || which >= RLIM_NLIMITS) {
+		errno = EINVAL;
+		warn("getrlimit: which");
+		return (-1);
+	}
+	rlimits = procstat_core_get(core, PSC_TYPE_RLIMIT, NULL, &len);
+	if (rlimits == NULL)
+		return (-1);
+	if (len < sizeof(struct rlimit) * RLIM_NLIMITS) {
+		free(rlimits);
+		return (-1);
+	}
+	*rlimit = rlimits[which];
+	return (0);
+}
+
+int
+procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp, int which,
+    struct rlimit* rlimit)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (-1);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getrlimit_sysctl(kp->ki_pid, which, rlimit));
+	case PROCSTAT_CORE:
+		return (procstat_getrlimit_core(procstat->core, which, rlimit));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (-1);
+	}
+}
+
+static int
+procstat_getpathname_sysctl(pid_t pid, char *pathname, size_t maxlen)
+{
+	int error, name[4];
+	size_t len;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PATHNAME;
+	name[3] = pid;
+	len = maxlen;
+	error = sysctl(name, 4, pathname, &len, NULL, 0);
+	if (error != 0 && errno != ESRCH)
+		warn("sysctl: kern.proc.pathname: %d", pid);
+	if (len == 0)
+		pathname[0] = '\0';
+	return (error);
+}
+
+static int
+procstat_getpathname_core(struct procstat_core *core, char *pathname,
+    size_t maxlen)
+{
+	struct kinfo_file *files;
+	int cnt, i, result;
+
+	files = kinfo_getfile_core(core, &cnt);
+	if (files == NULL)
+		return (-1);
+	result = -1;
+	for (i = 0; i < cnt; i++) {
+		if (files[i].kf_fd != KF_FD_TYPE_TEXT)
+			continue;
+		strncpy(pathname, files[i].kf_path, maxlen);
+		result = 0;
+		break;
+	}
+	free(files);
+	return (result);
+}
+
+int
+procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
+    char *pathname, size_t maxlen)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (-1);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getpathname_sysctl(kp->ki_pid, pathname,
+		    maxlen));
+	case PROCSTAT_CORE:
+		return (procstat_getpathname_core(procstat->core, pathname,
+		    maxlen));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (-1);
+	}
+}
+
+static int
+procstat_getosrel_sysctl(pid_t pid, int *osrelp)
+{
+	int error, name[4];
+	size_t len;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_OSREL;
+	name[3] = pid;
+	len = sizeof(*osrelp);
+	error = sysctl(name, 4, osrelp, &len, NULL, 0);
+	if (error != 0 && errno != ESRCH)
+		warn("sysctl: kern.proc.osrel: %d", pid);
+	return (error);
+}
+
+static int
+procstat_getosrel_core(struct procstat_core *core, int *osrelp)
+{
+	size_t len;
+	int *buf;
+
+	buf = procstat_core_get(core, PSC_TYPE_OSREL, NULL, &len);
+	if (buf == NULL)
+		return (-1);
+	if (len < sizeof(*osrelp)) {
+		free(buf);
+		return (-1);
+	}
+	*osrelp = *buf;
+	free(buf);
+	return (0);
+}
+
+int
+procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp, int *osrelp)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (-1);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getosrel_sysctl(kp->ki_pid, osrelp));
+	case PROCSTAT_CORE:
+		return (procstat_getosrel_core(procstat->core, osrelp));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (-1);
+	}
+}
+
+#define PROC_AUXV_MAX	256
+
+#if __ELF_WORD_SIZE == 64
+static const char *elf32_sv_names[] = {
+	"Linux ELF32",
+	"FreeBSD ELF32",
+};
+
+static int
+is_elf32_sysctl(pid_t pid)
+{
+	int error, name[4];
+	size_t len, i;
+	static char sv_name[256];
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_SV_NAME;
+	name[3] = pid;
+	len = sizeof(sv_name);
+	error = sysctl(name, 4, sv_name, &len, NULL, 0);
+	if (error != 0 || len == 0)
+		return (0);
+	for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
+		if (strncmp(sv_name, elf32_sv_names[i], sizeof(sv_name)) == 0)
+			return (1);
+	}
+	return (0);
+}
+
+static Elf_Auxinfo *
+procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
+{
+	Elf_Auxinfo *auxv;
+	Elf32_Auxinfo *auxv32;
+	void *ptr;
+	size_t len;
+	unsigned int i, count;
+	int name[4];
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_AUXV;
+	name[3] = pid;
+	len = PROC_AUXV_MAX * sizeof(Elf32_Auxinfo);
+	auxv = NULL;
+	auxv32 = malloc(len);
+	if (auxv32 == NULL) {
+		warn("malloc(%zu)", len);
+		goto out;
+	}
+	if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) {
+		if (errno != ESRCH && errno != EPERM)
+			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+		goto out;
+	}
+	count = len / sizeof(Elf_Auxinfo);
+	auxv = malloc(count  * sizeof(Elf_Auxinfo));
+	if (auxv == NULL) {
+		warn("malloc(%zu)", count * sizeof(Elf_Auxinfo));
+		goto out;
+	}
+	for (i = 0; i < count; i++) {
+		/*
+		 * XXX: We expect that values for a_type on a 32-bit platform
+		 * are directly mapped to values on 64-bit one, which is not
+		 * necessarily true.
+		 */
+		auxv[i].a_type = auxv32[i].a_type;
+		ptr = &auxv32[i].a_un;
+		auxv[i].a_un.a_val = *((uint32_t *)ptr);
+	}
+	*cntp = count;
+out:
+	free(auxv32);
+	return (auxv);
+}
+#endif /* __ELF_WORD_SIZE == 64 */
+
+static Elf_Auxinfo *
+procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
+{
+	Elf_Auxinfo *auxv;
+	int name[4];
+	size_t len;
+
+#if __ELF_WORD_SIZE == 64
+	if (is_elf32_sysctl(pid))
+		return (procstat_getauxv32_sysctl(pid, cntp));
+#endif
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_AUXV;
+	name[3] = pid;
+	len = PROC_AUXV_MAX * sizeof(Elf_Auxinfo);
+	auxv = malloc(len);
+	if (auxv == NULL) {
+		warn("malloc(%zu)", len);
+		return (NULL);
+	}
+	if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) {
+		if (errno != ESRCH && errno != EPERM)
+			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
+		free(auxv);
+		return (NULL);
+	}
+	*cntp = len / sizeof(Elf_Auxinfo);
+	return (auxv);
+}
+
+static Elf_Auxinfo *
+procstat_getauxv_core(struct procstat_core *core, unsigned int *cntp)
+{
+	Elf_Auxinfo *auxv;
+	size_t len;
+
+	auxv = procstat_core_get(core, PSC_TYPE_AUXV, NULL, &len);
+	if (auxv == NULL)
+		return (NULL);
+	*cntp = len / sizeof(Elf_Auxinfo);
+	return (auxv);
+}
+
+Elf_Auxinfo *
+procstat_getauxv(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned int *cntp)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (NULL);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getauxv_sysctl(kp->ki_pid, cntp));
+	case PROCSTAT_CORE:
+		return (procstat_getauxv_core(procstat->core, cntp));
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (NULL);
+	}
+}
+
+void
+procstat_freeauxv(struct procstat *procstat __unused, Elf_Auxinfo *auxv)
+{
+
+	free(auxv);
+}
+
+static struct kinfo_kstack *
+procstat_getkstack_sysctl(pid_t pid, int *cntp)
+{
+	struct kinfo_kstack *kkstp;
+	int error, name[4];
+	size_t len;
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_KSTACK;
+	name[3] = pid;
+
+	len = 0;
+	error = sysctl(name, 4, NULL, &len, NULL, 0);
+	if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
+		warn("sysctl: kern.proc.kstack: %d", pid);
+		return (NULL);
+	}
+	if (error == -1 && errno == ENOENT) {
+		warnx("sysctl: kern.proc.kstack unavailable"
+		    " (options DDB or options STACK required in kernel)");
+		return (NULL);
+	}
+	if (error == -1)
+		return (NULL);
+	kkstp = malloc(len);
+	if (kkstp == NULL) {
+		warn("malloc(%zu)", len);
+		return (NULL);
+	}
+	if (sysctl(name, 4, kkstp, &len, NULL, 0) == -1) {
+		warn("sysctl: kern.proc.pid: %d", pid);
+		free(kkstp);
+		return (NULL);
+	}
+	*cntp = len / sizeof(*kkstp);
+
+	return (kkstp);
+}
+
+struct kinfo_kstack *
+procstat_getkstack(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned int *cntp)
+{
+	switch(procstat->type) {
+	case PROCSTAT_KVM:
+		warnx("kvm method is not supported");
+		return (NULL);
+	case PROCSTAT_SYSCTL:
+		return (procstat_getkstack_sysctl(kp->ki_pid, cntp));
+	case PROCSTAT_CORE:
+		warnx("core method is not supported");
+		return (NULL);
+	default:
+		warnx("unknown access method: %d", procstat->type);
+		return (NULL);
+	}
+}
+
+void
+procstat_freekstack(struct procstat *procstat __unused,
+    struct kinfo_kstack *kkstp)
+{
+
+	free(kkstp);
 }
Index: user/attilio/vmcontention/lib/libprocstat/libprocstat.h
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/libprocstat.h	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/libprocstat.h	(revision 249699)
@@ -1,169 +1,213 @@
 /*-
  * Copyright (c) 2009 Stanislav Sedov 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #ifndef _LIBPROCSTAT_H_
 #define	_LIBPROCSTAT_H_
 
 /*
+ * XXX: sys/elf.h conflicts with zfs_context.h. Workaround this by not
+ * including conflicting parts when building zfs code.
+ */
+#ifndef ZFS
+#include 
+#endif
+
+/*
  * Vnode types.
  */
 #define	PS_FST_VTYPE_VNON	1
 #define	PS_FST_VTYPE_VREG	2
 #define	PS_FST_VTYPE_VDIR	3
 #define	PS_FST_VTYPE_VBLK	4
 #define	PS_FST_VTYPE_VCHR	5
 #define	PS_FST_VTYPE_VLNK	6
 #define	PS_FST_VTYPE_VSOCK	7
 #define	PS_FST_VTYPE_VFIFO	8
 #define	PS_FST_VTYPE_VBAD	9
 #define	PS_FST_VTYPE_UNKNOWN	255
 
 /*
  * Descriptor types.
  */
 #define	PS_FST_TYPE_VNODE	1
 #define	PS_FST_TYPE_FIFO	2
 #define	PS_FST_TYPE_SOCKET	3
 #define	PS_FST_TYPE_PIPE	4
 #define	PS_FST_TYPE_PTS		5
 #define	PS_FST_TYPE_KQUEUE	6
 #define	PS_FST_TYPE_CRYPTO	7
 #define	PS_FST_TYPE_MQUEUE	8
 #define	PS_FST_TYPE_SHM		9
 #define	PS_FST_TYPE_SEM		10
 #define	PS_FST_TYPE_UNKNOWN	11
 #define	PS_FST_TYPE_NONE	12
 
 /*
  * Special descriptor numbers.
  */
 #define	PS_FST_UFLAG_RDIR	0x0001
 #define	PS_FST_UFLAG_CDIR	0x0002
 #define	PS_FST_UFLAG_JAIL	0x0004
 #define	PS_FST_UFLAG_TRACE	0x0008
 #define	PS_FST_UFLAG_TEXT	0x0010
 #define	PS_FST_UFLAG_MMAP	0x0020
 #define	PS_FST_UFLAG_CTTY	0x0040
 
 /*
  * Descriptor flags.
  */
 #define PS_FST_FFLAG_READ	0x0001
 #define PS_FST_FFLAG_WRITE	0x0002
 #define	PS_FST_FFLAG_NONBLOCK	0x0004
 #define	PS_FST_FFLAG_APPEND	0x0008
 #define	PS_FST_FFLAG_SHLOCK	0x0010
 #define	PS_FST_FFLAG_EXLOCK	0x0020
 #define	PS_FST_FFLAG_ASYNC	0x0040
 #define	PS_FST_FFLAG_SYNC	0x0080
 #define	PS_FST_FFLAG_NOFOLLOW	0x0100
 #define	PS_FST_FFLAG_CREAT	0x0200
 #define	PS_FST_FFLAG_TRUNC	0x0400
 #define	PS_FST_FFLAG_EXCL	0x0800
 #define	PS_FST_FFLAG_DIRECT	0x1000
 #define	PS_FST_FFLAG_EXEC	0x2000
 #define	PS_FST_FFLAG_HASLOCK	0x4000
 
+struct kinfo_kstack;
+struct kinfo_vmentry;
 struct procstat;
+struct rlimit;
 struct filestat {
 	int	fs_type;	/* Descriptor type. */
 	int	fs_flags;	/* filestat specific flags. */
 	int	fs_fflags;	/* Descriptor access flags. */
 	int	fs_uflags;	/* How this file is used. */
 	int	fs_fd;		/* File descriptor number. */
 	int	fs_ref_count;	/* Reference count. */
 	off_t	fs_offset;	/* Seek location. */
 	void	*fs_typedep;	/* Type dependent data. */
 	char	*fs_path;
 	STAILQ_ENTRY(filestat)	next;
 	cap_rights_t	fs_cap_rights;	/* Capability rights, if flag set. */
 };
 struct vnstat {
 	uint64_t	vn_fileid;
 	uint64_t	vn_size;
 	char		*vn_mntdir;
 	uint32_t	vn_dev;
 	uint32_t	vn_fsid;
 	int		vn_type;
 	uint16_t	vn_mode;
 	char		vn_devname[SPECNAMELEN + 1];
 };
 struct ptsstat {
 	uint32_t	dev;
 	char		devname[SPECNAMELEN + 1];
 };
 struct pipestat {
 	size_t		buffer_cnt;
 	uint64_t	addr;
 	uint64_t	peer;
 };
 struct shmstat {
 	uint64_t	size;
 	uint16_t	mode;
 };
 struct sockstat {
 	uint64_t	inp_ppcb;
 	uint64_t	so_addr;
 	uint64_t	so_pcb;
 	uint64_t	unp_conn;
 	int		dom_family;
 	int		proto;
 	int		so_rcv_sb_state;
 	int		so_snd_sb_state;
 	struct sockaddr_storage	sa_local;	/* Socket address. */
 	struct sockaddr_storage	sa_peer;	/* Peer address. */
 	int		type;
 	char		dname[32];
 };
 
 STAILQ_HEAD(filestat_list, filestat);
 
 __BEGIN_DECLS
 void	procstat_close(struct procstat *procstat);
+void	procstat_freeargv(struct procstat *procstat);
+#ifndef ZFS
+void	procstat_freeauxv(struct procstat *procstat, Elf_Auxinfo *auxv);
+#endif
+void	procstat_freeenvv(struct procstat *procstat);
+void	procstat_freegroups(struct procstat *procstat, gid_t *groups);
+void	procstat_freekstack(struct procstat *procstat,
+    struct kinfo_kstack *kkstp);
 void	procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
 void	procstat_freefiles(struct procstat *procstat,
     struct filestat_list *head);
+void	procstat_freevmmap(struct procstat *procstat,
+    struct kinfo_vmentry *vmmap);
 struct filestat_list	*procstat_getfiles(struct procstat *procstat,
     struct kinfo_proc *kp, int mmapped);
 struct kinfo_proc	*procstat_getprocs(struct procstat *procstat,
     int what, int arg, unsigned int *count);
 int	procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
     struct pipestat *pipe, char *errbuf);
 int	procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
     struct ptsstat *pts, char *errbuf);
 int	procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
     struct shmstat *shm, char *errbuf);
 int	procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
     struct sockstat *sock, char *errbuf);
 int	procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
     struct vnstat *vn, char *errbuf);
+char	**procstat_getargv(struct procstat *procstat, struct kinfo_proc *p,
+    size_t nchr);
+#ifndef ZFS
+Elf_Auxinfo	*procstat_getauxv(struct procstat *procstat,
+    struct kinfo_proc *kp, unsigned int *cntp);
+#endif
+char	**procstat_getenvv(struct procstat *procstat, struct kinfo_proc *p,
+    size_t nchr);
+gid_t	*procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned int *count);
+struct kinfo_kstack	*procstat_getkstack(struct procstat *procstat,
+    struct kinfo_proc *kp, unsigned int *count);
+int	procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp,
+    int *osrelp);
+int	procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
+    char *pathname, size_t maxlen);
+int	procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp,
+    int which, struct rlimit* rlimit);
+int	procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
+    unsigned short* umask);
+struct kinfo_vmentry	*procstat_getvmmap(struct procstat *procstat,
+    struct kinfo_proc *kp, unsigned int *count);
+struct procstat	*procstat_open_core(const char *filename);
 struct procstat	*procstat_open_sysctl(void);
 struct procstat	*procstat_open_kvm(const char *nlistf, const char *memf);
 __END_DECLS
 
 #endif	/* !_LIBPROCSTAT_H_ */
Index: user/attilio/vmcontention/lib/libprocstat/libprocstat_internal.h
===================================================================
--- user/attilio/vmcontention/lib/libprocstat/libprocstat_internal.h	(revision 249698)
+++ user/attilio/vmcontention/lib/libprocstat/libprocstat_internal.h	(revision 249699)
@@ -1,39 +1,42 @@
 /*-
  * Copyright (c) 2009 Stanislav Sedov 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #ifndef _LIBPROCSTAT_INTERNAL_H_
 #define	_LIBPROCSTAT_INTERNAL_H_
 
 struct procstat {
 	int	type;
 	kvm_t	*kd;
 	void	*vmentries;
 	void	*files;
+	void	*argv;
+	void	*envv;
+	struct procstat_core *core;
 };
 
 #endif	/* !_LIBPROCSTAT_INTERNAL_H_ */
Index: user/attilio/vmcontention/sbin/gbde/Makefile
===================================================================
--- user/attilio/vmcontention/sbin/gbde/Makefile	(revision 249698)
+++ user/attilio/vmcontention/sbin/gbde/Makefile	(revision 249699)
@@ -1,32 +1,33 @@
 # $FreeBSD$
 
 PROG=	gbde
 SRCS=	gbde.c template.c
 SRCS+=	rijndael-alg-fst.c
 SRCS+=	rijndael-api-fst.c
 SRCS+=	sha2.c
 SRCS+=	g_bde_lock.c
 
 # rijndael-fst.c does evil casting things which can results in warnings,
 # the test-vectors check out however, so it works right.
 NO_WCAST_ALIGN=
+NO_WMISSING_VARIABLE_DECLARATIONS=
 
 CFLAGS+= -I${.CURDIR}/../../sys
 .PATH:	${.CURDIR}/../../sys/geom/bde \
 	${.CURDIR}/../../sys/crypto/rijndael \
 	${.CURDIR}/../../sys/crypto/sha2
 
 CLEANFILES+= template.c
 
 MAN=	gbde.8
 DPADD=	${LIBMD} ${LIBUTIL} ${LIBGEOM}
 LDADD=	-lmd -lutil -lgeom
 
 template.c: template.txt
 	file2c 'const char template[] = {' ',0};' \
 		< ${.CURDIR}/template.txt > template.c
 
 test: ${PROG}
 	sh ${.CURDIR}/test.sh ${.CURDIR}
 
 .include 
Index: user/attilio/vmcontention/sbin/geom/class/Makefile.inc
===================================================================
--- user/attilio/vmcontention/sbin/geom/class/Makefile.inc	(revision 249698)
+++ user/attilio/vmcontention/sbin/geom/class/Makefile.inc	(revision 249699)
@@ -1,11 +1,13 @@
 # $FreeBSD$
 
 SHLIBDIR?=${GEOM_CLASS_DIR}
 SHLIB_NAME?=geom_${GEOM_CLASS}.so
 LINKS=	${BINDIR}/geom ${BINDIR}/g${GEOM_CLASS}
 MAN=	g${GEOM_CLASS}.8
 SRCS+=	geom_${GEOM_CLASS}.c subr.c
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 CFLAGS+= -I${.CURDIR}/../..
 
 .include "../Makefile.inc"
Index: user/attilio/vmcontention/sbin/hastctl/Makefile
===================================================================
--- user/attilio/vmcontention/sbin/hastctl/Makefile	(revision 249698)
+++ user/attilio/vmcontention/sbin/hastctl/Makefile	(revision 249699)
@@ -1,46 +1,47 @@
 # $FreeBSD$
 
 .include 
 
 .PATH:	${.CURDIR}/../hastd
 
 PROG=	hastctl
 SRCS=	activemap.c
 SRCS+=	crc32.c
 SRCS+=	ebuf.c
 SRCS+=	hast_checksum.c hast_compression.c hast_proto.c hastctl.c
 SRCS+=	lzf.c
 SRCS+=	metadata.c
 SRCS+=	nv.c
 SRCS+=	parse.y pjdlog.c
 SRCS+=	proto.c proto_common.c proto_uds.c
 SRCS+=	token.l
 SRCS+=	subr.c
 SRCS+=	y.tab.h
 MAN=	hastctl.8
 
 NO_WFORMAT=
 NO_WCAST_ALIGN=
+NO_WMISSING_VARIABLE_DECLARATIONS=
 CFLAGS+=-I${.CURDIR}/../hastd
 CFLAGS+=-DHAVE_CAPSICUM
 CFLAGS+=-DINET
 .if ${MK_INET6_SUPPORT} != "no"
 CFLAGS+=-DINET6
 .endif
 # This is needed to have WARNS > 1.
 CFLAGS+=-DYY_NO_UNPUT
 CFLAGS+=-DYY_NO_INPUT
 
 DPADD=	${LIBL} ${LIBUTIL}
 LDADD=	-ll -lutil
 .if ${MK_OPENSSL} != "no"
 DPADD+=	${LIBCRYPTO}
 LDADD+=	-lcrypto
 CFLAGS+=-DHAVE_CRYPTO
 .endif
 
 YFLAGS+=-v
 
 CLEANFILES=y.tab.c y.tab.h y.output
 
 .include 
Index: user/attilio/vmcontention/sbin/hastd/Makefile
===================================================================
--- user/attilio/vmcontention/sbin/hastd/Makefile	(revision 249698)
+++ user/attilio/vmcontention/sbin/hastd/Makefile	(revision 249699)
@@ -1,44 +1,45 @@
 # $FreeBSD$
 
 .include 
 
 PROG=	hastd
 SRCS=	activemap.c
 SRCS+=	control.c crc32.c
 SRCS+=	ebuf.c event.c
 SRCS+=	hast_checksum.c hast_compression.c hast_proto.c hastd.c hooks.c
 SRCS+=	lzf.c
 SRCS+=	metadata.c
 SRCS+=	nv.c
 SRCS+=	secondary.c
 SRCS+=	parse.y pjdlog.c primary.c
 SRCS+=	proto.c proto_common.c proto_socketpair.c proto_tcp.c proto_uds.c
 SRCS+=	rangelock.c
 SRCS+=	subr.c
 SRCS+=	token.l
 SRCS+=	y.tab.h
 MAN=	hastd.8 hast.conf.5
 
 NO_WFORMAT=
 NO_WCAST_ALIGN=
+NO_WMISSING_VARIABLE_DECLARATIONS=
 CFLAGS+=-I${.CURDIR}
 CFLAGS+=-DHAVE_CAPSICUM
 CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457
 CFLAGS+=-DINET
 .if ${MK_INET6_SUPPORT} != "no"
 CFLAGS+=-DINET6
 .endif
 
 DPADD=	${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} ${LIBL} ${LIBPTHREAD} ${LIBUTIL}
 LDADD=	-lgeom -lbsdxml -lsbuf -ll -lpthread -lutil
 .if ${MK_OPENSSL} != "no"
 DPADD+=	${LIBCRYPTO}
 LDADD+=	-lcrypto
 CFLAGS+=-DHAVE_CRYPTO
 .endif
 
 YFLAGS+=-v
 
 CLEANFILES=y.tab.c y.tab.h y.output
 
 .include 
Index: user/attilio/vmcontention/sbin/md5/Makefile
===================================================================
--- user/attilio/vmcontention/sbin/md5/Makefile	(revision 249698)
+++ user/attilio/vmcontention/sbin/md5/Makefile	(revision 249699)
@@ -1,21 +1,22 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/9/93
 # $FreeBSD$
 
 PROG=	md5
 
 LINKS=	${BINDIR}/md5 ${BINDIR}/rmd160 \
 	${BINDIR}/md5 ${BINDIR}/sha1 \
 	${BINDIR}/md5 ${BINDIR}/sha256 \
 	${BINDIR}/md5 ${BINDIR}/sha512
 
 MLINKS=	md5.1 rmd160.1 \
 	md5.1 sha1.1 \
 	md5.1 sha256.1 \
 	md5.1 sha512.1
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
 WFORMAT?=	1
 
 DPADD=	${LIBMD}
 LDADD=	-lmd
 
 .include 
Index: user/attilio/vmcontention/sbin
===================================================================
--- user/attilio/vmcontention/sbin	(revision 249698)
+++ user/attilio/vmcontention/sbin	(revision 249699)

Property changes on: user/attilio/vmcontention/sbin
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head/sbin:r249527-249698
Index: user/attilio/vmcontention/share/man/man9/DELAY.9
===================================================================
--- user/attilio/vmcontention/share/man/man9/DELAY.9	(revision 249698)
+++ user/attilio/vmcontention/share/man/man9/DELAY.9	(revision 249699)
@@ -1,47 +1,49 @@
 .\"
 .\" Copyright (c) 2000 Alfred Perlstein
 .\"
 .\" All rights reserved.
 .\"
 .\" This program is free software.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
 .\" 1. Redistributions of source code must retain the above copyright
 .\"    notice, this list of conditions and the following disclaimer.
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\"
 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 21, 2000
+.Dd April 20, 2013
 .Dt DELAY 9
 .Os
 .Sh NAME
 .Nm DELAY
 .Nd busy loop for an interval
 .Sh SYNOPSIS
 .In sys/types.h
 .In sys/systm.h
 .Ft void
 .Fn DELAY "int delay"
 .Sh DESCRIPTION
 Delay for
 .Fa delay
 microseconds (1/1000000th of a second).
+.Sh SEE ALSO
+.Xr pause 9
 .Sh AUTHORS
 This manual page was written by
 .An Alfred Perlstein .
Index: user/attilio/vmcontention/share/mk/bsd.sys.mk
===================================================================
--- user/attilio/vmcontention/share/mk/bsd.sys.mk	(revision 249698)
+++ user/attilio/vmcontention/share/mk/bsd.sys.mk	(revision 249699)
@@ -1,143 +1,147 @@
 # $FreeBSD$
 #
 # This file contains common settings used for building FreeBSD
 # sources.
 
 # Enable various levels of compiler warning checks.  These may be
 # overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
 
 # for GCC:   http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Warning-Options.html
 
 .include 
 
 # the default is gnu99 for now
 CSTD?=		gnu99
 
 .if ${CSTD} == "k&r"
 CFLAGS+=	-traditional
 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
 CFLAGS+=	-std=iso9899:1990
 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
 CFLAGS+=	-std=iso9899:199409
 .elif ${CSTD} == "c99"
 CFLAGS+=	-std=iso9899:1999
 .else # CSTD
 CFLAGS+=	-std=${CSTD}
 .endif # CSTD
 .if !defined(NO_WARNS)
 # -pedantic is problematic because it also imposes namespace restrictions
 #CFLAGS+=	-pedantic
 .if defined(WARNS)
 .if ${WARNS} >= 1
 CWARNFLAGS+=	-Wsystem-headers
 .if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
     || !defined(NO_WERROR.clang))
 CWARNFLAGS+=	-Werror
 .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
 .endif # WARNS >= 1
 .if ${WARNS} >= 2
 CWARNFLAGS+=	-Wall -Wno-format-y2k
 .endif # WARNS >= 2
 .if ${WARNS} >= 3
 CWARNFLAGS+=	-W -Wno-unused-parameter -Wstrict-prototypes\
 		-Wmissing-prototypes -Wpointer-arith
 .endif # WARNS >= 3
 .if ${WARNS} >= 4
 CWARNFLAGS+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
 		-Wunused-parameter
 .if !defined(NO_WCAST_ALIGN) && (${COMPILER_TYPE} != "clang" \
     || !defined(NO_WCAST_ALIGN.clang))
 CWARNFLAGS+=	-Wcast-align
 .endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang)
 .endif # WARNS >= 4
 # BDECFLAGS
 .if ${WARNS} >= 6
 CWARNFLAGS+=	-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\
 		-Wold-style-definition
+.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) && \
+    !defined(NO_WMISSING_VARIABLE_DECLARATIONS)
+CWARNFLAGS+=	-Wmissing-variable-declarations
+.endif
 .endif # WARNS >= 6
 .if ${WARNS} >= 2 && ${WARNS} <= 4
 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
 # XXX always get it right.
 CWARNFLAGS+=	-Wno-uninitialized
 .endif # WARNS >=2 && WARNS <= 4
 CWARNFLAGS+=	-Wno-pointer-sign
 # Clang has more warnings enabled by default, and when using -Wall, so if WARNS
 # is set to low values, these have to be disabled explicitly.
 .if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD)
 .if ${WARNS} <= 6
 CWARNFLAGS+=	-Wno-empty-body -Wno-string-plus-int
 .endif # WARNS <= 6
 .if ${WARNS} <= 3
 CWARNFLAGS+=	-Wno-tautological-compare -Wno-unused-value\
 		-Wno-parentheses-equality -Wno-unused-function -Wno-conversion
 .endif # WARNS <= 3
 .if ${WARNS} <= 2
 CWARNFLAGS+=	-Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter
 .endif # WARNS <= 2
 .if ${WARNS} <= 1
 CWARNFLAGS+=	-Wno-parentheses
 .endif # WARNS <= 1
 .if defined(NO_WARRAY_BOUNDS)
 CWARNFLAGS+=	-Wno-array-bounds
 .endif # NO_WARRAY_BOUNDS
 .endif # CLANG
 .endif # WARNS
 
 .if defined(FORMAT_AUDIT)
 WFORMAT=	1
 .endif # FORMAT_AUDIT
 .if defined(WFORMAT)
 .if ${WFORMAT} > 0
 #CWARNFLAGS+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
 CWARNFLAGS+=	-Wformat=2 -Wno-format-extra-args
 .if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD)
 .if ${WARNS} <= 3
 CWARNFLAGS+=	-Wno-format-nonliteral
 .endif # WARNS <= 3
 .endif # CLANG
 .if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \
     || !defined(NO_WERROR.clang))
 CWARNFLAGS+=	-Werror
 .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
 .endif # WFORMAT > 0
 .endif # WFORMAT
 .if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang))
 CWARNFLAGS+=	-Wno-format
 .endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang)
 .endif # !NO_WARNS
 
 .if defined(IGNORE_PRAGMA)
 CWARNFLAGS+=	-Wno-unknown-pragmas
 .endif # IGNORE_PRAGMA
 
 .if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD)
 CLANG_NO_IAS=	 -no-integrated-as
 CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
 		 -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret
 CFLAGS+=	 -Qunused-arguments
 .endif # CLANG
 
 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
 # Don't use -Wstack-protector as it breaks world with -Werror.
 SSP_CFLAGS?=	-fstack-protector
 CFLAGS+=	${SSP_CFLAGS}
 .endif # SSP && !IA64 && !ARM && !MIPS
 
 # Allow user-specified additional warning flags
 CFLAGS+=	${CWARNFLAGS}
 
 
 # Tell bmake not to mistake standard targets for things to be searched for
 # or expect to ever be up-to-date.
 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
 		beforelinking build build-tools buildfiles buildincludes \
 		checkdpadd clean cleandepend cleandir cleanobj configure \
 		depend dependall distclean distribute exe extract fetch \
 		html includes install installfiles installincludes lint \
 		obj objlink objs objwarn patch realall realdepend \
 		realinstall regress subdir-all subdir-depend subdir-install \
 		tags whereobj
 
 .PHONY: ${PHONY_NOTMAIN}
 .NOTMAIN: ${PHONY_NOTMAIN}
Index: user/attilio/vmcontention/sys/cam/cam_xpt.c
===================================================================
--- user/attilio/vmcontention/sys/cam/cam_xpt.c	(revision 249698)
+++ user/attilio/vmcontention/sys/cam/cam_xpt.c	(revision 249699)
@@ -1,4970 +1,4977 @@
 /*-
  * Implementation of the Common Access Method Transport (XPT) layer.
  *
  * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
  * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification, immediately at the beginning of the file.
  * 2. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 
 #include 	/* geometry translation */
 #include 	/* for xpt_print below */
 
 #include "opt_cam.h"
 
 /*
  * This is the maximum number of high powered commands (e.g. start unit)
  * that can be outstanding at a particular time.
  */
 #ifndef CAM_MAX_HIGHPOWER
 #define CAM_MAX_HIGHPOWER  4
 #endif
 
 /* Datastructures internal to the xpt layer */
 MALLOC_DEFINE(M_CAMXPT, "CAM XPT", "CAM XPT buffers");
 MALLOC_DEFINE(M_CAMDEV, "CAM DEV", "CAM devices");
 MALLOC_DEFINE(M_CAMCCB, "CAM CCB", "CAM CCBs");
 MALLOC_DEFINE(M_CAMPATH, "CAM path", "CAM paths");
 
 /* Object for defering XPT actions to a taskqueue */
 struct xpt_task {
 	struct task	task;
 	void		*data1;
 	uintptr_t	data2;
 };
 
 typedef enum {
 	XPT_FLAG_OPEN		= 0x01
 } xpt_flags;
 
 struct xpt_softc {
 	xpt_flags		flags;
 	u_int32_t		xpt_generation;
 
 	/* number of high powered commands that can go through right now */
 	STAILQ_HEAD(highpowerlist, ccb_hdr)	highpowerq;
 	int			num_highpower;
 
 	/* queue for handling async rescan requests. */
 	TAILQ_HEAD(, ccb_hdr) ccb_scanq;
 	int buses_to_config;
 	int buses_config_done;
 
 	/* Registered busses */
 	TAILQ_HEAD(,cam_eb)	xpt_busses;
 	u_int			bus_generation;
 
 	struct intr_config_hook	*xpt_config_hook;
 
 	int			boot_delay;
 	struct callout 		boot_callout;
 
 	struct mtx		xpt_topo_lock;
 	struct mtx		xpt_lock;
 };
 
 typedef enum {
 	DM_RET_COPY		= 0x01,
 	DM_RET_FLAG_MASK	= 0x0f,
 	DM_RET_NONE		= 0x00,
 	DM_RET_STOP		= 0x10,
 	DM_RET_DESCEND		= 0x20,
 	DM_RET_ERROR		= 0x30,
 	DM_RET_ACTION_MASK	= 0xf0
 } dev_match_ret;
 
 typedef enum {
 	XPT_DEPTH_BUS,
 	XPT_DEPTH_TARGET,
 	XPT_DEPTH_DEVICE,
 	XPT_DEPTH_PERIPH
 } xpt_traverse_depth;
 
 struct xpt_traverse_config {
 	xpt_traverse_depth	depth;
 	void			*tr_func;
 	void			*tr_arg;
 };
 
 typedef	int	xpt_busfunc_t (struct cam_eb *bus, void *arg);
 typedef	int	xpt_targetfunc_t (struct cam_et *target, void *arg);
 typedef	int	xpt_devicefunc_t (struct cam_ed *device, void *arg);
 typedef	int	xpt_periphfunc_t (struct cam_periph *periph, void *arg);
 typedef int	xpt_pdrvfunc_t (struct periph_driver **pdrv, void *arg);
 
 /* Transport layer configuration information */
 static struct xpt_softc xsoftc;
 
 TUNABLE_INT("kern.cam.boot_delay", &xsoftc.boot_delay);
 SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN,
            &xsoftc.boot_delay, 0, "Bus registration wait time");
 
 /* Queues for our software interrupt handler */
 typedef TAILQ_HEAD(cam_isrq, ccb_hdr) cam_isrq_t;
 typedef TAILQ_HEAD(cam_simq, cam_sim) cam_simq_t;
 static cam_simq_t cam_simq;
 static struct mtx cam_simq_lock;
 
 /* Pointers to software interrupt handlers */
 static void *cambio_ih;
 
 struct cam_periph *xpt_periph;
 
 static periph_init_t xpt_periph_init;
 
 static struct periph_driver xpt_driver =
 {
 	xpt_periph_init, "xpt",
 	TAILQ_HEAD_INITIALIZER(xpt_driver.units), /* generation */ 0,
 	CAM_PERIPH_DRV_EARLY
 };
 
 PERIPHDRIVER_DECLARE(xpt, xpt_driver);
 
 static d_open_t xptopen;
 static d_close_t xptclose;
 static d_ioctl_t xptioctl;
 
 static struct cdevsw xpt_cdevsw = {
 	.d_version =	D_VERSION,
 	.d_flags =	0,
 	.d_open =	xptopen,
 	.d_close =	xptclose,
 	.d_ioctl =	xptioctl,
 	.d_name =	"xpt",
 };
 
 /* Storage for debugging datastructures */
 struct cam_path *cam_dpath;
 u_int32_t cam_dflags = CAM_DEBUG_FLAGS;
 TUNABLE_INT("kern.cam.dflags", &cam_dflags);
 SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW,
 	&cam_dflags, 0, "Enabled debug flags");
 u_int32_t cam_debug_delay = CAM_DEBUG_DELAY;
 TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay);
 SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW,
 	&cam_debug_delay, 0, "Delay in us after each debug message");
 
 /* Our boot-time initialization hook */
 static int cam_module_event_handler(module_t, int /*modeventtype_t*/, void *);
 
 static moduledata_t cam_moduledata = {
 	"cam",
 	cam_module_event_handler,
 	NULL
 };
 
 static int	xpt_init(void *);
 
 DECLARE_MODULE(cam, cam_moduledata, SI_SUB_CONFIGURE, SI_ORDER_SECOND);
 MODULE_VERSION(cam, 1);
 
 
 static void		xpt_async_bcast(struct async_list *async_head,
 					u_int32_t async_code,
 					struct cam_path *path,
 					void *async_arg);
 static path_id_t xptnextfreepathid(void);
 static path_id_t xptpathid(const char *sim_name, int sim_unit, int sim_bus);
 static union ccb *xpt_get_ccb(struct cam_ed *device);
 static void	 xpt_run_dev_allocq(struct cam_ed *device);
 static void	 xpt_run_devq(struct cam_devq *devq);
 static timeout_t xpt_release_devq_timeout;
 static void	 xpt_release_simq_timeout(void *arg) __unused;
 static void	 xpt_release_bus(struct cam_eb *bus);
 static void	 xpt_release_devq_device(struct cam_ed *dev, u_int count,
 		    int run_queue);
 static struct cam_et*
 		 xpt_alloc_target(struct cam_eb *bus, target_id_t target_id);
 static void	 xpt_release_target(struct cam_et *target);
 static struct cam_eb*
 		 xpt_find_bus(path_id_t path_id);
 static struct cam_et*
 		 xpt_find_target(struct cam_eb *bus, target_id_t target_id);
 static struct cam_ed*
 		 xpt_find_device(struct cam_et *target, lun_id_t lun_id);
 static void	 xpt_config(void *arg);
 static xpt_devicefunc_t xptpassannouncefunc;
 static void	 xptaction(struct cam_sim *sim, union ccb *work_ccb);
 static void	 xptpoll(struct cam_sim *sim);
 static void	 camisr(void *);
 static void	 camisr_runqueue(void *);
 static dev_match_ret	xptbusmatch(struct dev_match_pattern *patterns,
 				    u_int num_patterns, struct cam_eb *bus);
 static dev_match_ret	xptdevicematch(struct dev_match_pattern *patterns,
 				       u_int num_patterns,
 				       struct cam_ed *device);
 static dev_match_ret	xptperiphmatch(struct dev_match_pattern *patterns,
 				       u_int num_patterns,
 				       struct cam_periph *periph);
 static xpt_busfunc_t	xptedtbusfunc;
 static xpt_targetfunc_t	xptedttargetfunc;
 static xpt_devicefunc_t	xptedtdevicefunc;
 static xpt_periphfunc_t	xptedtperiphfunc;
 static xpt_pdrvfunc_t	xptplistpdrvfunc;
 static xpt_periphfunc_t	xptplistperiphfunc;
 static int		xptedtmatch(struct ccb_dev_match *cdm);
 static int		xptperiphlistmatch(struct ccb_dev_match *cdm);
 static int		xptbustraverse(struct cam_eb *start_bus,
 				       xpt_busfunc_t *tr_func, void *arg);
 static int		xpttargettraverse(struct cam_eb *bus,
 					  struct cam_et *start_target,
 					  xpt_targetfunc_t *tr_func, void *arg);
 static int		xptdevicetraverse(struct cam_et *target,
 					  struct cam_ed *start_device,
 					  xpt_devicefunc_t *tr_func, void *arg);
 static int		xptperiphtraverse(struct cam_ed *device,
 					  struct cam_periph *start_periph,
 					  xpt_periphfunc_t *tr_func, void *arg);
 static int		xptpdrvtraverse(struct periph_driver **start_pdrv,
 					xpt_pdrvfunc_t *tr_func, void *arg);
 static int		xptpdperiphtraverse(struct periph_driver **pdrv,
 					    struct cam_periph *start_periph,
 					    xpt_periphfunc_t *tr_func,
 					    void *arg);
 static xpt_busfunc_t	xptdefbusfunc;
 static xpt_targetfunc_t	xptdeftargetfunc;
 static xpt_devicefunc_t	xptdefdevicefunc;
 static xpt_periphfunc_t	xptdefperiphfunc;
 static void		xpt_finishconfig_task(void *context, int pending);
 static void		xpt_dev_async_default(u_int32_t async_code,
 					      struct cam_eb *bus,
 					      struct cam_et *target,
 					      struct cam_ed *device,
 					      void *async_arg);
 static struct cam_ed *	xpt_alloc_device_default(struct cam_eb *bus,
 						 struct cam_et *target,
 						 lun_id_t lun_id);
 static xpt_devicefunc_t	xptsetasyncfunc;
 static xpt_busfunc_t	xptsetasyncbusfunc;
 static cam_status	xptregister(struct cam_periph *periph,
 				    void *arg);
 static __inline int periph_is_queued(struct cam_periph *periph);
 static __inline int device_is_queued(struct cam_ed *device);
 
 static __inline int
 xpt_schedule_devq(struct cam_devq *devq, struct cam_ed *dev)
 {
 	int	retval;
 
 	if ((dev->ccbq.queue.entries > 0) &&
 	    (dev->ccbq.dev_openings > 0) &&
 	    (dev->ccbq.queue.qfrozen_cnt == 0)) {
 		/*
 		 * The priority of a device waiting for controller
 		 * resources is that of the highest priority CCB
 		 * enqueued.
 		 */
 		retval =
 		    xpt_schedule_dev(&devq->send_queue,
 				     &dev->devq_entry.pinfo,
 				     CAMQ_GET_PRIO(&dev->ccbq.queue));
 	} else {
 		retval = 0;
 	}
 	return (retval);
 }
 
 static __inline int
 periph_is_queued(struct cam_periph *periph)
 {
 	return (periph->pinfo.index != CAM_UNQUEUED_INDEX);
 }
 
 static __inline int
 device_is_queued(struct cam_ed *device)
 {
 	return (device->devq_entry.pinfo.index != CAM_UNQUEUED_INDEX);
 }
 
 static void
 xpt_periph_init()
 {
 	make_dev(&xpt_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600, "xpt0");
 }
 
 static void
 xptdone(struct cam_periph *periph, union ccb *done_ccb)
 {
 	/* Caller will release the CCB */
 	wakeup(&done_ccb->ccb_h.cbfcnp);
 }
 
 static int
 xptopen(struct cdev *dev, int flags, int fmt, struct thread *td)
 {
 
 	/*
 	 * Only allow read-write access.
 	 */
 	if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0))
 		return(EPERM);
 
 	/*
 	 * We don't allow nonblocking access.
 	 */
 	if ((flags & O_NONBLOCK) != 0) {
 		printf("%s: can't do nonblocking access\n", devtoname(dev));
 		return(ENODEV);
 	}
 
 	/* Mark ourselves open */
 	mtx_lock(&xsoftc.xpt_lock);
 	xsoftc.flags |= XPT_FLAG_OPEN;
 	mtx_unlock(&xsoftc.xpt_lock);
 
 	return(0);
 }
 
 static int
 xptclose(struct cdev *dev, int flag, int fmt, struct thread *td)
 {
 
 	/* Mark ourselves closed */
 	mtx_lock(&xsoftc.xpt_lock);
 	xsoftc.flags &= ~XPT_FLAG_OPEN;
 	mtx_unlock(&xsoftc.xpt_lock);
 
 	return(0);
 }
 
 /*
  * Don't automatically grab the xpt softc lock here even though this is going
  * through the xpt device.  The xpt device is really just a back door for
  * accessing other devices and SIMs, so the right thing to do is to grab
  * the appropriate SIM lock once the bus/SIM is located.
  */
 static int
 xptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 {
 	int error;
 
 	error = 0;
 
 	switch(cmd) {
 	/*
 	 * For the transport layer CAMIOCOMMAND ioctl, we really only want
 	 * to accept CCB types that don't quite make sense to send through a
 	 * passthrough driver. XPT_PATH_INQ is an exception to this, as stated
 	 * in the CAM spec.
 	 */
 	case CAMIOCOMMAND: {
 		union ccb *ccb;
 		union ccb *inccb;
 		struct cam_eb *bus;
 
 		inccb = (union ccb *)addr;
 
 		bus = xpt_find_bus(inccb->ccb_h.path_id);
 		if (bus == NULL)
 			return (EINVAL);
 
 		switch (inccb->ccb_h.func_code) {
 		case XPT_SCAN_BUS:
 		case XPT_RESET_BUS:
 			if (inccb->ccb_h.target_id != CAM_TARGET_WILDCARD ||
 			    inccb->ccb_h.target_lun != CAM_LUN_WILDCARD) {
 				xpt_release_bus(bus);
 				return (EINVAL);
 			}
 			break;
 		case XPT_SCAN_TGT:
 			if (inccb->ccb_h.target_id == CAM_TARGET_WILDCARD ||
 			    inccb->ccb_h.target_lun != CAM_LUN_WILDCARD) {
 				xpt_release_bus(bus);
 				return (EINVAL);
 			}
 			break;
 		default:
 			break;
 		}
 
 		switch(inccb->ccb_h.func_code) {
 		case XPT_SCAN_BUS:
 		case XPT_RESET_BUS:
 		case XPT_PATH_INQ:
 		case XPT_ENG_INQ:
 		case XPT_SCAN_LUN:
 		case XPT_SCAN_TGT:
 
 			ccb = xpt_alloc_ccb();
 
 			CAM_SIM_LOCK(bus->sim);
 
 			/*
 			 * Create a path using the bus, target, and lun the
 			 * user passed in.
 			 */
 			if (xpt_create_path(&ccb->ccb_h.path, NULL,
 					    inccb->ccb_h.path_id,
 					    inccb->ccb_h.target_id,
 					    inccb->ccb_h.target_lun) !=
 					    CAM_REQ_CMP){
 				error = EINVAL;
 				CAM_SIM_UNLOCK(bus->sim);
 				xpt_free_ccb(ccb);
 				break;
 			}
 			/* Ensure all of our fields are correct */
 			xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path,
 				      inccb->ccb_h.pinfo.priority);
 			xpt_merge_ccb(ccb, inccb);
 			ccb->ccb_h.cbfcnp = xptdone;
 			cam_periph_runccb(ccb, NULL, 0, 0, NULL);
 			bcopy(ccb, inccb, sizeof(union ccb));
 			xpt_free_path(ccb->ccb_h.path);
 			xpt_free_ccb(ccb);
 			CAM_SIM_UNLOCK(bus->sim);
 			break;
 
 		case XPT_DEBUG: {
 			union ccb ccb;
 
 			/*
 			 * This is an immediate CCB, so it's okay to
 			 * allocate it on the stack.
 			 */
 
 			CAM_SIM_LOCK(bus->sim);
 
 			/*
 			 * Create a path using the bus, target, and lun the
 			 * user passed in.
 			 */
 			if (xpt_create_path(&ccb.ccb_h.path, NULL,
 					    inccb->ccb_h.path_id,
 					    inccb->ccb_h.target_id,
 					    inccb->ccb_h.target_lun) !=
 					    CAM_REQ_CMP){
 				error = EINVAL;
 				CAM_SIM_UNLOCK(bus->sim);
 				break;
 			}
 			/* Ensure all of our fields are correct */
 			xpt_setup_ccb(&ccb.ccb_h, ccb.ccb_h.path,
 				      inccb->ccb_h.pinfo.priority);
 			xpt_merge_ccb(&ccb, inccb);
 			ccb.ccb_h.cbfcnp = xptdone;
 			xpt_action(&ccb);
 			bcopy(&ccb, inccb, sizeof(union ccb));
 			xpt_free_path(ccb.ccb_h.path);
 			CAM_SIM_UNLOCK(bus->sim);
 			break;
 
 		}
 		case XPT_DEV_MATCH: {
 			struct cam_periph_map_info mapinfo;
 			struct cam_path *old_path;
 
 			/*
 			 * We can't deal with physical addresses for this
 			 * type of transaction.
 			 */
 			if ((inccb->ccb_h.flags & CAM_DATA_MASK) !=
 			    CAM_DATA_VADDR) {
 				error = EINVAL;
 				break;
 			}
 
 			/*
 			 * Save this in case the caller had it set to
 			 * something in particular.
 			 */
 			old_path = inccb->ccb_h.path;
 
 			/*
 			 * We really don't need a path for the matching
 			 * code.  The path is needed because of the
 			 * debugging statements in xpt_action().  They
 			 * assume that the CCB has a valid path.
 			 */
 			inccb->ccb_h.path = xpt_periph->path;
 
 			bzero(&mapinfo, sizeof(mapinfo));
 
 			/*
 			 * Map the pattern and match buffers into kernel
 			 * virtual address space.
 			 */
 			error = cam_periph_mapmem(inccb, &mapinfo);
 
 			if (error) {
 				inccb->ccb_h.path = old_path;
 				break;
 			}
 
 			/*
 			 * This is an immediate CCB, we can send it on directly.
 			 */
 			CAM_SIM_LOCK(xpt_path_sim(xpt_periph->path));
 			xpt_action(inccb);
 			CAM_SIM_UNLOCK(xpt_path_sim(xpt_periph->path));
 
 			/*
 			 * Map the buffers back into user space.
 			 */
 			cam_periph_unmapmem(inccb, &mapinfo);
 
 			inccb->ccb_h.path = old_path;
 
 			error = 0;
 			break;
 		}
 		default:
 			error = ENOTSUP;
 			break;
 		}
 		xpt_release_bus(bus);
 		break;
 	}
 	/*
 	 * This is the getpassthru ioctl. It takes a XPT_GDEVLIST ccb as input,
 	 * with the periphal driver name and unit name filled in.  The other
 	 * fields don't really matter as input.  The passthrough driver name
 	 * ("pass"), and unit number are passed back in the ccb.  The current
 	 * device generation number, and the index into the device peripheral
 	 * driver list, and the status are also passed back.  Note that
 	 * since we do everything in one pass, unlike the XPT_GDEVLIST ccb,
 	 * we never return a status of CAM_GDEVLIST_LIST_CHANGED.  It is
 	 * (or rather should be) impossible for the device peripheral driver
 	 * list to change since we look at the whole thing in one pass, and
 	 * we do it with lock protection.
 	 *
 	 */
 	case CAMGETPASSTHRU: {
 		union ccb *ccb;
 		struct cam_periph *periph;
 		struct periph_driver **p_drv;
 		char   *name;
 		u_int unit;
 		u_int cur_generation;
 		int base_periph_found;
 		int splbreaknum;
 
 		ccb = (union ccb *)addr;
 		unit = ccb->cgdl.unit_number;
 		name = ccb->cgdl.periph_name;
 		/*
 		 * Every 100 devices, we want to drop our lock protection to
 		 * give the software interrupt handler a chance to run.
 		 * Most systems won't run into this check, but this should
 		 * avoid starvation in the software interrupt handler in
 		 * large systems.
 		 */
 		splbreaknum = 100;
 
 		ccb = (union ccb *)addr;
 
 		base_periph_found = 0;
 
 		/*
 		 * Sanity check -- make sure we don't get a null peripheral
 		 * driver name.
 		 */
 		if (*ccb->cgdl.periph_name == '\0') {
 			error = EINVAL;
 			break;
 		}
 
 		/* Keep the list from changing while we traverse it */
 		xpt_lock_buses();
 ptstartover:
 		cur_generation = xsoftc.xpt_generation;
 
 		/* first find our driver in the list of drivers */
 		for (p_drv = periph_drivers; *p_drv != NULL; p_drv++)
 			if (strcmp((*p_drv)->driver_name, name) == 0)
 				break;
 
 		if (*p_drv == NULL) {
 			xpt_unlock_buses();
 			ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 			ccb->cgdl.status = CAM_GDEVLIST_ERROR;
 			*ccb->cgdl.periph_name = '\0';
 			ccb->cgdl.unit_number = 0;
 			error = ENOENT;
 			break;
 		}
 
 		/*
 		 * Run through every peripheral instance of this driver
 		 * and check to see whether it matches the unit passed
 		 * in by the user.  If it does, get out of the loops and
 		 * find the passthrough driver associated with that
 		 * peripheral driver.
 		 */
 		for (periph = TAILQ_FIRST(&(*p_drv)->units); periph != NULL;
 		     periph = TAILQ_NEXT(periph, unit_links)) {
 
 			if (periph->unit_number == unit) {
 				break;
 			} else if (--splbreaknum == 0) {
 				xpt_unlock_buses();
 				xpt_lock_buses();
 				splbreaknum = 100;
 				if (cur_generation != xsoftc.xpt_generation)
 				       goto ptstartover;
 			}
 		}
 		/*
 		 * If we found the peripheral driver that the user passed
 		 * in, go through all of the peripheral drivers for that
 		 * particular device and look for a passthrough driver.
 		 */
 		if (periph != NULL) {
 			struct cam_ed *device;
 			int i;
 
 			base_periph_found = 1;
 			device = periph->path->device;
 			for (i = 0, periph = SLIST_FIRST(&device->periphs);
 			     periph != NULL;
 			     periph = SLIST_NEXT(periph, periph_links), i++) {
 				/*
 				 * Check to see whether we have a
 				 * passthrough device or not.
 				 */
 				if (strcmp(periph->periph_name, "pass") == 0) {
 					/*
 					 * Fill in the getdevlist fields.
 					 */
 					strcpy(ccb->cgdl.periph_name,
 					       periph->periph_name);
 					ccb->cgdl.unit_number =
 						periph->unit_number;
 					if (SLIST_NEXT(periph, periph_links))
 						ccb->cgdl.status =
 							CAM_GDEVLIST_MORE_DEVS;
 					else
 						ccb->cgdl.status =
 						       CAM_GDEVLIST_LAST_DEVICE;
 					ccb->cgdl.generation =
 						device->generation;
 					ccb->cgdl.index = i;
 					/*
 					 * Fill in some CCB header fields
 					 * that the user may want.
 					 */
 					ccb->ccb_h.path_id =
 						periph->path->bus->path_id;
 					ccb->ccb_h.target_id =
 						periph->path->target->target_id;
 					ccb->ccb_h.target_lun =
 						periph->path->device->lun_id;
 					ccb->ccb_h.status = CAM_REQ_CMP;
 					break;
 				}
 			}
 		}
 
 		/*
 		 * If the periph is null here, one of two things has
 		 * happened.  The first possibility is that we couldn't
 		 * find the unit number of the particular peripheral driver
 		 * that the user is asking about.  e.g. the user asks for
 		 * the passthrough driver for "da11".  We find the list of
 		 * "da" peripherals all right, but there is no unit 11.
 		 * The other possibility is that we went through the list
 		 * of peripheral drivers attached to the device structure,
 		 * but didn't find one with the name "pass".  Either way,
 		 * we return ENOENT, since we couldn't find something.
 		 */
 		if (periph == NULL) {
 			ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 			ccb->cgdl.status = CAM_GDEVLIST_ERROR;
 			*ccb->cgdl.periph_name = '\0';
 			ccb->cgdl.unit_number = 0;
 			error = ENOENT;
 			/*
 			 * It is unfortunate that this is even necessary,
 			 * but there are many, many clueless users out there.
 			 * If this is true, the user is looking for the
 			 * passthrough driver, but doesn't have one in his
 			 * kernel.
 			 */
 			if (base_periph_found == 1) {
 				printf("xptioctl: pass driver is not in the "
 				       "kernel\n");
 				printf("xptioctl: put \"device pass\" in "
 				       "your kernel config file\n");
 			}
 		}
 		xpt_unlock_buses();
 		break;
 		}
 	default:
 		error = ENOTTY;
 		break;
 	}
 
 	return(error);
 }
 
 static int
 cam_module_event_handler(module_t mod, int what, void *arg)
 {
 	int error;
 
 	switch (what) {
 	case MOD_LOAD:
 		if ((error = xpt_init(NULL)) != 0)
 			return (error);
 		break;
 	case MOD_UNLOAD:
 		return EBUSY;
 	default:
 		return EOPNOTSUPP;
 	}
 
 	return 0;
 }
 
 static void
 xpt_rescan_done(struct cam_periph *periph, union ccb *done_ccb)
 {
 
 	if (done_ccb->ccb_h.ppriv_ptr1 == NULL) {
 		xpt_free_path(done_ccb->ccb_h.path);
 		xpt_free_ccb(done_ccb);
 	} else {
 		done_ccb->ccb_h.cbfcnp = done_ccb->ccb_h.ppriv_ptr1;
 		(*done_ccb->ccb_h.cbfcnp)(periph, done_ccb);
 	}
 	xpt_release_boot();
 }
 
 /* thread to handle bus rescans */
 static void
 xpt_scanner_thread(void *dummy)
 {
 	union ccb	*ccb;
 	struct cam_sim	*sim;
 
 	xpt_lock_buses();
 	for (;;) {
 		if (TAILQ_EMPTY(&xsoftc.ccb_scanq))
 			msleep(&xsoftc.ccb_scanq, &xsoftc.xpt_topo_lock, PRIBIO,
 			       "ccb_scanq", 0);
 		if ((ccb = (union ccb *)TAILQ_FIRST(&xsoftc.ccb_scanq)) != NULL) {
 			TAILQ_REMOVE(&xsoftc.ccb_scanq, &ccb->ccb_h, sim_links.tqe);
 			xpt_unlock_buses();
 
 			sim = ccb->ccb_h.path->bus->sim;
 			CAM_SIM_LOCK(sim);
 			xpt_action(ccb);
 			CAM_SIM_UNLOCK(sim);
 
 			xpt_lock_buses();
 		}
 	}
 }
 
 void
 xpt_rescan(union ccb *ccb)
 {
 	struct ccb_hdr *hdr;
 
 	/* Prepare request */
 	if (ccb->ccb_h.path->target->target_id == CAM_TARGET_WILDCARD &&
 	    ccb->ccb_h.path->device->lun_id == CAM_LUN_WILDCARD)
 		ccb->ccb_h.func_code = XPT_SCAN_BUS;
 	else if (ccb->ccb_h.path->target->target_id != CAM_TARGET_WILDCARD &&
 	    ccb->ccb_h.path->device->lun_id == CAM_LUN_WILDCARD)
 		ccb->ccb_h.func_code = XPT_SCAN_TGT;
 	else if (ccb->ccb_h.path->target->target_id != CAM_TARGET_WILDCARD &&
 	    ccb->ccb_h.path->device->lun_id != CAM_LUN_WILDCARD)
 		ccb->ccb_h.func_code = XPT_SCAN_LUN;
 	else {
 		xpt_print(ccb->ccb_h.path, "illegal scan path\n");
 		xpt_free_path(ccb->ccb_h.path);
 		xpt_free_ccb(ccb);
 		return;
 	}
 	ccb->ccb_h.ppriv_ptr1 = ccb->ccb_h.cbfcnp;
 	ccb->ccb_h.cbfcnp = xpt_rescan_done;
 	xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, CAM_PRIORITY_XPT);
 	/* Don't make duplicate entries for the same paths. */
 	xpt_lock_buses();
 	if (ccb->ccb_h.ppriv_ptr1 == NULL) {
 		TAILQ_FOREACH(hdr, &xsoftc.ccb_scanq, sim_links.tqe) {
 			if (xpt_path_comp(hdr->path, ccb->ccb_h.path) == 0) {
 				wakeup(&xsoftc.ccb_scanq);
 				xpt_unlock_buses();
 				xpt_print(ccb->ccb_h.path, "rescan already queued\n");
 				xpt_free_path(ccb->ccb_h.path);
 				xpt_free_ccb(ccb);
 				return;
 			}
 		}
 	}
 	TAILQ_INSERT_TAIL(&xsoftc.ccb_scanq, &ccb->ccb_h, sim_links.tqe);
 	xsoftc.buses_to_config++;
 	wakeup(&xsoftc.ccb_scanq);
 	xpt_unlock_buses();
 }
 
 /* Functions accessed by the peripheral drivers */
 static int
 xpt_init(void *dummy)
 {
 	struct cam_sim *xpt_sim;
 	struct cam_path *path;
 	struct cam_devq *devq;
 	cam_status status;
 
 	TAILQ_INIT(&xsoftc.xpt_busses);
 	TAILQ_INIT(&cam_simq);
 	TAILQ_INIT(&xsoftc.ccb_scanq);
 	STAILQ_INIT(&xsoftc.highpowerq);
 	xsoftc.num_highpower = CAM_MAX_HIGHPOWER;
 
 	mtx_init(&cam_simq_lock, "CAM SIMQ lock", NULL, MTX_DEF);
 	mtx_init(&xsoftc.xpt_lock, "XPT lock", NULL, MTX_DEF);
 	mtx_init(&xsoftc.xpt_topo_lock, "XPT topology lock", NULL, MTX_DEF);
 
+#ifdef CAM_BOOT_DELAY
+	/*
+	 * Override this value at compile time to assist our users
+	 * who don't use loader to boot a kernel.
+	 */
+	xsoftc.boot_delay = CAM_BOOT_DELAY;
+#endif
 	/*
 	 * The xpt layer is, itself, the equivelent of a SIM.
 	 * Allow 16 ccbs in the ccb pool for it.  This should
 	 * give decent parallelism when we probe busses and
 	 * perform other XPT functions.
 	 */
 	devq = cam_simq_alloc(16);
 	xpt_sim = cam_sim_alloc(xptaction,
 				xptpoll,
 				"xpt",
 				/*softc*/NULL,
 				/*unit*/0,
 				/*mtx*/&xsoftc.xpt_lock,
 				/*max_dev_transactions*/0,
 				/*max_tagged_dev_transactions*/0,
 				devq);
 	if (xpt_sim == NULL)
 		return (ENOMEM);
 
 	mtx_lock(&xsoftc.xpt_lock);
 	if ((status = xpt_bus_register(xpt_sim, NULL, 0)) != CAM_SUCCESS) {
 		mtx_unlock(&xsoftc.xpt_lock);
 		printf("xpt_init: xpt_bus_register failed with status %#x,"
 		       " failing attach\n", status);
 		return (EINVAL);
 	}
 
 	/*
 	 * Looking at the XPT from the SIM layer, the XPT is
 	 * the equivelent of a peripheral driver.  Allocate
 	 * a peripheral driver entry for us.
 	 */
 	if ((status = xpt_create_path(&path, NULL, CAM_XPT_PATH_ID,
 				      CAM_TARGET_WILDCARD,
 				      CAM_LUN_WILDCARD)) != CAM_REQ_CMP) {
 		mtx_unlock(&xsoftc.xpt_lock);
 		printf("xpt_init: xpt_create_path failed with status %#x,"
 		       " failing attach\n", status);
 		return (EINVAL);
 	}
 
 	cam_periph_alloc(xptregister, NULL, NULL, NULL, "xpt", CAM_PERIPH_BIO,
 			 path, NULL, 0, xpt_sim);
 	xpt_free_path(path);
 	mtx_unlock(&xsoftc.xpt_lock);
 	/* Install our software interrupt handlers */
 	swi_add(NULL, "cambio", camisr, NULL, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih);
 	/*
 	 * Register a callback for when interrupts are enabled.
 	 */
 	xsoftc.xpt_config_hook =
 	    (struct intr_config_hook *)malloc(sizeof(struct intr_config_hook),
 					      M_CAMXPT, M_NOWAIT | M_ZERO);
 	if (xsoftc.xpt_config_hook == NULL) {
 		printf("xpt_init: Cannot malloc config hook "
 		       "- failing attach\n");
 		return (ENOMEM);
 	}
 	xsoftc.xpt_config_hook->ich_func = xpt_config;
 	if (config_intrhook_establish(xsoftc.xpt_config_hook) != 0) {
 		free (xsoftc.xpt_config_hook, M_CAMXPT);
 		printf("xpt_init: config_intrhook_establish failed "
 		       "- failing attach\n");
 	}
 
 	return (0);
 }
 
 static cam_status
 xptregister(struct cam_periph *periph, void *arg)
 {
 	struct cam_sim *xpt_sim;
 
 	if (periph == NULL) {
 		printf("xptregister: periph was NULL!!\n");
 		return(CAM_REQ_CMP_ERR);
 	}
 
 	xpt_sim = (struct cam_sim *)arg;
 	xpt_sim->softc = periph;
 	xpt_periph = periph;
 	periph->softc = NULL;
 
 	return(CAM_REQ_CMP);
 }
 
 int32_t
 xpt_add_periph(struct cam_periph *periph)
 {
 	struct cam_ed *device;
 	int32_t	 status;
 	struct periph_list *periph_head;
 
 	mtx_assert(periph->sim->mtx, MA_OWNED);
 
 	device = periph->path->device;
 
 	periph_head = &device->periphs;
 
 	status = CAM_REQ_CMP;
 
 	if (device != NULL) {
 		/*
 		 * Make room for this peripheral
 		 * so it will fit in the queue
 		 * when it's scheduled to run
 		 */
 		status = camq_resize(&device->drvq,
 				     device->drvq.array_size + 1);
 
 		device->generation++;
 
 		SLIST_INSERT_HEAD(periph_head, periph, periph_links);
 	}
 
 	xpt_lock_buses();
 	xsoftc.xpt_generation++;
 	xpt_unlock_buses();
 
 	return (status);
 }
 
 void
 xpt_remove_periph(struct cam_periph *periph, int topology_lock_held)
 {
 	struct cam_ed *device;
 
 	mtx_assert(periph->sim->mtx, MA_OWNED);
 
 	device = periph->path->device;
 
 	if (device != NULL) {
 		struct periph_list *periph_head;
 
 		periph_head = &device->periphs;
 
 		/* Release the slot for this peripheral */
 		camq_resize(&device->drvq, device->drvq.array_size - 1);
 
 		device->generation++;
 
 		SLIST_REMOVE(periph_head, periph, cam_periph, periph_links);
 	}
 
 	if (topology_lock_held == 0)
 		xpt_lock_buses();
 
 	xsoftc.xpt_generation++;
 
 	if (topology_lock_held == 0)
 		xpt_unlock_buses();
 }
 
 
 void
 xpt_announce_periph(struct cam_periph *periph, char *announce_string)
 {
 	struct	cam_path *path = periph->path;
 
 	mtx_assert(periph->sim->mtx, MA_OWNED);
 
 	printf("%s%d at %s%d bus %d scbus%d target %d lun %d\n",
 	       periph->periph_name, periph->unit_number,
 	       path->bus->sim->sim_name,
 	       path->bus->sim->unit_number,
 	       path->bus->sim->bus_id,
 	       path->bus->path_id,
 	       path->target->target_id,
 	       path->device->lun_id);
 	printf("%s%d: ", periph->periph_name, periph->unit_number);
 	if (path->device->protocol == PROTO_SCSI)
 		scsi_print_inquiry(&path->device->inq_data);
 	else if (path->device->protocol == PROTO_ATA ||
 	    path->device->protocol == PROTO_SATAPM)
 		ata_print_ident(&path->device->ident_data);
 	else if (path->device->protocol == PROTO_SEMB)
 		semb_print_ident(
 		    (struct sep_identify_data *)&path->device->ident_data);
 	else
 		printf("Unknown protocol device\n");
 	if (bootverbose && path->device->serial_num_len > 0) {
 		/* Don't wrap the screen  - print only the first 60 chars */
 		printf("%s%d: Serial Number %.60s\n", periph->periph_name,
 		       periph->unit_number, path->device->serial_num);
 	}
 	/* Announce transport details. */
 	(*(path->bus->xport->announce))(periph);
 	/* Announce command queueing. */
 	if (path->device->inq_flags & SID_CmdQue
 	 || path->device->flags & CAM_DEV_TAG_AFTER_COUNT) {
 		printf("%s%d: Command Queueing enabled\n",
 		       periph->periph_name, periph->unit_number);
 	}
 	/* Announce caller's details if they've passed in. */
 	if (announce_string != NULL)
 		printf("%s%d: %s\n", periph->periph_name,
 		       periph->unit_number, announce_string);
 }
 
 int
 xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
 {
 	int ret = -1;
 	struct ccb_dev_advinfo cdai;
 
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
 
 	memset(&cdai, 0, sizeof(cdai));
 	xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL);
 	cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
 	cdai.bufsiz = len;
 
 	if (!strcmp(attr, "GEOM::ident"))
 		cdai.buftype = CDAI_TYPE_SERIAL_NUM;
 	else if (!strcmp(attr, "GEOM::physpath"))
 		cdai.buftype = CDAI_TYPE_PHYS_PATH;
 	else
 		goto out;
 
 	cdai.buf = malloc(cdai.bufsiz, M_CAMXPT, M_NOWAIT|M_ZERO);
 	if (cdai.buf == NULL) {
 		ret = ENOMEM;
 		goto out;
 	}
 	xpt_action((union ccb *)&cdai); /* can only be synchronous */
 	if ((cdai.ccb_h.status & CAM_DEV_QFRZN) != 0)
 		cam_release_devq(cdai.ccb_h.path, 0, 0, 0, FALSE);
 	if (cdai.provsiz == 0)
 		goto out;
 	ret = 0;
 	if (strlcpy(buf, cdai.buf, len) >= len)
 		ret = EFAULT;
 
 out:
 	if (cdai.buf != NULL)
 		free(cdai.buf, M_CAMXPT);
 	return ret;
 }
 
 static dev_match_ret
 xptbusmatch(struct dev_match_pattern *patterns, u_int num_patterns,
 	    struct cam_eb *bus)
 {
 	dev_match_ret retval;
 	int i;
 
 	retval = DM_RET_NONE;
 
 	/*
 	 * If we aren't given something to match against, that's an error.
 	 */
 	if (bus == NULL)
 		return(DM_RET_ERROR);
 
 	/*
 	 * If there are no match entries, then this bus matches no
 	 * matter what.
 	 */
 	if ((patterns == NULL) || (num_patterns == 0))
 		return(DM_RET_DESCEND | DM_RET_COPY);
 
 	for (i = 0; i < num_patterns; i++) {
 		struct bus_match_pattern *cur_pattern;
 
 		/*
 		 * If the pattern in question isn't for a bus node, we
 		 * aren't interested.  However, we do indicate to the
 		 * calling routine that we should continue descending the
 		 * tree, since the user wants to match against lower-level
 		 * EDT elements.
 		 */
 		if (patterns[i].type != DEV_MATCH_BUS) {
 			if ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE)
 				retval |= DM_RET_DESCEND;
 			continue;
 		}
 
 		cur_pattern = &patterns[i].pattern.bus_pattern;
 
 		/*
 		 * If they want to match any bus node, we give them any
 		 * device node.
 		 */
 		if (cur_pattern->flags == BUS_MATCH_ANY) {
 			/* set the copy flag */
 			retval |= DM_RET_COPY;
 
 			/*
 			 * If we've already decided on an action, go ahead
 			 * and return.
 			 */
 			if ((retval & DM_RET_ACTION_MASK) != DM_RET_NONE)
 				return(retval);
 		}
 
 		/*
 		 * Not sure why someone would do this...
 		 */
 		if (cur_pattern->flags == BUS_MATCH_NONE)
 			continue;
 
 		if (((cur_pattern->flags & BUS_MATCH_PATH) != 0)
 		 && (cur_pattern->path_id != bus->path_id))
 			continue;
 
 		if (((cur_pattern->flags & BUS_MATCH_BUS_ID) != 0)
 		 && (cur_pattern->bus_id != bus->sim->bus_id))
 			continue;
 
 		if (((cur_pattern->flags & BUS_MATCH_UNIT) != 0)
 		 && (cur_pattern->unit_number != bus->sim->unit_number))
 			continue;
 
 		if (((cur_pattern->flags & BUS_MATCH_NAME) != 0)
 		 && (strncmp(cur_pattern->dev_name, bus->sim->sim_name,
 			     DEV_IDLEN) != 0))
 			continue;
 
 		/*
 		 * If we get to this point, the user definitely wants
 		 * information on this bus.  So tell the caller to copy the
 		 * data out.
 		 */
 		retval |= DM_RET_COPY;
 
 		/*
 		 * If the return action has been set to descend, then we
 		 * know that we've already seen a non-bus matching
 		 * expression, therefore we need to further descend the tree.
 		 * This won't change by continuing around the loop, so we
 		 * go ahead and return.  If we haven't seen a non-bus
 		 * matching expression, we keep going around the loop until
 		 * we exhaust the matching expressions.  We'll set the stop
 		 * flag once we fall out of the loop.
 		 */
 		if ((retval & DM_RET_ACTION_MASK) == DM_RET_DESCEND)
 			return(retval);
 	}
 
 	/*
 	 * If the return action hasn't been set to descend yet, that means
 	 * we haven't seen anything other than bus matching patterns.  So
 	 * tell the caller to stop descending the tree -- the user doesn't
 	 * want to match against lower level tree elements.
 	 */
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE)
 		retval |= DM_RET_STOP;
 
 	return(retval);
 }
 
 static dev_match_ret
 xptdevicematch(struct dev_match_pattern *patterns, u_int num_patterns,
 	       struct cam_ed *device)
 {
 	dev_match_ret retval;
 	int i;
 
 	retval = DM_RET_NONE;
 
 	/*
 	 * If we aren't given something to match against, that's an error.
 	 */
 	if (device == NULL)
 		return(DM_RET_ERROR);
 
 	/*
 	 * If there are no match entries, then this device matches no
 	 * matter what.
 	 */
 	if ((patterns == NULL) || (num_patterns == 0))
 		return(DM_RET_DESCEND | DM_RET_COPY);
 
 	for (i = 0; i < num_patterns; i++) {
 		struct device_match_pattern *cur_pattern;
 		struct scsi_vpd_device_id *device_id_page;
 
 		/*
 		 * If the pattern in question isn't for a device node, we
 		 * aren't interested.
 		 */
 		if (patterns[i].type != DEV_MATCH_DEVICE) {
 			if ((patterns[i].type == DEV_MATCH_PERIPH)
 			 && ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE))
 				retval |= DM_RET_DESCEND;
 			continue;
 		}
 
 		cur_pattern = &patterns[i].pattern.device_pattern;
 
 		/* Error out if mutually exclusive options are specified. */ 
 		if ((cur_pattern->flags & (DEV_MATCH_INQUIRY|DEV_MATCH_DEVID))
 		 == (DEV_MATCH_INQUIRY|DEV_MATCH_DEVID))
 			return(DM_RET_ERROR);
 
 		/*
 		 * If they want to match any device node, we give them any
 		 * device node.
 		 */
 		if (cur_pattern->flags == DEV_MATCH_ANY)
 			goto copy_dev_node;
 
 		/*
 		 * Not sure why someone would do this...
 		 */
 		if (cur_pattern->flags == DEV_MATCH_NONE)
 			continue;
 
 		if (((cur_pattern->flags & DEV_MATCH_PATH) != 0)
 		 && (cur_pattern->path_id != device->target->bus->path_id))
 			continue;
 
 		if (((cur_pattern->flags & DEV_MATCH_TARGET) != 0)
 		 && (cur_pattern->target_id != device->target->target_id))
 			continue;
 
 		if (((cur_pattern->flags & DEV_MATCH_LUN) != 0)
 		 && (cur_pattern->target_lun != device->lun_id))
 			continue;
 
 		if (((cur_pattern->flags & DEV_MATCH_INQUIRY) != 0)
 		 && (cam_quirkmatch((caddr_t)&device->inq_data,
 				    (caddr_t)&cur_pattern->data.inq_pat,
 				    1, sizeof(cur_pattern->data.inq_pat),
 				    scsi_static_inquiry_match) == NULL))
 			continue;
 
 		device_id_page = (struct scsi_vpd_device_id *)device->device_id;
 		if (((cur_pattern->flags & DEV_MATCH_DEVID) != 0)
 		 && (device->device_id_len < SVPD_DEVICE_ID_HDR_LEN
 		  || scsi_devid_match((uint8_t *)device_id_page->desc_list,
 				      device->device_id_len
 				    - SVPD_DEVICE_ID_HDR_LEN,
 				      cur_pattern->data.devid_pat.id,
 				      cur_pattern->data.devid_pat.id_len) != 0))
 			continue;
 
 copy_dev_node:
 		/*
 		 * If we get to this point, the user definitely wants
 		 * information on this device.  So tell the caller to copy
 		 * the data out.
 		 */
 		retval |= DM_RET_COPY;
 
 		/*
 		 * If the return action has been set to descend, then we
 		 * know that we've already seen a peripheral matching
 		 * expression, therefore we need to further descend the tree.
 		 * This won't change by continuing around the loop, so we
 		 * go ahead and return.  If we haven't seen a peripheral
 		 * matching expression, we keep going around the loop until
 		 * we exhaust the matching expressions.  We'll set the stop
 		 * flag once we fall out of the loop.
 		 */
 		if ((retval & DM_RET_ACTION_MASK) == DM_RET_DESCEND)
 			return(retval);
 	}
 
 	/*
 	 * If the return action hasn't been set to descend yet, that means
 	 * we haven't seen any peripheral matching patterns.  So tell the
 	 * caller to stop descending the tree -- the user doesn't want to
 	 * match against lower level tree elements.
 	 */
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_NONE)
 		retval |= DM_RET_STOP;
 
 	return(retval);
 }
 
 /*
  * Match a single peripheral against any number of match patterns.
  */
 static dev_match_ret
 xptperiphmatch(struct dev_match_pattern *patterns, u_int num_patterns,
 	       struct cam_periph *periph)
 {
 	dev_match_ret retval;
 	int i;
 
 	/*
 	 * If we aren't given something to match against, that's an error.
 	 */
 	if (periph == NULL)
 		return(DM_RET_ERROR);
 
 	/*
 	 * If there are no match entries, then this peripheral matches no
 	 * matter what.
 	 */
 	if ((patterns == NULL) || (num_patterns == 0))
 		return(DM_RET_STOP | DM_RET_COPY);
 
 	/*
 	 * There aren't any nodes below a peripheral node, so there's no
 	 * reason to descend the tree any further.
 	 */
 	retval = DM_RET_STOP;
 
 	for (i = 0; i < num_patterns; i++) {
 		struct periph_match_pattern *cur_pattern;
 
 		/*
 		 * If the pattern in question isn't for a peripheral, we
 		 * aren't interested.
 		 */
 		if (patterns[i].type != DEV_MATCH_PERIPH)
 			continue;
 
 		cur_pattern = &patterns[i].pattern.periph_pattern;
 
 		/*
 		 * If they want to match on anything, then we will do so.
 		 */
 		if (cur_pattern->flags == PERIPH_MATCH_ANY) {
 			/* set the copy flag */
 			retval |= DM_RET_COPY;
 
 			/*
 			 * We've already set the return action to stop,
 			 * since there are no nodes below peripherals in
 			 * the tree.
 			 */
 			return(retval);
 		}
 
 		/*
 		 * Not sure why someone would do this...
 		 */
 		if (cur_pattern->flags == PERIPH_MATCH_NONE)
 			continue;
 
 		if (((cur_pattern->flags & PERIPH_MATCH_PATH) != 0)
 		 && (cur_pattern->path_id != periph->path->bus->path_id))
 			continue;
 
 		/*
 		 * For the target and lun id's, we have to make sure the
 		 * target and lun pointers aren't NULL.  The xpt peripheral
 		 * has a wildcard target and device.
 		 */
 		if (((cur_pattern->flags & PERIPH_MATCH_TARGET) != 0)
 		 && ((periph->path->target == NULL)
 		 ||(cur_pattern->target_id != periph->path->target->target_id)))
 			continue;
 
 		if (((cur_pattern->flags & PERIPH_MATCH_LUN) != 0)
 		 && ((periph->path->device == NULL)
 		 || (cur_pattern->target_lun != periph->path->device->lun_id)))
 			continue;
 
 		if (((cur_pattern->flags & PERIPH_MATCH_UNIT) != 0)
 		 && (cur_pattern->unit_number != periph->unit_number))
 			continue;
 
 		if (((cur_pattern->flags & PERIPH_MATCH_NAME) != 0)
 		 && (strncmp(cur_pattern->periph_name, periph->periph_name,
 			     DEV_IDLEN) != 0))
 			continue;
 
 		/*
 		 * If we get to this point, the user definitely wants
 		 * information on this peripheral.  So tell the caller to
 		 * copy the data out.
 		 */
 		retval |= DM_RET_COPY;
 
 		/*
 		 * The return action has already been set to stop, since
 		 * peripherals don't have any nodes below them in the EDT.
 		 */
 		return(retval);
 	}
 
 	/*
 	 * If we get to this point, the peripheral that was passed in
 	 * doesn't match any of the patterns.
 	 */
 	return(retval);
 }
 
 static int
 xptedtbusfunc(struct cam_eb *bus, void *arg)
 {
 	struct ccb_dev_match *cdm;
 	dev_match_ret retval;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	/*
 	 * If our position is for something deeper in the tree, that means
 	 * that we've already seen this node.  So, we keep going down.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus == bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.cookie.target != NULL))
 		retval = DM_RET_DESCEND;
 	else
 		retval = xptbusmatch(cdm->patterns, cdm->num_patterns, bus);
 
 	/*
 	 * If we got an error, bail out of the search.
 	 */
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) {
 		cdm->status = CAM_DEV_MATCH_ERROR;
 		return(0);
 	}
 
 	/*
 	 * If the copy flag is set, copy this bus out.
 	 */
 	if (retval & DM_RET_COPY) {
 		int spaceleft, j;
 
 		spaceleft = cdm->match_buf_len - (cdm->num_matches *
 			sizeof(struct dev_match_result));
 
 		/*
 		 * If we don't have enough space to put in another
 		 * match result, save our position and tell the
 		 * user there are more devices to check.
 		 */
 		if (spaceleft < sizeof(struct dev_match_result)) {
 			bzero(&cdm->pos, sizeof(cdm->pos));
 			cdm->pos.position_type =
 				CAM_DEV_POS_EDT | CAM_DEV_POS_BUS;
 
 			cdm->pos.cookie.bus = bus;
 			cdm->pos.generations[CAM_BUS_GENERATION]=
 				xsoftc.bus_generation;
 			cdm->status = CAM_DEV_MATCH_MORE;
 			return(0);
 		}
 		j = cdm->num_matches;
 		cdm->num_matches++;
 		cdm->matches[j].type = DEV_MATCH_BUS;
 		cdm->matches[j].result.bus_result.path_id = bus->path_id;
 		cdm->matches[j].result.bus_result.bus_id = bus->sim->bus_id;
 		cdm->matches[j].result.bus_result.unit_number =
 			bus->sim->unit_number;
 		strncpy(cdm->matches[j].result.bus_result.dev_name,
 			bus->sim->sim_name, DEV_IDLEN);
 	}
 
 	/*
 	 * If the user is only interested in busses, there's no
 	 * reason to descend to the next level in the tree.
 	 */
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_STOP)
 		return(1);
 
 	/*
 	 * If there is a target generation recorded, check it to
 	 * make sure the target list hasn't changed.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (bus == cdm->pos.cookie.bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.generations[CAM_TARGET_GENERATION] != 0)
 	 && (cdm->pos.generations[CAM_TARGET_GENERATION] !=
 	     bus->generation)) {
 		cdm->status = CAM_DEV_MATCH_LIST_CHANGED;
 		return(0);
 	}
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus == bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.cookie.target != NULL))
 		return(xpttargettraverse(bus,
 					(struct cam_et *)cdm->pos.cookie.target,
 					 xptedttargetfunc, arg));
 	else
 		return(xpttargettraverse(bus, NULL, xptedttargetfunc, arg));
 }
 
 static int
 xptedttargetfunc(struct cam_et *target, void *arg)
 {
 	struct ccb_dev_match *cdm;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	/*
 	 * If there is a device list generation recorded, check it to
 	 * make sure the device list hasn't changed.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus == target->bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.cookie.target == target)
 	 && (cdm->pos.position_type & CAM_DEV_POS_DEVICE)
 	 && (cdm->pos.generations[CAM_DEV_GENERATION] != 0)
 	 && (cdm->pos.generations[CAM_DEV_GENERATION] !=
 	     target->generation)) {
 		cdm->status = CAM_DEV_MATCH_LIST_CHANGED;
 		return(0);
 	}
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus == target->bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.cookie.target == target)
 	 && (cdm->pos.position_type & CAM_DEV_POS_DEVICE)
 	 && (cdm->pos.cookie.device != NULL))
 		return(xptdevicetraverse(target,
 					(struct cam_ed *)cdm->pos.cookie.device,
 					 xptedtdevicefunc, arg));
 	else
 		return(xptdevicetraverse(target, NULL, xptedtdevicefunc, arg));
 }
 
 static int
 xptedtdevicefunc(struct cam_ed *device, void *arg)
 {
 
 	struct ccb_dev_match *cdm;
 	dev_match_ret retval;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	/*
 	 * If our position is for something deeper in the tree, that means
 	 * that we've already seen this node.  So, we keep going down.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_DEVICE)
 	 && (cdm->pos.cookie.device == device)
 	 && (cdm->pos.position_type & CAM_DEV_POS_PERIPH)
 	 && (cdm->pos.cookie.periph != NULL))
 		retval = DM_RET_DESCEND;
 	else
 		retval = xptdevicematch(cdm->patterns, cdm->num_patterns,
 					device);
 
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) {
 		cdm->status = CAM_DEV_MATCH_ERROR;
 		return(0);
 	}
 
 	/*
 	 * If the copy flag is set, copy this device out.
 	 */
 	if (retval & DM_RET_COPY) {
 		int spaceleft, j;
 
 		spaceleft = cdm->match_buf_len - (cdm->num_matches *
 			sizeof(struct dev_match_result));
 
 		/*
 		 * If we don't have enough space to put in another
 		 * match result, save our position and tell the
 		 * user there are more devices to check.
 		 */
 		if (spaceleft < sizeof(struct dev_match_result)) {
 			bzero(&cdm->pos, sizeof(cdm->pos));
 			cdm->pos.position_type =
 				CAM_DEV_POS_EDT | CAM_DEV_POS_BUS |
 				CAM_DEV_POS_TARGET | CAM_DEV_POS_DEVICE;
 
 			cdm->pos.cookie.bus = device->target->bus;
 			cdm->pos.generations[CAM_BUS_GENERATION]=
 				xsoftc.bus_generation;
 			cdm->pos.cookie.target = device->target;
 			cdm->pos.generations[CAM_TARGET_GENERATION] =
 				device->target->bus->generation;
 			cdm->pos.cookie.device = device;
 			cdm->pos.generations[CAM_DEV_GENERATION] =
 				device->target->generation;
 			cdm->status = CAM_DEV_MATCH_MORE;
 			return(0);
 		}
 		j = cdm->num_matches;
 		cdm->num_matches++;
 		cdm->matches[j].type = DEV_MATCH_DEVICE;
 		cdm->matches[j].result.device_result.path_id =
 			device->target->bus->path_id;
 		cdm->matches[j].result.device_result.target_id =
 			device->target->target_id;
 		cdm->matches[j].result.device_result.target_lun =
 			device->lun_id;
 		cdm->matches[j].result.device_result.protocol =
 			device->protocol;
 		bcopy(&device->inq_data,
 		      &cdm->matches[j].result.device_result.inq_data,
 		      sizeof(struct scsi_inquiry_data));
 		bcopy(&device->ident_data,
 		      &cdm->matches[j].result.device_result.ident_data,
 		      sizeof(struct ata_params));
 
 		/* Let the user know whether this device is unconfigured */
 		if (device->flags & CAM_DEV_UNCONFIGURED)
 			cdm->matches[j].result.device_result.flags =
 				DEV_RESULT_UNCONFIGURED;
 		else
 			cdm->matches[j].result.device_result.flags =
 				DEV_RESULT_NOFLAG;
 	}
 
 	/*
 	 * If the user isn't interested in peripherals, don't descend
 	 * the tree any further.
 	 */
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_STOP)
 		return(1);
 
 	/*
 	 * If there is a peripheral list generation recorded, make sure
 	 * it hasn't changed.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (device->target->bus == cdm->pos.cookie.bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (device->target == cdm->pos.cookie.target)
 	 && (cdm->pos.position_type & CAM_DEV_POS_DEVICE)
 	 && (device == cdm->pos.cookie.device)
 	 && (cdm->pos.position_type & CAM_DEV_POS_PERIPH)
 	 && (cdm->pos.generations[CAM_PERIPH_GENERATION] != 0)
 	 && (cdm->pos.generations[CAM_PERIPH_GENERATION] !=
 	     device->generation)){
 		cdm->status = CAM_DEV_MATCH_LIST_CHANGED;
 		return(0);
 	}
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus == device->target->bus)
 	 && (cdm->pos.position_type & CAM_DEV_POS_TARGET)
 	 && (cdm->pos.cookie.target == device->target)
 	 && (cdm->pos.position_type & CAM_DEV_POS_DEVICE)
 	 && (cdm->pos.cookie.device == device)
 	 && (cdm->pos.position_type & CAM_DEV_POS_PERIPH)
 	 && (cdm->pos.cookie.periph != NULL))
 		return(xptperiphtraverse(device,
 				(struct cam_periph *)cdm->pos.cookie.periph,
 				xptedtperiphfunc, arg));
 	else
 		return(xptperiphtraverse(device, NULL, xptedtperiphfunc, arg));
 }
 
 static int
 xptedtperiphfunc(struct cam_periph *periph, void *arg)
 {
 	struct ccb_dev_match *cdm;
 	dev_match_ret retval;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	retval = xptperiphmatch(cdm->patterns, cdm->num_patterns, periph);
 
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) {
 		cdm->status = CAM_DEV_MATCH_ERROR;
 		return(0);
 	}
 
 	/*
 	 * If the copy flag is set, copy this peripheral out.
 	 */
 	if (retval & DM_RET_COPY) {
 		int spaceleft, j;
 
 		spaceleft = cdm->match_buf_len - (cdm->num_matches *
 			sizeof(struct dev_match_result));
 
 		/*
 		 * If we don't have enough space to put in another
 		 * match result, save our position and tell the
 		 * user there are more devices to check.
 		 */
 		if (spaceleft < sizeof(struct dev_match_result)) {
 			bzero(&cdm->pos, sizeof(cdm->pos));
 			cdm->pos.position_type =
 				CAM_DEV_POS_EDT | CAM_DEV_POS_BUS |
 				CAM_DEV_POS_TARGET | CAM_DEV_POS_DEVICE |
 				CAM_DEV_POS_PERIPH;
 
 			cdm->pos.cookie.bus = periph->path->bus;
 			cdm->pos.generations[CAM_BUS_GENERATION]=
 				xsoftc.bus_generation;
 			cdm->pos.cookie.target = periph->path->target;
 			cdm->pos.generations[CAM_TARGET_GENERATION] =
 				periph->path->bus->generation;
 			cdm->pos.cookie.device = periph->path->device;
 			cdm->pos.generations[CAM_DEV_GENERATION] =
 				periph->path->target->generation;
 			cdm->pos.cookie.periph = periph;
 			cdm->pos.generations[CAM_PERIPH_GENERATION] =
 				periph->path->device->generation;
 			cdm->status = CAM_DEV_MATCH_MORE;
 			return(0);
 		}
 
 		j = cdm->num_matches;
 		cdm->num_matches++;
 		cdm->matches[j].type = DEV_MATCH_PERIPH;
 		cdm->matches[j].result.periph_result.path_id =
 			periph->path->bus->path_id;
 		cdm->matches[j].result.periph_result.target_id =
 			periph->path->target->target_id;
 		cdm->matches[j].result.periph_result.target_lun =
 			periph->path->device->lun_id;
 		cdm->matches[j].result.periph_result.unit_number =
 			periph->unit_number;
 		strncpy(cdm->matches[j].result.periph_result.periph_name,
 			periph->periph_name, DEV_IDLEN);
 	}
 
 	return(1);
 }
 
 static int
 xptedtmatch(struct ccb_dev_match *cdm)
 {
 	int ret;
 
 	cdm->num_matches = 0;
 
 	/*
 	 * Check the bus list generation.  If it has changed, the user
 	 * needs to reset everything and start over.
 	 */
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.generations[CAM_BUS_GENERATION] != 0)
 	 && (cdm->pos.generations[CAM_BUS_GENERATION] != xsoftc.bus_generation)) {
 		cdm->status = CAM_DEV_MATCH_LIST_CHANGED;
 		return(0);
 	}
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_BUS)
 	 && (cdm->pos.cookie.bus != NULL))
 		ret = xptbustraverse((struct cam_eb *)cdm->pos.cookie.bus,
 				     xptedtbusfunc, cdm);
 	else
 		ret = xptbustraverse(NULL, xptedtbusfunc, cdm);
 
 	/*
 	 * If we get back 0, that means that we had to stop before fully
 	 * traversing the EDT.  It also means that one of the subroutines
 	 * has set the status field to the proper value.  If we get back 1,
 	 * we've fully traversed the EDT and copied out any matching entries.
 	 */
 	if (ret == 1)
 		cdm->status = CAM_DEV_MATCH_LAST;
 
 	return(ret);
 }
 
 static int
 xptplistpdrvfunc(struct periph_driver **pdrv, void *arg)
 {
 	struct ccb_dev_match *cdm;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_PDPTR)
 	 && (cdm->pos.cookie.pdrv == pdrv)
 	 && (cdm->pos.position_type & CAM_DEV_POS_PERIPH)
 	 && (cdm->pos.generations[CAM_PERIPH_GENERATION] != 0)
 	 && (cdm->pos.generations[CAM_PERIPH_GENERATION] !=
 	     (*pdrv)->generation)) {
 		cdm->status = CAM_DEV_MATCH_LIST_CHANGED;
 		return(0);
 	}
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_PDPTR)
 	 && (cdm->pos.cookie.pdrv == pdrv)
 	 && (cdm->pos.position_type & CAM_DEV_POS_PERIPH)
 	 && (cdm->pos.cookie.periph != NULL))
 		return(xptpdperiphtraverse(pdrv,
 				(struct cam_periph *)cdm->pos.cookie.periph,
 				xptplistperiphfunc, arg));
 	else
 		return(xptpdperiphtraverse(pdrv, NULL,xptplistperiphfunc, arg));
 }
 
 static int
 xptplistperiphfunc(struct cam_periph *periph, void *arg)
 {
 	struct ccb_dev_match *cdm;
 	dev_match_ret retval;
 
 	cdm = (struct ccb_dev_match *)arg;
 
 	retval = xptperiphmatch(cdm->patterns, cdm->num_patterns, periph);
 
 	if ((retval & DM_RET_ACTION_MASK) == DM_RET_ERROR) {
 		cdm->status = CAM_DEV_MATCH_ERROR;
 		return(0);
 	}
 
 	/*
 	 * If the copy flag is set, copy this peripheral out.
 	 */
 	if (retval & DM_RET_COPY) {
 		int spaceleft, j;
 
 		spaceleft = cdm->match_buf_len - (cdm->num_matches *
 			sizeof(struct dev_match_result));
 
 		/*
 		 * If we don't have enough space to put in another
 		 * match result, save our position and tell the
 		 * user there are more devices to check.
 		 */
 		if (spaceleft < sizeof(struct dev_match_result)) {
 			struct periph_driver **pdrv;
 
 			pdrv = NULL;
 			bzero(&cdm->pos, sizeof(cdm->pos));
 			cdm->pos.position_type =
 				CAM_DEV_POS_PDRV | CAM_DEV_POS_PDPTR |
 				CAM_DEV_POS_PERIPH;
 
 			/*
 			 * This may look a bit non-sensical, but it is
 			 * actually quite logical.  There are very few
 			 * peripheral drivers, and bloating every peripheral
 			 * structure with a pointer back to its parent
 			 * peripheral driver linker set entry would cost
 			 * more in the long run than doing this quick lookup.
 			 */
 			for (pdrv = periph_drivers; *pdrv != NULL; pdrv++) {
 				if (strcmp((*pdrv)->driver_name,
 				    periph->periph_name) == 0)
 					break;
 			}
 
 			if (*pdrv == NULL) {
 				cdm->status = CAM_DEV_MATCH_ERROR;
 				return(0);
 			}
 
 			cdm->pos.cookie.pdrv = pdrv;
 			/*
 			 * The periph generation slot does double duty, as
 			 * does the periph pointer slot.  They are used for
 			 * both edt and pdrv lookups and positioning.
 			 */
 			cdm->pos.cookie.periph = periph;
 			cdm->pos.generations[CAM_PERIPH_GENERATION] =
 				(*pdrv)->generation;
 			cdm->status = CAM_DEV_MATCH_MORE;
 			return(0);
 		}
 
 		j = cdm->num_matches;
 		cdm->num_matches++;
 		cdm->matches[j].type = DEV_MATCH_PERIPH;
 		cdm->matches[j].result.periph_result.path_id =
 			periph->path->bus->path_id;
 
 		/*
 		 * The transport layer peripheral doesn't have a target or
 		 * lun.
 		 */
 		if (periph->path->target)
 			cdm->matches[j].result.periph_result.target_id =
 				periph->path->target->target_id;
 		else
 			cdm->matches[j].result.periph_result.target_id = -1;
 
 		if (periph->path->device)
 			cdm->matches[j].result.periph_result.target_lun =
 				periph->path->device->lun_id;
 		else
 			cdm->matches[j].result.periph_result.target_lun = -1;
 
 		cdm->matches[j].result.periph_result.unit_number =
 			periph->unit_number;
 		strncpy(cdm->matches[j].result.periph_result.periph_name,
 			periph->periph_name, DEV_IDLEN);
 	}
 
 	return(1);
 }
 
 static int
 xptperiphlistmatch(struct ccb_dev_match *cdm)
 {
 	int ret;
 
 	cdm->num_matches = 0;
 
 	/*
 	 * At this point in the edt traversal function, we check the bus
 	 * list generation to make sure that no busses have been added or
 	 * removed since the user last sent a XPT_DEV_MATCH ccb through.
 	 * For the peripheral driver list traversal function, however, we
 	 * don't have to worry about new peripheral driver types coming or
 	 * going; they're in a linker set, and therefore can't change
 	 * without a recompile.
 	 */
 
 	if ((cdm->pos.position_type & CAM_DEV_POS_PDPTR)
 	 && (cdm->pos.cookie.pdrv != NULL))
 		ret = xptpdrvtraverse(
 				(struct periph_driver **)cdm->pos.cookie.pdrv,
 				xptplistpdrvfunc, cdm);
 	else
 		ret = xptpdrvtraverse(NULL, xptplistpdrvfunc, cdm);
 
 	/*
 	 * If we get back 0, that means that we had to stop before fully
 	 * traversing the peripheral driver tree.  It also means that one of
 	 * the subroutines has set the status field to the proper value.  If
 	 * we get back 1, we've fully traversed the EDT and copied out any
 	 * matching entries.
 	 */
 	if (ret == 1)
 		cdm->status = CAM_DEV_MATCH_LAST;
 
 	return(ret);
 }
 
 static int
 xptbustraverse(struct cam_eb *start_bus, xpt_busfunc_t *tr_func, void *arg)
 {
 	struct cam_eb *bus, *next_bus;
 	int retval;
 
 	retval = 1;
 
 	xpt_lock_buses();
 	for (bus = (start_bus ? start_bus : TAILQ_FIRST(&xsoftc.xpt_busses));
 	     bus != NULL;
 	     bus = next_bus) {
 
 		bus->refcount++;
 
 		/*
 		 * XXX The locking here is obviously very complex.  We
 		 * should work to simplify it.
 		 */
 		xpt_unlock_buses();
 		CAM_SIM_LOCK(bus->sim);
 		retval = tr_func(bus, arg);
 		CAM_SIM_UNLOCK(bus->sim);
 
 		xpt_lock_buses();
 		next_bus = TAILQ_NEXT(bus, links);
 		xpt_unlock_buses();
 
 		xpt_release_bus(bus);
 
 		if (retval == 0)
 			return(retval);
 		xpt_lock_buses();
 	}
 	xpt_unlock_buses();
 
 	return(retval);
 }
 
 static int
 xpttargettraverse(struct cam_eb *bus, struct cam_et *start_target,
 		  xpt_targetfunc_t *tr_func, void *arg)
 {
 	struct cam_et *target, *next_target;
 	int retval;
 
 	mtx_assert(bus->sim->mtx, MA_OWNED);
 	retval = 1;
 	for (target = (start_target ? start_target :
 		       TAILQ_FIRST(&bus->et_entries));
 	     target != NULL; target = next_target) {
 
 		target->refcount++;
 
 		retval = tr_func(target, arg);
 
 		next_target = TAILQ_NEXT(target, links);
 
 		xpt_release_target(target);
 
 		if (retval == 0)
 			return(retval);
 	}
 
 	return(retval);
 }
 
 static int
 xptdevicetraverse(struct cam_et *target, struct cam_ed *start_device,
 		  xpt_devicefunc_t *tr_func, void *arg)
 {
 	struct cam_ed *device, *next_device;
 	int retval;
 
 	mtx_assert(target->bus->sim->mtx, MA_OWNED);
 	retval = 1;
 	for (device = (start_device ? start_device :
 		       TAILQ_FIRST(&target->ed_entries));
 	     device != NULL;
 	     device = next_device) {
 
 		/*
 		 * Hold a reference so the current device does not go away
 		 * on us.
 		 */
 		device->refcount++;
 
 		retval = tr_func(device, arg);
 
 		/*
 		 * Grab our next pointer before we release the current
 		 * device.
 		 */
 		next_device = TAILQ_NEXT(device, links);
 
 		xpt_release_device(device);
 
 		if (retval == 0)
 			return(retval);
 	}
 
 	return(retval);
 }
 
 static int
 xptperiphtraverse(struct cam_ed *device, struct cam_periph *start_periph,
 		  xpt_periphfunc_t *tr_func, void *arg)
 {
 	struct cam_periph *periph, *next_periph;
 	int retval;
 
 	retval = 1;
 
 	mtx_assert(device->sim->mtx, MA_OWNED);
 	xpt_lock_buses();
 	for (periph = (start_periph ? start_periph :
 		       SLIST_FIRST(&device->periphs));
 	     periph != NULL;
 	     periph = next_periph) {
 
 
 		/*
 		 * In this case, we want to show peripherals that have been
 		 * invalidated, but not peripherals that are scheduled to
 		 * be freed.  So instead of calling cam_periph_acquire(),
 		 * which will fail if the periph has been invalidated, we
 		 * just check for the free flag here.  If it is in the
 		 * process of being freed, we skip to the next periph.
 		 */
 		if (periph->flags & CAM_PERIPH_FREE) {
 			next_periph = SLIST_NEXT(periph, periph_links);
 			continue;
 		}
 
 		/*
 		 * Acquire a reference to this periph while we call the
 		 * traversal function, so it can't go away.
 		 */
 		periph->refcount++;
 
 		retval = tr_func(periph, arg);
 
 		/*
 		 * Grab the next peripheral before we release this one, so
 		 * our next pointer is still valid.
 		 */
 		next_periph = SLIST_NEXT(periph, periph_links);
 
 		cam_periph_release_locked_buses(periph);
 
 		if (retval == 0)
 			goto bailout_done;
 	}
 
 bailout_done:
 
 	xpt_unlock_buses();
 
 	return(retval);
 }
 
 static int
 xptpdrvtraverse(struct periph_driver **start_pdrv,
 		xpt_pdrvfunc_t *tr_func, void *arg)
 {
 	struct periph_driver **pdrv;
 	int retval;
 
 	retval = 1;
 
 	/*
 	 * We don't traverse the peripheral driver list like we do the
 	 * other lists, because it is a linker set, and therefore cannot be
 	 * changed during runtime.  If the peripheral driver list is ever
 	 * re-done to be something other than a linker set (i.e. it can
 	 * change while the system is running), the list traversal should
 	 * be modified to work like the other traversal functions.
 	 */
 	for (pdrv = (start_pdrv ? start_pdrv : periph_drivers);
 	     *pdrv != NULL; pdrv++) {
 		retval = tr_func(pdrv, arg);
 
 		if (retval == 0)
 			return(retval);
 	}
 
 	return(retval);
 }
 
 static int
 xptpdperiphtraverse(struct periph_driver **pdrv,
 		    struct cam_periph *start_periph,
 		    xpt_periphfunc_t *tr_func, void *arg)
 {
 	struct cam_periph *periph, *next_periph;
 	struct cam_sim *sim;
 	int retval;
 
 	retval = 1;
 
 	xpt_lock_buses();
 	for (periph = (start_periph ? start_periph :
 	     TAILQ_FIRST(&(*pdrv)->units)); periph != NULL;
 	     periph = next_periph) {
 
 
 		/*
 		 * In this case, we want to show peripherals that have been
 		 * invalidated, but not peripherals that are scheduled to
 		 * be freed.  So instead of calling cam_periph_acquire(),
 		 * which will fail if the periph has been invalidated, we
 		 * just check for the free flag here.  If it is free, we
 		 * skip to the next periph.
 		 */
 		if (periph->flags & CAM_PERIPH_FREE) {
 			next_periph = TAILQ_NEXT(periph, unit_links);
 			continue;
 		}
 
 		/*
 		 * Acquire a reference to this periph while we call the
 		 * traversal function, so it can't go away.
 		 */
 		periph->refcount++;
 		sim = periph->sim;
 		xpt_unlock_buses();
 		CAM_SIM_LOCK(sim);
 		xpt_lock_buses();
 		retval = tr_func(periph, arg);
 
 		/*
 		 * Grab the next peripheral before we release this one, so
 		 * our next pointer is still valid.
 		 */
 		next_periph = TAILQ_NEXT(periph, unit_links);
 
 		cam_periph_release_locked_buses(periph);
 		CAM_SIM_UNLOCK(sim);
 
 		if (retval == 0)
 			goto bailout_done;
 	}
 bailout_done:
 
 	xpt_unlock_buses();
 
 	return(retval);
 }
 
 static int
 xptdefbusfunc(struct cam_eb *bus, void *arg)
 {
 	struct xpt_traverse_config *tr_config;
 
 	tr_config = (struct xpt_traverse_config *)arg;
 
 	if (tr_config->depth == XPT_DEPTH_BUS) {
 		xpt_busfunc_t *tr_func;
 
 		tr_func = (xpt_busfunc_t *)tr_config->tr_func;
 
 		return(tr_func(bus, tr_config->tr_arg));
 	} else
 		return(xpttargettraverse(bus, NULL, xptdeftargetfunc, arg));
 }
 
 static int
 xptdeftargetfunc(struct cam_et *target, void *arg)
 {
 	struct xpt_traverse_config *tr_config;
 
 	tr_config = (struct xpt_traverse_config *)arg;
 
 	if (tr_config->depth == XPT_DEPTH_TARGET) {
 		xpt_targetfunc_t *tr_func;
 
 		tr_func = (xpt_targetfunc_t *)tr_config->tr_func;
 
 		return(tr_func(target, tr_config->tr_arg));
 	} else
 		return(xptdevicetraverse(target, NULL, xptdefdevicefunc, arg));
 }
 
 static int
 xptdefdevicefunc(struct cam_ed *device, void *arg)
 {
 	struct xpt_traverse_config *tr_config;
 
 	tr_config = (struct xpt_traverse_config *)arg;
 
 	if (tr_config->depth == XPT_DEPTH_DEVICE) {
 		xpt_devicefunc_t *tr_func;
 
 		tr_func = (xpt_devicefunc_t *)tr_config->tr_func;
 
 		return(tr_func(device, tr_config->tr_arg));
 	} else
 		return(xptperiphtraverse(device, NULL, xptdefperiphfunc, arg));
 }
 
 static int
 xptdefperiphfunc(struct cam_periph *periph, void *arg)
 {
 	struct xpt_traverse_config *tr_config;
 	xpt_periphfunc_t *tr_func;
 
 	tr_config = (struct xpt_traverse_config *)arg;
 
 	tr_func = (xpt_periphfunc_t *)tr_config->tr_func;
 
 	/*
 	 * Unlike the other default functions, we don't check for depth
 	 * here.  The peripheral driver level is the last level in the EDT,
 	 * so if we're here, we should execute the function in question.
 	 */
 	return(tr_func(periph, tr_config->tr_arg));
 }
 
 /*
  * Execute the given function for every bus in the EDT.
  */
 static int
 xpt_for_all_busses(xpt_busfunc_t *tr_func, void *arg)
 {
 	struct xpt_traverse_config tr_config;
 
 	tr_config.depth = XPT_DEPTH_BUS;
 	tr_config.tr_func = tr_func;
 	tr_config.tr_arg = arg;
 
 	return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
 }
 
 /*
  * Execute the given function for every device in the EDT.
  */
 static int
 xpt_for_all_devices(xpt_devicefunc_t *tr_func, void *arg)
 {
 	struct xpt_traverse_config tr_config;
 
 	tr_config.depth = XPT_DEPTH_DEVICE;
 	tr_config.tr_func = tr_func;
 	tr_config.tr_arg = arg;
 
 	return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
 }
 
 static int
 xptsetasyncfunc(struct cam_ed *device, void *arg)
 {
 	struct cam_path path;
 	struct ccb_getdev cgd;
 	struct ccb_setasync *csa = (struct ccb_setasync *)arg;
 
 	/*
 	 * Don't report unconfigured devices (Wildcard devs,
 	 * devices only for target mode, device instances
 	 * that have been invalidated but are waiting for
 	 * their last reference count to be released).
 	 */
 	if ((device->flags & CAM_DEV_UNCONFIGURED) != 0)
 		return (1);
 
 	xpt_compile_path(&path,
 			 NULL,
 			 device->target->bus->path_id,
 			 device->target->target_id,
 			 device->lun_id);
 	xpt_setup_ccb(&cgd.ccb_h, &path, CAM_PRIORITY_NORMAL);
 	cgd.ccb_h.func_code = XPT_GDEV_TYPE;
 	xpt_action((union ccb *)&cgd);
 	csa->callback(csa->callback_arg,
 			    AC_FOUND_DEVICE,
 			    &path, &cgd);
 	xpt_release_path(&path);
 
 	return(1);
 }
 
 static int
 xptsetasyncbusfunc(struct cam_eb *bus, void *arg)
 {
 	struct cam_path path;
 	struct ccb_pathinq cpi;
 	struct ccb_setasync *csa = (struct ccb_setasync *)arg;
 
 	xpt_compile_path(&path, /*periph*/NULL,
 			 bus->sim->path_id,
 			 CAM_TARGET_WILDCARD,
 			 CAM_LUN_WILDCARD);
 	xpt_setup_ccb(&cpi.ccb_h, &path, CAM_PRIORITY_NORMAL);
 	cpi.ccb_h.func_code = XPT_PATH_INQ;
 	xpt_action((union ccb *)&cpi);
 	csa->callback(csa->callback_arg,
 			    AC_PATH_REGISTERED,
 			    &path, &cpi);
 	xpt_release_path(&path);
 
 	return(1);
 }
 
 void
 xpt_action(union ccb *start_ccb)
 {
 
 	CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_action\n"));
 
 	start_ccb->ccb_h.status = CAM_REQ_INPROG;
 	(*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb);
 }
 
 void
 xpt_action_default(union ccb *start_ccb)
 {
 	struct cam_path *path;
 
 	path = start_ccb->ccb_h.path;
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_action_default\n"));
 
 	switch (start_ccb->ccb_h.func_code) {
 	case XPT_SCSI_IO:
 	{
 		struct cam_ed *device;
 
 		/*
 		 * For the sake of compatibility with SCSI-1
 		 * devices that may not understand the identify
 		 * message, we include lun information in the
 		 * second byte of all commands.  SCSI-1 specifies
 		 * that luns are a 3 bit value and reserves only 3
 		 * bits for lun information in the CDB.  Later
 		 * revisions of the SCSI spec allow for more than 8
 		 * luns, but have deprecated lun information in the
 		 * CDB.  So, if the lun won't fit, we must omit.
 		 *
 		 * Also be aware that during initial probing for devices,
 		 * the inquiry information is unknown but initialized to 0.
 		 * This means that this code will be exercised while probing
 		 * devices with an ANSI revision greater than 2.
 		 */
 		device = path->device;
 		if (device->protocol_version <= SCSI_REV_2
 		 && start_ccb->ccb_h.target_lun < 8
 		 && (start_ccb->ccb_h.flags & CAM_CDB_POINTER) == 0) {
 
 			start_ccb->csio.cdb_io.cdb_bytes[1] |=
 			    start_ccb->ccb_h.target_lun << 5;
 		}
 		start_ccb->csio.scsi_status = SCSI_STATUS_OK;
 	}
 	/* FALLTHROUGH */
 	case XPT_TARGET_IO:
 	case XPT_CONT_TARGET_IO:
 		start_ccb->csio.sense_resid = 0;
 		start_ccb->csio.resid = 0;
 		/* FALLTHROUGH */
 	case XPT_ATA_IO:
 		if (start_ccb->ccb_h.func_code == XPT_ATA_IO)
 			start_ccb->ataio.resid = 0;
 		/* FALLTHROUGH */
 	case XPT_RESET_DEV:
 	case XPT_ENG_EXEC:
 	case XPT_SMP_IO:
 		cam_ccbq_insert_ccb(&path->device->ccbq, start_ccb);
 		if (xpt_schedule_devq(path->bus->sim->devq, path->device))
 			xpt_run_devq(path->bus->sim->devq);
 		break;
 	case XPT_CALC_GEOMETRY:
 	{
 		struct cam_sim *sim;
 
 		/* Filter out garbage */
 		if (start_ccb->ccg.block_size == 0
 		 || start_ccb->ccg.volume_size == 0) {
 			start_ccb->ccg.cylinders = 0;
 			start_ccb->ccg.heads = 0;
 			start_ccb->ccg.secs_per_track = 0;
 			start_ccb->ccb_h.status = CAM_REQ_CMP;
 			break;
 		}
 #if defined(PC98) || defined(__sparc64__)
 		/*
 		 * In a PC-98 system, geometry translation depens on
 		 * the "real" device geometry obtained from mode page 4.
 		 * SCSI geometry translation is performed in the
 		 * initialization routine of the SCSI BIOS and the result
 		 * stored in host memory.  If the translation is available
 		 * in host memory, use it.  If not, rely on the default
 		 * translation the device driver performs.
 		 * For sparc64, we may need adjust the geometry of large
 		 * disks in order to fit the limitations of the 16-bit
 		 * fields of the VTOC8 disk label.
 		 */
 		if (scsi_da_bios_params(&start_ccb->ccg) != 0) {
 			start_ccb->ccb_h.status = CAM_REQ_CMP;
 			break;
 		}
 #endif
 		sim = path->bus->sim;
 		(*(sim->sim_action))(sim, start_ccb);
 		break;
 	}
 	case XPT_ABORT:
 	{
 		union ccb* abort_ccb;
 
 		abort_ccb = start_ccb->cab.abort_ccb;
 		if (XPT_FC_IS_DEV_QUEUED(abort_ccb)) {
 
 			if (abort_ccb->ccb_h.pinfo.index >= 0) {
 				struct cam_ccbq *ccbq;
 				struct cam_ed *device;
 
 				device = abort_ccb->ccb_h.path->device;
 				ccbq = &device->ccbq;
 				cam_ccbq_remove_ccb(ccbq, abort_ccb);
 				abort_ccb->ccb_h.status =
 				    CAM_REQ_ABORTED|CAM_DEV_QFRZN;
 				xpt_freeze_devq(abort_ccb->ccb_h.path, 1);
 				xpt_done(abort_ccb);
 				start_ccb->ccb_h.status = CAM_REQ_CMP;
 				break;
 			}
 			if (abort_ccb->ccb_h.pinfo.index == CAM_UNQUEUED_INDEX
 			 && (abort_ccb->ccb_h.status & CAM_SIM_QUEUED) == 0) {
 				/*
 				 * We've caught this ccb en route to
 				 * the SIM.  Flag it for abort and the
 				 * SIM will do so just before starting
 				 * real work on the CCB.
 				 */
 				abort_ccb->ccb_h.status =
 				    CAM_REQ_ABORTED|CAM_DEV_QFRZN;
 				xpt_freeze_devq(abort_ccb->ccb_h.path, 1);
 				start_ccb->ccb_h.status = CAM_REQ_CMP;
 				break;
 			}
 		}
 		if (XPT_FC_IS_QUEUED(abort_ccb)
 		 && (abort_ccb->ccb_h.pinfo.index == CAM_DONEQ_INDEX)) {
 			/*
 			 * It's already completed but waiting
 			 * for our SWI to get to it.
 			 */
 			start_ccb->ccb_h.status = CAM_UA_ABORT;
 			break;
 		}
 		/*
 		 * If we weren't able to take care of the abort request
 		 * in the XPT, pass the request down to the SIM for processing.
 		 */
 	}
 	/* FALLTHROUGH */
 	case XPT_ACCEPT_TARGET_IO:
 	case XPT_EN_LUN:
 	case XPT_IMMED_NOTIFY:
 	case XPT_NOTIFY_ACK:
 	case XPT_RESET_BUS:
 	case XPT_IMMEDIATE_NOTIFY:
 	case XPT_NOTIFY_ACKNOWLEDGE:
 	case XPT_GET_SIM_KNOB:
 	case XPT_SET_SIM_KNOB:
 	{
 		struct cam_sim *sim;
 
 		sim = path->bus->sim;
 		(*(sim->sim_action))(sim, start_ccb);
 		break;
 	}
 	case XPT_PATH_INQ:
 	{
 		struct cam_sim *sim;
 
 		sim = path->bus->sim;
 		(*(sim->sim_action))(sim, start_ccb);
 		break;
 	}
 	case XPT_PATH_STATS:
 		start_ccb->cpis.last_reset = path->bus->last_reset;
 		start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	case XPT_GDEV_TYPE:
 	{
 		struct cam_ed *dev;
 
 		dev = path->device;
 		if ((dev->flags & CAM_DEV_UNCONFIGURED) != 0) {
 			start_ccb->ccb_h.status = CAM_DEV_NOT_THERE;
 		} else {
 			struct ccb_getdev *cgd;
 
 			cgd = &start_ccb->cgd;
 			cgd->protocol = dev->protocol;
 			cgd->inq_data = dev->inq_data;
 			cgd->ident_data = dev->ident_data;
 			cgd->inq_flags = dev->inq_flags;
 			cgd->ccb_h.status = CAM_REQ_CMP;
 			cgd->serial_num_len = dev->serial_num_len;
 			if ((dev->serial_num_len > 0)
 			 && (dev->serial_num != NULL))
 				bcopy(dev->serial_num, cgd->serial_num,
 				      dev->serial_num_len);
 		}
 		break;
 	}
 	case XPT_GDEV_STATS:
 	{
 		struct cam_ed *dev;
 
 		dev = path->device;
 		if ((dev->flags & CAM_DEV_UNCONFIGURED) != 0) {
 			start_ccb->ccb_h.status = CAM_DEV_NOT_THERE;
 		} else {
 			struct ccb_getdevstats *cgds;
 			struct cam_eb *bus;
 			struct cam_et *tar;
 
 			cgds = &start_ccb->cgds;
 			bus = path->bus;
 			tar = path->target;
 			cgds->dev_openings = dev->ccbq.dev_openings;
 			cgds->dev_active = dev->ccbq.dev_active;
 			cgds->devq_openings = dev->ccbq.devq_openings;
 			cgds->devq_queued = dev->ccbq.queue.entries;
 			cgds->held = dev->ccbq.held;
 			cgds->last_reset = tar->last_reset;
 			cgds->maxtags = dev->maxtags;
 			cgds->mintags = dev->mintags;
 			if (timevalcmp(&tar->last_reset, &bus->last_reset, <))
 				cgds->last_reset = bus->last_reset;
 			cgds->ccb_h.status = CAM_REQ_CMP;
 		}
 		break;
 	}
 	case XPT_GDEVLIST:
 	{
 		struct cam_periph	*nperiph;
 		struct periph_list	*periph_head;
 		struct ccb_getdevlist	*cgdl;
 		u_int			i;
 		struct cam_ed		*device;
 		int			found;
 
 
 		found = 0;
 
 		/*
 		 * Don't want anyone mucking with our data.
 		 */
 		device = path->device;
 		periph_head = &device->periphs;
 		cgdl = &start_ccb->cgdl;
 
 		/*
 		 * Check and see if the list has changed since the user
 		 * last requested a list member.  If so, tell them that the
 		 * list has changed, and therefore they need to start over
 		 * from the beginning.
 		 */
 		if ((cgdl->index != 0) &&
 		    (cgdl->generation != device->generation)) {
 			cgdl->status = CAM_GDEVLIST_LIST_CHANGED;
 			break;
 		}
 
 		/*
 		 * Traverse the list of peripherals and attempt to find
 		 * the requested peripheral.
 		 */
 		for (nperiph = SLIST_FIRST(periph_head), i = 0;
 		     (nperiph != NULL) && (i <= cgdl->index);
 		     nperiph = SLIST_NEXT(nperiph, periph_links), i++) {
 			if (i == cgdl->index) {
 				strncpy(cgdl->periph_name,
 					nperiph->periph_name,
 					DEV_IDLEN);
 				cgdl->unit_number = nperiph->unit_number;
 				found = 1;
 			}
 		}
 		if (found == 0) {
 			cgdl->status = CAM_GDEVLIST_ERROR;
 			break;
 		}
 
 		if (nperiph == NULL)
 			cgdl->status = CAM_GDEVLIST_LAST_DEVICE;
 		else
 			cgdl->status = CAM_GDEVLIST_MORE_DEVS;
 
 		cgdl->index++;
 		cgdl->generation = device->generation;
 
 		cgdl->ccb_h.status = CAM_REQ_CMP;
 		break;
 	}
 	case XPT_DEV_MATCH:
 	{
 		dev_pos_type position_type;
 		struct ccb_dev_match *cdm;
 
 		cdm = &start_ccb->cdm;
 
 		/*
 		 * There are two ways of getting at information in the EDT.
 		 * The first way is via the primary EDT tree.  It starts
 		 * with a list of busses, then a list of targets on a bus,
 		 * then devices/luns on a target, and then peripherals on a
 		 * device/lun.  The "other" way is by the peripheral driver
 		 * lists.  The peripheral driver lists are organized by
 		 * peripheral driver.  (obviously)  So it makes sense to
 		 * use the peripheral driver list if the user is looking
 		 * for something like "da1", or all "da" devices.  If the
 		 * user is looking for something on a particular bus/target
 		 * or lun, it's generally better to go through the EDT tree.
 		 */
 
 		if (cdm->pos.position_type != CAM_DEV_POS_NONE)
 			position_type = cdm->pos.position_type;
 		else {
 			u_int i;
 
 			position_type = CAM_DEV_POS_NONE;
 
 			for (i = 0; i < cdm->num_patterns; i++) {
 				if ((cdm->patterns[i].type == DEV_MATCH_BUS)
 				 ||(cdm->patterns[i].type == DEV_MATCH_DEVICE)){
 					position_type = CAM_DEV_POS_EDT;
 					break;
 				}
 			}
 
 			if (cdm->num_patterns == 0)
 				position_type = CAM_DEV_POS_EDT;
 			else if (position_type == CAM_DEV_POS_NONE)
 				position_type = CAM_DEV_POS_PDRV;
 		}
 
 		/*
 		 * Note that we drop the SIM lock here, because the EDT
 		 * traversal code needs to do its own locking.
 		 */
 		CAM_SIM_UNLOCK(xpt_path_sim(cdm->ccb_h.path));
 		switch(position_type & CAM_DEV_POS_TYPEMASK) {
 		case CAM_DEV_POS_EDT:
 			xptedtmatch(cdm);
 			break;
 		case CAM_DEV_POS_PDRV:
 			xptperiphlistmatch(cdm);
 			break;
 		default:
 			cdm->status = CAM_DEV_MATCH_ERROR;
 			break;
 		}
 		CAM_SIM_LOCK(xpt_path_sim(cdm->ccb_h.path));
 
 		if (cdm->status == CAM_DEV_MATCH_ERROR)
 			start_ccb->ccb_h.status = CAM_REQ_CMP_ERR;
 		else
 			start_ccb->ccb_h.status = CAM_REQ_CMP;
 
 		break;
 	}
 	case XPT_SASYNC_CB:
 	{
 		struct ccb_setasync *csa;
 		struct async_node *cur_entry;
 		struct async_list *async_head;
 		u_int32_t added;
 
 		csa = &start_ccb->csa;
 		added = csa->event_enable;
 		async_head = &path->device->asyncs;
 
 		/*
 		 * If there is already an entry for us, simply
 		 * update it.
 		 */
 		cur_entry = SLIST_FIRST(async_head);
 		while (cur_entry != NULL) {
 			if ((cur_entry->callback_arg == csa->callback_arg)
 			 && (cur_entry->callback == csa->callback))
 				break;
 			cur_entry = SLIST_NEXT(cur_entry, links);
 		}
 
 		if (cur_entry != NULL) {
 		 	/*
 			 * If the request has no flags set,
 			 * remove the entry.
 			 */
 			added &= ~cur_entry->event_enable;
 			if (csa->event_enable == 0) {
 				SLIST_REMOVE(async_head, cur_entry,
 					     async_node, links);
 				xpt_release_device(path->device);
 				free(cur_entry, M_CAMXPT);
 			} else {
 				cur_entry->event_enable = csa->event_enable;
 			}
 			csa->event_enable = added;
 		} else {
 			cur_entry = malloc(sizeof(*cur_entry), M_CAMXPT,
 					   M_NOWAIT);
 			if (cur_entry == NULL) {
 				csa->ccb_h.status = CAM_RESRC_UNAVAIL;
 				break;
 			}
 			cur_entry->event_enable = csa->event_enable;
 			cur_entry->callback_arg = csa->callback_arg;
 			cur_entry->callback = csa->callback;
 			SLIST_INSERT_HEAD(async_head, cur_entry, links);
 			xpt_acquire_device(path->device);
 		}
 		start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	}
 	case XPT_REL_SIMQ:
 	{
 		struct ccb_relsim *crs;
 		struct cam_ed *dev;
 
 		crs = &start_ccb->crs;
 		dev = path->device;
 		if (dev == NULL) {
 
 			crs->ccb_h.status = CAM_DEV_NOT_THERE;
 			break;
 		}
 
 		if ((crs->release_flags & RELSIM_ADJUST_OPENINGS) != 0) {
 
 			/* Don't ever go below one opening */
 			if (crs->openings > 0) {
 				xpt_dev_ccbq_resize(path, crs->openings);
 				if (bootverbose) {
 					xpt_print(path,
 					    "number of openings is now %d\n",
 					    crs->openings);
 				}
 			}
 		}
 
 		if ((crs->release_flags & RELSIM_RELEASE_AFTER_TIMEOUT) != 0) {
 
 			if ((dev->flags & CAM_DEV_REL_TIMEOUT_PENDING) != 0) {
 
 				/*
 				 * Just extend the old timeout and decrement
 				 * the freeze count so that a single timeout
 				 * is sufficient for releasing the queue.
 				 */
 				start_ccb->ccb_h.flags &= ~CAM_DEV_QFREEZE;
 				callout_stop(&dev->callout);
 			} else {
 
 				start_ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
 			}
 
 			callout_reset(&dev->callout,
 			    (crs->release_timeout * hz) / 1000,
 			    xpt_release_devq_timeout, dev);
 
 			dev->flags |= CAM_DEV_REL_TIMEOUT_PENDING;
 
 		}
 
 		if ((crs->release_flags & RELSIM_RELEASE_AFTER_CMDCMPLT) != 0) {
 
 			if ((dev->flags & CAM_DEV_REL_ON_COMPLETE) != 0) {
 				/*
 				 * Decrement the freeze count so that a single
 				 * completion is still sufficient to unfreeze
 				 * the queue.
 				 */
 				start_ccb->ccb_h.flags &= ~CAM_DEV_QFREEZE;
 			} else {
 
 				dev->flags |= CAM_DEV_REL_ON_COMPLETE;
 				start_ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
 			}
 		}
 
 		if ((crs->release_flags & RELSIM_RELEASE_AFTER_QEMPTY) != 0) {
 
 			if ((dev->flags & CAM_DEV_REL_ON_QUEUE_EMPTY) != 0
 			 || (dev->ccbq.dev_active == 0)) {
 
 				start_ccb->ccb_h.flags &= ~CAM_DEV_QFREEZE;
 			} else {
 
 				dev->flags |= CAM_DEV_REL_ON_QUEUE_EMPTY;
 				start_ccb->ccb_h.flags |= CAM_DEV_QFREEZE;
 			}
 		}
 
 		if ((start_ccb->ccb_h.flags & CAM_DEV_QFREEZE) == 0)
 			xpt_release_devq(path, /*count*/1, /*run_queue*/TRUE);
 		start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt;
 		start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	}
 	case XPT_DEBUG: {
 		struct cam_path *oldpath;
 		struct cam_sim *oldsim;
 
 		/* Check that all request bits are supported. */
 		if (start_ccb->cdbg.flags & ~(CAM_DEBUG_COMPILE)) {
 			start_ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
 			break;
 		}
 
 		cam_dflags = CAM_DEBUG_NONE;
 		if (cam_dpath != NULL) {
 			/* To release the old path we must hold proper lock. */
 			oldpath = cam_dpath;
 			cam_dpath = NULL;
 			oldsim = xpt_path_sim(oldpath);
 			CAM_SIM_UNLOCK(xpt_path_sim(start_ccb->ccb_h.path));
 			CAM_SIM_LOCK(oldsim);
 			xpt_free_path(oldpath);
 			CAM_SIM_UNLOCK(oldsim);
 			CAM_SIM_LOCK(xpt_path_sim(start_ccb->ccb_h.path));
 		}
 		if (start_ccb->cdbg.flags != CAM_DEBUG_NONE) {
 			if (xpt_create_path(&cam_dpath, NULL,
 					    start_ccb->ccb_h.path_id,
 					    start_ccb->ccb_h.target_id,
 					    start_ccb->ccb_h.target_lun) !=
 					    CAM_REQ_CMP) {
 				start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
 			} else {
 				cam_dflags = start_ccb->cdbg.flags;
 				start_ccb->ccb_h.status = CAM_REQ_CMP;
 				xpt_print(cam_dpath, "debugging flags now %x\n",
 				    cam_dflags);
 			}
 		} else
 			start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	}
 	case XPT_NOOP:
 		if ((start_ccb->ccb_h.flags & CAM_DEV_QFREEZE) != 0)
 			xpt_freeze_devq(path, 1);
 		start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
 	default:
 	case XPT_SDEV_TYPE:
 	case XPT_TERM_IO:
 	case XPT_ENG_INQ:
 		/* XXX Implement */
 		printf("%s: CCB type %#x not supported\n", __func__,
 		       start_ccb->ccb_h.func_code);
 		start_ccb->ccb_h.status = CAM_PROVIDE_FAIL;
 		if (start_ccb->ccb_h.func_code & XPT_FC_DEV_QUEUED) {
 			xpt_done(start_ccb);
 		}
 		break;
 	}
 }
 
 void
 xpt_polled_action(union ccb *start_ccb)
 {
 	u_int32_t timeout;
 	struct	  cam_sim *sim;
 	struct	  cam_devq *devq;
 	struct	  cam_ed *dev;
 
 
 	timeout = start_ccb->ccb_h.timeout * 10;
 	sim = start_ccb->ccb_h.path->bus->sim;
 	devq = sim->devq;
 	dev = start_ccb->ccb_h.path->device;
 
 	mtx_assert(sim->mtx, MA_OWNED);
 
 	/* Don't use ISR for this SIM while polling. */
 	sim->flags |= CAM_SIM_POLLED;
 
 	/*
 	 * Steal an opening so that no other queued requests
 	 * can get it before us while we simulate interrupts.
 	 */
 	dev->ccbq.devq_openings--;
 	dev->ccbq.dev_openings--;
 
 	while(((devq != NULL && devq->send_openings <= 0) ||
 	   dev->ccbq.dev_openings < 0) && (--timeout > 0)) {
 		DELAY(100);
 		(*(sim->sim_poll))(sim);
 		camisr_runqueue(&sim->sim_doneq);
 	}
 
 	dev->ccbq.devq_openings++;
 	dev->ccbq.dev_openings++;
 
 	if (timeout != 0) {
 		xpt_action(start_ccb);
 		while(--timeout > 0) {
 			(*(sim->sim_poll))(sim);
 			camisr_runqueue(&sim->sim_doneq);
 			if ((start_ccb->ccb_h.status  & CAM_STATUS_MASK)
 			    != CAM_REQ_INPROG)
 				break;
 			DELAY(100);
 		}
 		if (timeout == 0) {
 			/*
 			 * XXX Is it worth adding a sim_timeout entry
 			 * point so we can attempt recovery?  If
 			 * this is only used for dumps, I don't think
 			 * it is.
 			 */
 			start_ccb->ccb_h.status = CAM_CMD_TIMEOUT;
 		}
 	} else {
 		start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
 	}
 
 	/* We will use CAM ISR for this SIM again. */
 	sim->flags &= ~CAM_SIM_POLLED;
 }
 
 /*
  * Schedule a peripheral driver to receive a ccb when it's
  * target device has space for more transactions.
  */
 void
 xpt_schedule(struct cam_periph *perph, u_int32_t new_priority)
 {
 	struct cam_ed *device;
 	int runq = 0;
 
 	mtx_assert(perph->sim->mtx, MA_OWNED);
 
 	CAM_DEBUG(perph->path, CAM_DEBUG_TRACE, ("xpt_schedule\n"));
 	device = perph->path->device;
 	if (periph_is_queued(perph)) {
 		/* Simply reorder based on new priority */
 		CAM_DEBUG(perph->path, CAM_DEBUG_SUBTRACE,
 			  ("   change priority to %d\n", new_priority));
 		if (new_priority < perph->pinfo.priority) {
 			camq_change_priority(&device->drvq,
 					     perph->pinfo.index,
 					     new_priority);
 			runq = 1;
 		}
 	} else {
 		/* New entry on the queue */
 		CAM_DEBUG(perph->path, CAM_DEBUG_SUBTRACE,
 			  ("   added periph to queue\n"));
 		perph->pinfo.priority = new_priority;
 		perph->pinfo.generation = ++device->drvq.generation;
 		camq_insert(&device->drvq, &perph->pinfo);
 		runq = 1;
 	}
 	if (runq != 0) {
 		CAM_DEBUG(perph->path, CAM_DEBUG_SUBTRACE,
 			  ("   calling xpt_run_dev_allocq\n"));
 		xpt_run_dev_allocq(device);
 	}
 }
 
 
 /*
  * Schedule a device to run on a given queue.
  * If the device was inserted as a new entry on the queue,
  * return 1 meaning the device queue should be run. If we
  * were already queued, implying someone else has already
  * started the queue, return 0 so the caller doesn't attempt
  * to run the queue.
  */
 int
 xpt_schedule_dev(struct camq *queue, cam_pinfo *pinfo,
 		 u_int32_t new_priority)
 {
 	int retval;
 	u_int32_t old_priority;
 
 	CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_schedule_dev\n"));
 
 	old_priority = pinfo->priority;
 
 	/*
 	 * Are we already queued?
 	 */
 	if (pinfo->index != CAM_UNQUEUED_INDEX) {
 		/* Simply reorder based on new priority */
 		if (new_priority < old_priority) {
 			camq_change_priority(queue, pinfo->index,
 					     new_priority);
 			CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 					("changed priority to %d\n",
 					 new_priority));
 			retval = 1;
 		} else
 			retval = 0;
 	} else {
 		/* New entry on the queue */
 		if (new_priority < old_priority)
 			pinfo->priority = new_priority;
 
 		CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 				("Inserting onto queue\n"));
 		pinfo->generation = ++queue->generation;
 		camq_insert(queue, pinfo);
 		retval = 1;
 	}
 	return (retval);
 }
 
 static void
 xpt_run_dev_allocq(struct cam_ed *device)
 {
 	struct camq	*drvq;
 
 	if (device->ccbq.devq_allocating)
 		return;
 	device->ccbq.devq_allocating = 1;
 	CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_dev_allocq(%p)\n", device));
 	drvq = &device->drvq;
 	while ((drvq->entries > 0) &&
 	    (device->ccbq.devq_openings > 0 ||
 	     CAMQ_GET_PRIO(drvq) <= CAM_PRIORITY_OOB) &&
 	    (device->ccbq.queue.qfrozen_cnt == 0)) {
 		union	ccb *work_ccb;
 		struct	cam_periph *drv;
 
 		KASSERT(drvq->entries > 0, ("xpt_run_dev_allocq: "
 		    "Device on queue without any work to do"));
 		if ((work_ccb = xpt_get_ccb(device)) != NULL) {
 			drv = (struct cam_periph*)camq_remove(drvq, CAMQ_HEAD);
 			xpt_setup_ccb(&work_ccb->ccb_h, drv->path,
 				      drv->pinfo.priority);
 			CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 					("calling periph start\n"));
 			drv->periph_start(drv, work_ccb);
 		} else {
 			/*
 			 * Malloc failure in alloc_ccb
 			 */
 			/*
 			 * XXX add us to a list to be run from free_ccb
 			 * if we don't have any ccbs active on this
 			 * device queue otherwise we may never get run
 			 * again.
 			 */
 			break;
 		}
 	}
 	device->ccbq.devq_allocating = 0;
 }
 
 static void
 xpt_run_devq(struct cam_devq *devq)
 {
 	char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1];
 
 	CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_devq\n"));
 
 	devq->send_queue.qfrozen_cnt++;
 	while ((devq->send_queue.entries > 0)
 	    && (devq->send_openings > 0)
 	    && (devq->send_queue.qfrozen_cnt <= 1)) {
 		struct	cam_ed_qinfo *qinfo;
 		struct	cam_ed *device;
 		union ccb *work_ccb;
 		struct	cam_sim *sim;
 
 		qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->send_queue,
 							   CAMQ_HEAD);
 		device = qinfo->device;
 		CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 				("running device %p\n", device));
 
 		work_ccb = cam_ccbq_peek_ccb(&device->ccbq, CAMQ_HEAD);
 		if (work_ccb == NULL) {
 			printf("device on run queue with no ccbs???\n");
 			continue;
 		}
 
 		if ((work_ccb->ccb_h.flags & CAM_HIGH_POWER) != 0) {
 
 			mtx_lock(&xsoftc.xpt_lock);
 		 	if (xsoftc.num_highpower <= 0) {
 				/*
 				 * We got a high power command, but we
 				 * don't have any available slots.  Freeze
 				 * the device queue until we have a slot
 				 * available.
 				 */
 				xpt_freeze_devq(work_ccb->ccb_h.path, 1);
 				STAILQ_INSERT_TAIL(&xsoftc.highpowerq,
 						   &work_ccb->ccb_h,
 						   xpt_links.stqe);
 
 				mtx_unlock(&xsoftc.xpt_lock);
 				continue;
 			} else {
 				/*
 				 * Consume a high power slot while
 				 * this ccb runs.
 				 */
 				xsoftc.num_highpower--;
 			}
 			mtx_unlock(&xsoftc.xpt_lock);
 		}
 		cam_ccbq_remove_ccb(&device->ccbq, work_ccb);
 		cam_ccbq_send_ccb(&device->ccbq, work_ccb);
 
 		devq->send_openings--;
 		devq->send_active++;
 
 		xpt_schedule_devq(devq, device);
 
 		if ((work_ccb->ccb_h.flags & CAM_DEV_QFREEZE) != 0) {
 			/*
 			 * The client wants to freeze the queue
 			 * after this CCB is sent.
 			 */
 			xpt_freeze_devq(work_ccb->ccb_h.path, 1);
 		}
 
 		/* In Target mode, the peripheral driver knows best... */
 		if (work_ccb->ccb_h.func_code == XPT_SCSI_IO) {
 			if ((device->inq_flags & SID_CmdQue) != 0
 			 && work_ccb->csio.tag_action != CAM_TAG_ACTION_NONE)
 				work_ccb->ccb_h.flags |= CAM_TAG_ACTION_VALID;
 			else
 				/*
 				 * Clear this in case of a retried CCB that
 				 * failed due to a rejected tag.
 				 */
 				work_ccb->ccb_h.flags &= ~CAM_TAG_ACTION_VALID;
 		}
 
 		switch (work_ccb->ccb_h.func_code) {
 		case XPT_SCSI_IO:
 			CAM_DEBUG(work_ccb->ccb_h.path,
 			    CAM_DEBUG_CDB,("%s. CDB: %s\n",
 			     scsi_op_desc(work_ccb->csio.cdb_io.cdb_bytes[0],
 					  &device->inq_data),
 			     scsi_cdb_string(work_ccb->csio.cdb_io.cdb_bytes,
 					     cdb_str, sizeof(cdb_str))));
 			break;
 		case XPT_ATA_IO:
 			CAM_DEBUG(work_ccb->ccb_h.path,
 			    CAM_DEBUG_CDB,("%s. ACB: %s\n",
 			     ata_op_string(&work_ccb->ataio.cmd),
 			     ata_cmd_string(&work_ccb->ataio.cmd,
 					    cdb_str, sizeof(cdb_str))));
 			break;
 		default:
 			break;
 		}
 
 		/*
 		 * Device queues can be shared among multiple sim instances
 		 * that reside on different busses.  Use the SIM in the queue
 		 * CCB's path, rather than the one in the bus that was passed
 		 * into this function.
 		 */
 		sim = work_ccb->ccb_h.path->bus->sim;
 		(*(sim->sim_action))(sim, work_ccb);
 	}
 	devq->send_queue.qfrozen_cnt--;
 }
 
 /*
  * This function merges stuff from the slave ccb into the master ccb, while
  * keeping important fields in the master ccb constant.
  */
 void
 xpt_merge_ccb(union ccb *master_ccb, union ccb *slave_ccb)
 {
 
 	/*
 	 * Pull fields that are valid for peripheral drivers to set
 	 * into the master CCB along with the CCB "payload".
 	 */
 	master_ccb->ccb_h.retry_count = slave_ccb->ccb_h.retry_count;
 	master_ccb->ccb_h.func_code = slave_ccb->ccb_h.func_code;
 	master_ccb->ccb_h.timeout = slave_ccb->ccb_h.timeout;
 	master_ccb->ccb_h.flags = slave_ccb->ccb_h.flags;
 	bcopy(&(&slave_ccb->ccb_h)[1], &(&master_ccb->ccb_h)[1],
 	      sizeof(union ccb) - sizeof(struct ccb_hdr));
 }
 
 void
 xpt_setup_ccb(struct ccb_hdr *ccb_h, struct cam_path *path, u_int32_t priority)
 {
 
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_setup_ccb\n"));
 	ccb_h->pinfo.priority = priority;
 	ccb_h->path = path;
 	ccb_h->path_id = path->bus->path_id;
 	if (path->target)
 		ccb_h->target_id = path->target->target_id;
 	else
 		ccb_h->target_id = CAM_TARGET_WILDCARD;
 	if (path->device) {
 		ccb_h->target_lun = path->device->lun_id;
 		ccb_h->pinfo.generation = ++path->device->ccbq.queue.generation;
 	} else {
 		ccb_h->target_lun = CAM_TARGET_WILDCARD;
 	}
 	ccb_h->pinfo.index = CAM_UNQUEUED_INDEX;
 	ccb_h->flags = 0;
 }
 
 /* Path manipulation functions */
 cam_status
 xpt_create_path(struct cam_path **new_path_ptr, struct cam_periph *perph,
 		path_id_t path_id, target_id_t target_id, lun_id_t lun_id)
 {
 	struct	   cam_path *path;
 	cam_status status;
 
 	path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT);
 
 	if (path == NULL) {
 		status = CAM_RESRC_UNAVAIL;
 		return(status);
 	}
 	status = xpt_compile_path(path, perph, path_id, target_id, lun_id);
 	if (status != CAM_REQ_CMP) {
 		free(path, M_CAMPATH);
 		path = NULL;
 	}
 	*new_path_ptr = path;
 	return (status);
 }
 
 cam_status
 xpt_create_path_unlocked(struct cam_path **new_path_ptr,
 			 struct cam_periph *periph, path_id_t path_id,
 			 target_id_t target_id, lun_id_t lun_id)
 {
 	struct	   cam_path *path;
 	struct	   cam_eb *bus = NULL;
 	cam_status status;
 
 	path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_WAITOK);
 
 	bus = xpt_find_bus(path_id);
 	if (bus != NULL)
 		CAM_SIM_LOCK(bus->sim);
 	status = xpt_compile_path(path, periph, path_id, target_id, lun_id);
 	if (bus != NULL) {
 		CAM_SIM_UNLOCK(bus->sim);
 		xpt_release_bus(bus);
 	}
 	if (status != CAM_REQ_CMP) {
 		free(path, M_CAMPATH);
 		path = NULL;
 	}
 	*new_path_ptr = path;
 	return (status);
 }
 
 cam_status
 xpt_compile_path(struct cam_path *new_path, struct cam_periph *perph,
 		 path_id_t path_id, target_id_t target_id, lun_id_t lun_id)
 {
 	struct	     cam_eb *bus;
 	struct	     cam_et *target;
 	struct	     cam_ed *device;
 	cam_status   status;
 
 	status = CAM_REQ_CMP;	/* Completed without error */
 	target = NULL;		/* Wildcarded */
 	device = NULL;		/* Wildcarded */
 
 	/*
 	 * We will potentially modify the EDT, so block interrupts
 	 * that may attempt to create cam paths.
 	 */
 	bus = xpt_find_bus(path_id);
 	if (bus == NULL) {
 		status = CAM_PATH_INVALID;
 	} else {
 		target = xpt_find_target(bus, target_id);
 		if (target == NULL) {
 			/* Create one */
 			struct cam_et *new_target;
 
 			new_target = xpt_alloc_target(bus, target_id);
 			if (new_target == NULL) {
 				status = CAM_RESRC_UNAVAIL;
 			} else {
 				target = new_target;
 			}
 		}
 		if (target != NULL) {
 			device = xpt_find_device(target, lun_id);
 			if (device == NULL) {
 				/* Create one */
 				struct cam_ed *new_device;
 
 				new_device =
 				    (*(bus->xport->alloc_device))(bus,
 								      target,
 								      lun_id);
 				if (new_device == NULL) {
 					status = CAM_RESRC_UNAVAIL;
 				} else {
 					device = new_device;
 				}
 			}
 		}
 	}
 
 	/*
 	 * Only touch the user's data if we are successful.
 	 */
 	if (status == CAM_REQ_CMP) {
 		new_path->periph = perph;
 		new_path->bus = bus;
 		new_path->target = target;
 		new_path->device = device;
 		CAM_DEBUG(new_path, CAM_DEBUG_TRACE, ("xpt_compile_path\n"));
 	} else {
 		if (device != NULL)
 			xpt_release_device(device);
 		if (target != NULL)
 			xpt_release_target(target);
 		if (bus != NULL)
 			xpt_release_bus(bus);
 	}
 	return (status);
 }
 
 void
 xpt_release_path(struct cam_path *path)
 {
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_release_path\n"));
 	if (path->device != NULL) {
 		xpt_release_device(path->device);
 		path->device = NULL;
 	}
 	if (path->target != NULL) {
 		xpt_release_target(path->target);
 		path->target = NULL;
 	}
 	if (path->bus != NULL) {
 		xpt_release_bus(path->bus);
 		path->bus = NULL;
 	}
 }
 
 void
 xpt_free_path(struct cam_path *path)
 {
 
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_free_path\n"));
 	xpt_release_path(path);
 	free(path, M_CAMPATH);
 }
 
 void
 xpt_path_counts(struct cam_path *path, uint32_t *bus_ref,
     uint32_t *periph_ref, uint32_t *target_ref, uint32_t *device_ref)
 {
 
 	xpt_lock_buses();
 	if (bus_ref) {
 		if (path->bus)
 			*bus_ref = path->bus->refcount;
 		else
 			*bus_ref = 0;
 	}
 	if (periph_ref) {
 		if (path->periph)
 			*periph_ref = path->periph->refcount;
 		else
 			*periph_ref = 0;
 	}
 	xpt_unlock_buses();
 	if (target_ref) {
 		if (path->target)
 			*target_ref = path->target->refcount;
 		else
 			*target_ref = 0;
 	}
 	if (device_ref) {
 		if (path->device)
 			*device_ref = path->device->refcount;
 		else
 			*device_ref = 0;
 	}
 }
 
 /*
  * Return -1 for failure, 0 for exact match, 1 for match with wildcards
  * in path1, 2 for match with wildcards in path2.
  */
 int
 xpt_path_comp(struct cam_path *path1, struct cam_path *path2)
 {
 	int retval = 0;
 
 	if (path1->bus != path2->bus) {
 		if (path1->bus->path_id == CAM_BUS_WILDCARD)
 			retval = 1;
 		else if (path2->bus->path_id == CAM_BUS_WILDCARD)
 			retval = 2;
 		else
 			return (-1);
 	}
 	if (path1->target != path2->target) {
 		if (path1->target->target_id == CAM_TARGET_WILDCARD) {
 			if (retval == 0)
 				retval = 1;
 		} else if (path2->target->target_id == CAM_TARGET_WILDCARD)
 			retval = 2;
 		else
 			return (-1);
 	}
 	if (path1->device != path2->device) {
 		if (path1->device->lun_id == CAM_LUN_WILDCARD) {
 			if (retval == 0)
 				retval = 1;
 		} else if (path2->device->lun_id == CAM_LUN_WILDCARD)
 			retval = 2;
 		else
 			return (-1);
 	}
 	return (retval);
 }
 
 void
 xpt_print_path(struct cam_path *path)
 {
 
 	if (path == NULL)
 		printf("(nopath): ");
 	else {
 		if (path->periph != NULL)
 			printf("(%s%d:", path->periph->periph_name,
 			       path->periph->unit_number);
 		else
 			printf("(noperiph:");
 
 		if (path->bus != NULL)
 			printf("%s%d:%d:", path->bus->sim->sim_name,
 			       path->bus->sim->unit_number,
 			       path->bus->sim->bus_id);
 		else
 			printf("nobus:");
 
 		if (path->target != NULL)
 			printf("%d:", path->target->target_id);
 		else
 			printf("X:");
 
 		if (path->device != NULL)
 			printf("%d): ", path->device->lun_id);
 		else
 			printf("X): ");
 	}
 }
 
 void
 xpt_print(struct cam_path *path, const char *fmt, ...)
 {
 	va_list ap;
 	xpt_print_path(path);
 	va_start(ap, fmt);
 	vprintf(fmt, ap);
 	va_end(ap);
 }
 
 int
 xpt_path_string(struct cam_path *path, char *str, size_t str_len)
 {
 	struct sbuf sb;
 
 #ifdef INVARIANTS
 	if (path != NULL && path->bus != NULL)
 		mtx_assert(path->bus->sim->mtx, MA_OWNED);
 #endif
 
 	sbuf_new(&sb, str, str_len, 0);
 
 	if (path == NULL)
 		sbuf_printf(&sb, "(nopath): ");
 	else {
 		if (path->periph != NULL)
 			sbuf_printf(&sb, "(%s%d:", path->periph->periph_name,
 				    path->periph->unit_number);
 		else
 			sbuf_printf(&sb, "(noperiph:");
 
 		if (path->bus != NULL)
 			sbuf_printf(&sb, "%s%d:%d:", path->bus->sim->sim_name,
 				    path->bus->sim->unit_number,
 				    path->bus->sim->bus_id);
 		else
 			sbuf_printf(&sb, "nobus:");
 
 		if (path->target != NULL)
 			sbuf_printf(&sb, "%d:", path->target->target_id);
 		else
 			sbuf_printf(&sb, "X:");
 
 		if (path->device != NULL)
 			sbuf_printf(&sb, "%d): ", path->device->lun_id);
 		else
 			sbuf_printf(&sb, "X): ");
 	}
 	sbuf_finish(&sb);
 
 	return(sbuf_len(&sb));
 }
 
 path_id_t
 xpt_path_path_id(struct cam_path *path)
 {
 	return(path->bus->path_id);
 }
 
 target_id_t
 xpt_path_target_id(struct cam_path *path)
 {
 	if (path->target != NULL)
 		return (path->target->target_id);
 	else
 		return (CAM_TARGET_WILDCARD);
 }
 
 lun_id_t
 xpt_path_lun_id(struct cam_path *path)
 {
 	if (path->device != NULL)
 		return (path->device->lun_id);
 	else
 		return (CAM_LUN_WILDCARD);
 }
 
 struct cam_sim *
 xpt_path_sim(struct cam_path *path)
 {
 
 	return (path->bus->sim);
 }
 
 struct cam_periph*
 xpt_path_periph(struct cam_path *path)
 {
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
 
 	return (path->periph);
 }
 
 int
 xpt_path_legacy_ata_id(struct cam_path *path)
 {
 	struct cam_eb *bus;
 	int bus_id;
 
 	if ((strcmp(path->bus->sim->sim_name, "ata") != 0) &&
 	    strcmp(path->bus->sim->sim_name, "ahcich") != 0 &&
 	    strcmp(path->bus->sim->sim_name, "mvsch") != 0 &&
 	    strcmp(path->bus->sim->sim_name, "siisch") != 0)
 		return (-1);
 
 	if (strcmp(path->bus->sim->sim_name, "ata") == 0 &&
 	    path->bus->sim->unit_number < 2) {
 		bus_id = path->bus->sim->unit_number;
 	} else {
 		bus_id = 2;
 		xpt_lock_buses();
 		TAILQ_FOREACH(bus, &xsoftc.xpt_busses, links) {
 			if (bus == path->bus)
 				break;
 			if ((strcmp(bus->sim->sim_name, "ata") == 0 &&
 			     bus->sim->unit_number >= 2) ||
 			    strcmp(bus->sim->sim_name, "ahcich") == 0 ||
 			    strcmp(bus->sim->sim_name, "mvsch") == 0 ||
 			    strcmp(bus->sim->sim_name, "siisch") == 0)
 				bus_id++;
 		}
 		xpt_unlock_buses();
 	}
 	if (path->target != NULL) {
 		if (path->target->target_id < 2)
 			return (bus_id * 2 + path->target->target_id);
 		else
 			return (-1);
 	} else
 		return (bus_id * 2);
 }
 
 /*
  * Release a CAM control block for the caller.  Remit the cost of the structure
  * to the device referenced by the path.  If the this device had no 'credits'
  * and peripheral drivers have registered async callbacks for this notification
  * call them now.
  */
 void
 xpt_release_ccb(union ccb *free_ccb)
 {
 	struct	 cam_path *path;
 	struct	 cam_ed *device;
 	struct	 cam_eb *bus;
 	struct   cam_sim *sim;
 
 	CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_release_ccb\n"));
 	path = free_ccb->ccb_h.path;
 	device = path->device;
 	bus = path->bus;
 	sim = bus->sim;
 
 	mtx_assert(sim->mtx, MA_OWNED);
 
 	cam_ccbq_release_opening(&device->ccbq);
 	if (device->flags & CAM_DEV_RESIZE_QUEUE_NEEDED) {
 		device->flags &= ~CAM_DEV_RESIZE_QUEUE_NEEDED;
 		cam_ccbq_resize(&device->ccbq,
 		    device->ccbq.dev_openings + device->ccbq.dev_active);
 	}
 	if (sim->ccb_count > sim->max_ccbs) {
 		xpt_free_ccb(free_ccb);
 		sim->ccb_count--;
 	} else {
 		SLIST_INSERT_HEAD(&sim->ccb_freeq, &free_ccb->ccb_h,
 		    xpt_links.sle);
 	}
 	xpt_run_dev_allocq(device);
 }
 
 /* Functions accessed by SIM drivers */
 
 static struct xpt_xport xport_default = {
 	.alloc_device = xpt_alloc_device_default,
 	.action = xpt_action_default,
 	.async = xpt_dev_async_default,
 };
 
 /*
  * A sim structure, listing the SIM entry points and instance
  * identification info is passed to xpt_bus_register to hook the SIM
  * into the CAM framework.  xpt_bus_register creates a cam_eb entry
  * for this new bus and places it in the array of busses and assigns
  * it a path_id.  The path_id may be influenced by "hard wiring"
  * information specified by the user.  Once interrupt services are
  * available, the bus will be probed.
  */
 int32_t
 xpt_bus_register(struct cam_sim *sim, device_t parent, u_int32_t bus)
 {
 	struct cam_eb *new_bus;
 	struct cam_eb *old_bus;
 	struct ccb_pathinq cpi;
 	struct cam_path *path;
 	cam_status status;
 
 	mtx_assert(sim->mtx, MA_OWNED);
 
 	sim->bus_id = bus;
 	new_bus = (struct cam_eb *)malloc(sizeof(*new_bus),
 					  M_CAMXPT, M_NOWAIT);
 	if (new_bus == NULL) {
 		/* Couldn't satisfy request */
 		return (CAM_RESRC_UNAVAIL);
 	}
 	if (strcmp(sim->sim_name, "xpt") != 0) {
 		sim->path_id =
 		    xptpathid(sim->sim_name, sim->unit_number, sim->bus_id);
 	}
 
 	TAILQ_INIT(&new_bus->et_entries);
 	new_bus->path_id = sim->path_id;
 	cam_sim_hold(sim);
 	new_bus->sim = sim;
 	timevalclear(&new_bus->last_reset);
 	new_bus->flags = 0;
 	new_bus->refcount = 1;	/* Held until a bus_deregister event */
 	new_bus->generation = 0;
 
 	xpt_lock_buses();
 	old_bus = TAILQ_FIRST(&xsoftc.xpt_busses);
 	while (old_bus != NULL
 	    && old_bus->path_id < new_bus->path_id)
 		old_bus = TAILQ_NEXT(old_bus, links);
 	if (old_bus != NULL)
 		TAILQ_INSERT_BEFORE(old_bus, new_bus, links);
 	else
 		TAILQ_INSERT_TAIL(&xsoftc.xpt_busses, new_bus, links);
 	xsoftc.bus_generation++;
 	xpt_unlock_buses();
 
 	/*
 	 * Set a default transport so that a PATH_INQ can be issued to
 	 * the SIM.  This will then allow for probing and attaching of
 	 * a more appropriate transport.
 	 */
 	new_bus->xport = &xport_default;
 
 	status = xpt_create_path(&path, /*periph*/NULL, sim->path_id,
 				  CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 	if (status != CAM_REQ_CMP) {
 		xpt_release_bus(new_bus);
 		free(path, M_CAMXPT);
 		return (CAM_RESRC_UNAVAIL);
 	}
 
 	xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL);
 	cpi.ccb_h.func_code = XPT_PATH_INQ;
 	xpt_action((union ccb *)&cpi);
 
 	if (cpi.ccb_h.status == CAM_REQ_CMP) {
 		switch (cpi.transport) {
 		case XPORT_SPI:
 		case XPORT_SAS:
 		case XPORT_FC:
 		case XPORT_USB:
 		case XPORT_ISCSI:
 		case XPORT_PPB:
 			new_bus->xport = scsi_get_xport();
 			break;
 		case XPORT_ATA:
 		case XPORT_SATA:
 			new_bus->xport = ata_get_xport();
 			break;
 		default:
 			new_bus->xport = &xport_default;
 			break;
 		}
 	}
 
 	/* Notify interested parties */
 	if (sim->path_id != CAM_XPT_PATH_ID) {
 		union	ccb *scan_ccb;
 
 		xpt_async(AC_PATH_REGISTERED, path, &cpi);
 		/* Initiate bus rescan. */
 		scan_ccb = xpt_alloc_ccb_nowait();
 		scan_ccb->ccb_h.path = path;
 		scan_ccb->ccb_h.func_code = XPT_SCAN_BUS;
 		scan_ccb->crcn.flags = 0;
 		xpt_rescan(scan_ccb);
 	} else
 		xpt_free_path(path);
 	return (CAM_SUCCESS);
 }
 
 int32_t
 xpt_bus_deregister(path_id_t pathid)
 {
 	struct cam_path bus_path;
 	cam_status status;
 
 	status = xpt_compile_path(&bus_path, NULL, pathid,
 				  CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 	if (status != CAM_REQ_CMP)
 		return (status);
 
 	xpt_async(AC_LOST_DEVICE, &bus_path, NULL);
 	xpt_async(AC_PATH_DEREGISTERED, &bus_path, NULL);
 
 	/* Release the reference count held while registered. */
 	xpt_release_bus(bus_path.bus);
 	xpt_release_path(&bus_path);
 
 	return (CAM_REQ_CMP);
 }
 
 static path_id_t
 xptnextfreepathid(void)
 {
 	struct cam_eb *bus;
 	path_id_t pathid;
 	const char *strval;
 
 	pathid = 0;
 	xpt_lock_buses();
 	bus = TAILQ_FIRST(&xsoftc.xpt_busses);
 retry:
 	/* Find an unoccupied pathid */
 	while (bus != NULL && bus->path_id <= pathid) {
 		if (bus->path_id == pathid)
 			pathid++;
 		bus = TAILQ_NEXT(bus, links);
 	}
 	xpt_unlock_buses();
 
 	/*
 	 * Ensure that this pathid is not reserved for
 	 * a bus that may be registered in the future.
 	 */
 	if (resource_string_value("scbus", pathid, "at", &strval) == 0) {
 		++pathid;
 		/* Start the search over */
 		xpt_lock_buses();
 		goto retry;
 	}
 	return (pathid);
 }
 
 static path_id_t
 xptpathid(const char *sim_name, int sim_unit, int sim_bus)
 {
 	path_id_t pathid;
 	int i, dunit, val;
 	char buf[32];
 	const char *dname;
 
 	pathid = CAM_XPT_PATH_ID;
 	snprintf(buf, sizeof(buf), "%s%d", sim_name, sim_unit);
 	i = 0;
 	while ((resource_find_match(&i, &dname, &dunit, "at", buf)) == 0) {
 		if (strcmp(dname, "scbus")) {
 			/* Avoid a bit of foot shooting. */
 			continue;
 		}
 		if (dunit < 0)		/* unwired?! */
 			continue;
 		if (resource_int_value("scbus", dunit, "bus", &val) == 0) {
 			if (sim_bus == val) {
 				pathid = dunit;
 				break;
 			}
 		} else if (sim_bus == 0) {
 			/* Unspecified matches bus 0 */
 			pathid = dunit;
 			break;
 		} else {
 			printf("Ambiguous scbus configuration for %s%d "
 			       "bus %d, cannot wire down.  The kernel "
 			       "config entry for scbus%d should "
 			       "specify a controller bus.\n"
 			       "Scbus will be assigned dynamically.\n",
 			       sim_name, sim_unit, sim_bus, dunit);
 			break;
 		}
 	}
 
 	if (pathid == CAM_XPT_PATH_ID)
 		pathid = xptnextfreepathid();
 	return (pathid);
 }
 
 static const char *
 xpt_async_string(u_int32_t async_code)
 {
 
 	switch (async_code) {
 	case AC_BUS_RESET: return ("AC_BUS_RESET");
 	case AC_UNSOL_RESEL: return ("AC_UNSOL_RESEL");
 	case AC_SCSI_AEN: return ("AC_SCSI_AEN");
 	case AC_SENT_BDR: return ("AC_SENT_BDR");
 	case AC_PATH_REGISTERED: return ("AC_PATH_REGISTERED");
 	case AC_PATH_DEREGISTERED: return ("AC_PATH_DEREGISTERED");
 	case AC_FOUND_DEVICE: return ("AC_FOUND_DEVICE");
 	case AC_LOST_DEVICE: return ("AC_LOST_DEVICE");
 	case AC_TRANSFER_NEG: return ("AC_TRANSFER_NEG");
 	case AC_INQ_CHANGED: return ("AC_INQ_CHANGED");
 	case AC_GETDEV_CHANGED: return ("AC_GETDEV_CHANGED");
 	case AC_CONTRACT: return ("AC_CONTRACT");
 	case AC_ADVINFO_CHANGED: return ("AC_ADVINFO_CHANGED");
 	case AC_UNIT_ATTENTION: return ("AC_UNIT_ATTENTION");
 	}
 	return ("AC_UNKNOWN");
 }
 
 void
 xpt_async(u_int32_t async_code, struct cam_path *path, void *async_arg)
 {
 	struct cam_eb *bus;
 	struct cam_et *target, *next_target;
 	struct cam_ed *device, *next_device;
 
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
 	CAM_DEBUG(path, CAM_DEBUG_TRACE | CAM_DEBUG_INFO,
 	    ("xpt_async(%s)\n", xpt_async_string(async_code)));
 
 	/*
 	 * Most async events come from a CAM interrupt context.  In
 	 * a few cases, the error recovery code at the peripheral layer,
 	 * which may run from our SWI or a process context, may signal
 	 * deferred events with a call to xpt_async.
 	 */
 
 	bus = path->bus;
 
 	if (async_code == AC_BUS_RESET) {
 		/* Update our notion of when the last reset occurred */
 		microtime(&bus->last_reset);
 	}
 
 	for (target = TAILQ_FIRST(&bus->et_entries);
 	     target != NULL;
 	     target = next_target) {
 
 		next_target = TAILQ_NEXT(target, links);
 
 		if (path->target != target
 		 && path->target->target_id != CAM_TARGET_WILDCARD
 		 && target->target_id != CAM_TARGET_WILDCARD)
 			continue;
 
 		if (async_code == AC_SENT_BDR) {
 			/* Update our notion of when the last reset occurred */
 			microtime(&path->target->last_reset);
 		}
 
 		for (device = TAILQ_FIRST(&target->ed_entries);
 		     device != NULL;
 		     device = next_device) {
 
 			next_device = TAILQ_NEXT(device, links);
 
 			if (path->device != device
 			 && path->device->lun_id != CAM_LUN_WILDCARD
 			 && device->lun_id != CAM_LUN_WILDCARD)
 				continue;
 			/*
 			 * The async callback could free the device.
 			 * If it is a broadcast async, it doesn't hold
 			 * device reference, so take our own reference.
 			 */
 			xpt_acquire_device(device);
 			(*(bus->xport->async))(async_code, bus,
 					       target, device,
 					       async_arg);
 
 			xpt_async_bcast(&device->asyncs, async_code,
 					path, async_arg);
 			xpt_release_device(device);
 		}
 	}
 
 	/*
 	 * If this wasn't a fully wildcarded async, tell all
 	 * clients that want all async events.
 	 */
 	if (bus != xpt_periph->path->bus)
 		xpt_async_bcast(&xpt_periph->path->device->asyncs, async_code,
 				path, async_arg);
 }
 
 static void
 xpt_async_bcast(struct async_list *async_head,
 		u_int32_t async_code,
 		struct cam_path *path, void *async_arg)
 {
 	struct async_node *cur_entry;
 
 	cur_entry = SLIST_FIRST(async_head);
 	while (cur_entry != NULL) {
 		struct async_node *next_entry;
 		/*
 		 * Grab the next list entry before we call the current
 		 * entry's callback.  This is because the callback function
 		 * can delete its async callback entry.
 		 */
 		next_entry = SLIST_NEXT(cur_entry, links);
 		if ((cur_entry->event_enable & async_code) != 0)
 			cur_entry->callback(cur_entry->callback_arg,
 					    async_code, path,
 					    async_arg);
 		cur_entry = next_entry;
 	}
 }
 
 static void
 xpt_dev_async_default(u_int32_t async_code, struct cam_eb *bus,
 		      struct cam_et *target, struct cam_ed *device,
 		      void *async_arg)
 {
 	printf("%s called\n", __func__);
 }
 
 u_int32_t
 xpt_freeze_devq(struct cam_path *path, u_int count)
 {
 	struct cam_ed *dev = path->device;
 
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
 	dev->ccbq.queue.qfrozen_cnt += count;
 	/* Remove frozen device from sendq. */
 	if (device_is_queued(dev)) {
 		camq_remove(&dev->sim->devq->send_queue,
 		    dev->devq_entry.pinfo.index);
 	}
 	return (dev->ccbq.queue.qfrozen_cnt);
 }
 
 u_int32_t
 xpt_freeze_simq(struct cam_sim *sim, u_int count)
 {
 
 	mtx_assert(sim->mtx, MA_OWNED);
 	sim->devq->send_queue.qfrozen_cnt += count;
 	return (sim->devq->send_queue.qfrozen_cnt);
 }
 
 static void
 xpt_release_devq_timeout(void *arg)
 {
 	struct cam_ed *device;
 
 	device = (struct cam_ed *)arg;
 	xpt_release_devq_device(device, /*count*/1, /*run_queue*/TRUE);
 }
 
 void
 xpt_release_devq(struct cam_path *path, u_int count, int run_queue)
 {
 
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
 	xpt_release_devq_device(path->device, count, run_queue);
 }
 
 void
 xpt_release_devq_device(struct cam_ed *dev, u_int count, int run_queue)
 {
 
 	if (count > dev->ccbq.queue.qfrozen_cnt) {
 #ifdef INVARIANTS
 		printf("xpt_release_devq(): requested %u > present %u\n",
 		    count, dev->ccbq.queue.qfrozen_cnt);
 #endif
 		count = dev->ccbq.queue.qfrozen_cnt;
 	}
 	dev->ccbq.queue.qfrozen_cnt -= count;
 	if (dev->ccbq.queue.qfrozen_cnt == 0) {
 		/*
 		 * No longer need to wait for a successful
 		 * command completion.
 		 */
 		dev->flags &= ~CAM_DEV_REL_ON_COMPLETE;
 		/*
 		 * Remove any timeouts that might be scheduled
 		 * to release this queue.
 		 */
 		if ((dev->flags & CAM_DEV_REL_TIMEOUT_PENDING) != 0) {
 			callout_stop(&dev->callout);
 			dev->flags &= ~CAM_DEV_REL_TIMEOUT_PENDING;
 		}
 		xpt_run_dev_allocq(dev);
 		if (run_queue == 0)
 			return;
 		/*
 		 * Now that we are unfrozen schedule the
 		 * device so any pending transactions are
 		 * run.
 		 */
 		if (xpt_schedule_devq(dev->sim->devq, dev))
 			xpt_run_devq(dev->sim->devq);
 	}
 }
 
 void
 xpt_release_simq(struct cam_sim *sim, int run_queue)
 {
 	struct	camq *sendq;
 
 	mtx_assert(sim->mtx, MA_OWNED);
 	sendq = &(sim->devq->send_queue);
 	if (sendq->qfrozen_cnt <= 0) {
 #ifdef INVARIANTS
 		printf("xpt_release_simq: requested 1 > present %u\n",
 		    sendq->qfrozen_cnt);
 #endif
 	} else
 		sendq->qfrozen_cnt--;
 	if (sendq->qfrozen_cnt == 0) {
 		/*
 		 * If there is a timeout scheduled to release this
 		 * sim queue, remove it.  The queue frozen count is
 		 * already at 0.
 		 */
 		if ((sim->flags & CAM_SIM_REL_TIMEOUT_PENDING) != 0){
 			callout_stop(&sim->callout);
 			sim->flags &= ~CAM_SIM_REL_TIMEOUT_PENDING;
 		}
 		if (run_queue) {
 			/*
 			 * Now that we are unfrozen run the send queue.
 			 */
 			xpt_run_devq(sim->devq);
 		}
 	}
 }
 
 /*
  * XXX Appears to be unused.
  */
 static void
 xpt_release_simq_timeout(void *arg)
 {
 	struct cam_sim *sim;
 
 	sim = (struct cam_sim *)arg;
 	xpt_release_simq(sim, /* run_queue */ TRUE);
 }
 
 void
 xpt_done(union ccb *done_ccb)
 {
 	struct cam_sim *sim;
 	int	first;
 
 	CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_done\n"));
 	if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) != 0) {
 		/*
 		 * Queue up the request for handling by our SWI handler
 		 * any of the "non-immediate" type of ccbs.
 		 */
 		sim = done_ccb->ccb_h.path->bus->sim;
 		TAILQ_INSERT_TAIL(&sim->sim_doneq, &done_ccb->ccb_h,
 		    sim_links.tqe);
 		done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
 		if ((sim->flags & (CAM_SIM_ON_DONEQ | CAM_SIM_POLLED |
 		    CAM_SIM_BATCH)) == 0) {
 			mtx_lock(&cam_simq_lock);
 			first = TAILQ_EMPTY(&cam_simq);
 			TAILQ_INSERT_TAIL(&cam_simq, sim, links);
 			mtx_unlock(&cam_simq_lock);
 			sim->flags |= CAM_SIM_ON_DONEQ;
 			if (first)
 				swi_sched(cambio_ih, 0);
 		}
 	}
 }
 
 void
 xpt_batch_start(struct cam_sim *sim)
 {
 
 	KASSERT((sim->flags & CAM_SIM_BATCH) == 0, ("Batch flag already set"));
 	sim->flags |= CAM_SIM_BATCH;
 }
 
 void
 xpt_batch_done(struct cam_sim *sim)
 {
 
 	KASSERT((sim->flags & CAM_SIM_BATCH) != 0, ("Batch flag was not set"));
 	sim->flags &= ~CAM_SIM_BATCH;
 	if (!TAILQ_EMPTY(&sim->sim_doneq) &&
 	    (sim->flags & CAM_SIM_ON_DONEQ) == 0)
 		camisr_runqueue(&sim->sim_doneq);
 }
 
 union ccb *
 xpt_alloc_ccb()
 {
 	union ccb *new_ccb;
 
 	new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK);
 	return (new_ccb);
 }
 
 union ccb *
 xpt_alloc_ccb_nowait()
 {
 	union ccb *new_ccb;
 
 	new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT);
 	return (new_ccb);
 }
 
 void
 xpt_free_ccb(union ccb *free_ccb)
 {
 	free(free_ccb, M_CAMCCB);
 }
 
 
 
 /* Private XPT functions */
 
 /*
  * Get a CAM control block for the caller. Charge the structure to the device
  * referenced by the path.  If the this device has no 'credits' then the
  * device already has the maximum number of outstanding operations under way
  * and we return NULL. If we don't have sufficient resources to allocate more
  * ccbs, we also return NULL.
  */
 static union ccb *
 xpt_get_ccb(struct cam_ed *device)
 {
 	union ccb *new_ccb;
 	struct cam_sim *sim;
 
 	sim = device->sim;
 	if ((new_ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) == NULL) {
 		new_ccb = xpt_alloc_ccb_nowait();
                 if (new_ccb == NULL) {
 			return (NULL);
 		}
 		if ((sim->flags & CAM_SIM_MPSAFE) == 0)
 			callout_handle_init(&new_ccb->ccb_h.timeout_ch);
 		SLIST_INSERT_HEAD(&sim->ccb_freeq, &new_ccb->ccb_h,
 				  xpt_links.sle);
 		sim->ccb_count++;
 	}
 	cam_ccbq_take_opening(&device->ccbq);
 	SLIST_REMOVE_HEAD(&sim->ccb_freeq, xpt_links.sle);
 	return (new_ccb);
 }
 
 static void
 xpt_release_bus(struct cam_eb *bus)
 {
 
 	xpt_lock_buses();
 	KASSERT(bus->refcount >= 1, ("bus->refcount >= 1"));
 	if (--bus->refcount > 0) {
 		xpt_unlock_buses();
 		return;
 	}
 	KASSERT(TAILQ_EMPTY(&bus->et_entries),
 	    ("refcount is zero, but target list is not empty"));
 	TAILQ_REMOVE(&xsoftc.xpt_busses, bus, links);
 	xsoftc.bus_generation++;
 	xpt_unlock_buses();
 	cam_sim_release(bus->sim);
 	free(bus, M_CAMXPT);
 }
 
 static struct cam_et *
 xpt_alloc_target(struct cam_eb *bus, target_id_t target_id)
 {
 	struct cam_et *cur_target, *target;
 
 	mtx_assert(bus->sim->mtx, MA_OWNED);
 	target = (struct cam_et *)malloc(sizeof(*target), M_CAMXPT,
 					 M_NOWAIT|M_ZERO);
 	if (target == NULL)
 		return (NULL);
 
 	TAILQ_INIT(&target->ed_entries);
 	target->bus = bus;
 	target->target_id = target_id;
 	target->refcount = 1;
 	target->generation = 0;
 	target->luns = NULL;
 	timevalclear(&target->last_reset);
 	/*
 	 * Hold a reference to our parent bus so it
 	 * will not go away before we do.
 	 */
 	xpt_lock_buses();
 	bus->refcount++;
 	xpt_unlock_buses();
 
 	/* Insertion sort into our bus's target list */
 	cur_target = TAILQ_FIRST(&bus->et_entries);
 	while (cur_target != NULL && cur_target->target_id < target_id)
 		cur_target = TAILQ_NEXT(cur_target, links);
 	if (cur_target != NULL) {
 		TAILQ_INSERT_BEFORE(cur_target, target, links);
 	} else {
 		TAILQ_INSERT_TAIL(&bus->et_entries, target, links);
 	}
 	bus->generation++;
 	return (target);
 }
 
 static void
 xpt_release_target(struct cam_et *target)
 {
 
 	mtx_assert(target->bus->sim->mtx, MA_OWNED);
 	if (--target->refcount > 0)
 		return;
 	KASSERT(TAILQ_EMPTY(&target->ed_entries),
 	    ("refcount is zero, but device list is not empty"));
 	TAILQ_REMOVE(&target->bus->et_entries, target, links);
 	target->bus->generation++;
 	xpt_release_bus(target->bus);
 	if (target->luns)
 		free(target->luns, M_CAMXPT);
 	free(target, M_CAMXPT);
 }
 
 static struct cam_ed *
 xpt_alloc_device_default(struct cam_eb *bus, struct cam_et *target,
 			 lun_id_t lun_id)
 {
 	struct cam_ed *device;
 
 	device = xpt_alloc_device(bus, target, lun_id);
 	if (device == NULL)
 		return (NULL);
 
 	device->mintags = 1;
 	device->maxtags = 1;
 	bus->sim->max_ccbs += device->ccbq.devq_openings;
 	return (device);
 }
 
 struct cam_ed *
 xpt_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
 {
 	struct cam_ed	*cur_device, *device;
 	struct cam_devq	*devq;
 	cam_status status;
 
 	mtx_assert(target->bus->sim->mtx, MA_OWNED);
 	/* Make space for us in the device queue on our bus */
 	devq = bus->sim->devq;
 	status = cam_devq_resize(devq, devq->send_queue.array_size + 1);
 	if (status != CAM_REQ_CMP)
 		return (NULL);
 
 	device = (struct cam_ed *)malloc(sizeof(*device),
 					 M_CAMDEV, M_NOWAIT|M_ZERO);
 	if (device == NULL)
 		return (NULL);
 
 	cam_init_pinfo(&device->devq_entry.pinfo);
 	device->devq_entry.device = device;
 	device->target = target;
 	device->lun_id = lun_id;
 	device->sim = bus->sim;
 	/* Initialize our queues */
 	if (camq_init(&device->drvq, 0) != 0) {
 		free(device, M_CAMDEV);
 		return (NULL);
 	}
 	if (cam_ccbq_init(&device->ccbq,
 			  bus->sim->max_dev_openings) != 0) {
 		camq_fini(&device->drvq);
 		free(device, M_CAMDEV);
 		return (NULL);
 	}
 	SLIST_INIT(&device->asyncs);
 	SLIST_INIT(&device->periphs);
 	device->generation = 0;
 	device->flags = CAM_DEV_UNCONFIGURED;
 	device->tag_delay_count = 0;
 	device->tag_saved_openings = 0;
 	device->refcount = 1;
 	callout_init_mtx(&device->callout, bus->sim->mtx, 0);
 
 	cur_device = TAILQ_FIRST(&target->ed_entries);
 	while (cur_device != NULL && cur_device->lun_id < lun_id)
 		cur_device = TAILQ_NEXT(cur_device, links);
 	if (cur_device != NULL)
 		TAILQ_INSERT_BEFORE(cur_device, device, links);
 	else
 		TAILQ_INSERT_TAIL(&target->ed_entries, device, links);
 	target->refcount++;
 	target->generation++;
 	return (device);
 }
 
 void
 xpt_acquire_device(struct cam_ed *device)
 {
 
 	mtx_assert(device->sim->mtx, MA_OWNED);
 	device->refcount++;
 }
 
 void
 xpt_release_device(struct cam_ed *device)
 {
 	struct cam_devq *devq;
 
 	mtx_assert(device->sim->mtx, MA_OWNED);
 	if (--device->refcount > 0)
 		return;
 
 	KASSERT(SLIST_EMPTY(&device->periphs),
 	    ("refcount is zero, but periphs list is not empty"));
 	if (device->devq_entry.pinfo.index != CAM_UNQUEUED_INDEX)
 		panic("Removing device while still queued for ccbs");
 
 	if ((device->flags & CAM_DEV_REL_TIMEOUT_PENDING) != 0)
 		callout_stop(&device->callout);
 
 	TAILQ_REMOVE(&device->target->ed_entries, device,links);
 	device->target->generation++;
 	device->target->bus->sim->max_ccbs -= device->ccbq.devq_openings;
 	/* Release our slot in the devq */
 	devq = device->target->bus->sim->devq;
 	cam_devq_resize(devq, devq->send_queue.array_size - 1);
 	camq_fini(&device->drvq);
 	cam_ccbq_fini(&device->ccbq);
 	/*
 	 * Free allocated memory.  free(9) does nothing if the
 	 * supplied pointer is NULL, so it is safe to call without
 	 * checking.
 	 */
 	free(device->supported_vpds, M_CAMXPT);
 	free(device->device_id, M_CAMXPT);
 	free(device->physpath, M_CAMXPT);
 	free(device->rcap_buf, M_CAMXPT);
 	free(device->serial_num, M_CAMXPT);
 
 	xpt_release_target(device->target);
 	free(device, M_CAMDEV);
 }
 
 u_int32_t
 xpt_dev_ccbq_resize(struct cam_path *path, int newopenings)
 {
 	int	diff;
 	int	result;
 	struct	cam_ed *dev;
 
 	dev = path->device;
 
 	diff = newopenings - (dev->ccbq.dev_active + dev->ccbq.dev_openings);
 	result = cam_ccbq_resize(&dev->ccbq, newopenings);
 	if (result == CAM_REQ_CMP && (diff < 0)) {
 		dev->flags |= CAM_DEV_RESIZE_QUEUE_NEEDED;
 	}
 	if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0
 	 || (dev->inq_flags & SID_CmdQue) != 0)
 		dev->tag_saved_openings = newopenings;
 	/* Adjust the global limit */
 	dev->sim->max_ccbs += diff;
 	return (result);
 }
 
 static struct cam_eb *
 xpt_find_bus(path_id_t path_id)
 {
 	struct cam_eb *bus;
 
 	xpt_lock_buses();
 	for (bus = TAILQ_FIRST(&xsoftc.xpt_busses);
 	     bus != NULL;
 	     bus = TAILQ_NEXT(bus, links)) {
 		if (bus->path_id == path_id) {
 			bus->refcount++;
 			break;
 		}
 	}
 	xpt_unlock_buses();
 	return (bus);
 }
 
 static struct cam_et *
 xpt_find_target(struct cam_eb *bus, target_id_t	target_id)
 {
 	struct cam_et *target;
 
 	mtx_assert(bus->sim->mtx, MA_OWNED);
 	for (target = TAILQ_FIRST(&bus->et_entries);
 	     target != NULL;
 	     target = TAILQ_NEXT(target, links)) {
 		if (target->target_id == target_id) {
 			target->refcount++;
 			break;
 		}
 	}
 	return (target);
 }
 
 static struct cam_ed *
 xpt_find_device(struct cam_et *target, lun_id_t lun_id)
 {
 	struct cam_ed *device;
 
 	mtx_assert(target->bus->sim->mtx, MA_OWNED);
 	for (device = TAILQ_FIRST(&target->ed_entries);
 	     device != NULL;
 	     device = TAILQ_NEXT(device, links)) {
 		if (device->lun_id == lun_id) {
 			device->refcount++;
 			break;
 		}
 	}
 	return (device);
 }
 
 void
 xpt_start_tags(struct cam_path *path)
 {
 	struct ccb_relsim crs;
 	struct cam_ed *device;
 	struct cam_sim *sim;
 	int    newopenings;
 
 	device = path->device;
 	sim = path->bus->sim;
 	device->flags &= ~CAM_DEV_TAG_AFTER_COUNT;
 	xpt_freeze_devq(path, /*count*/1);
 	device->inq_flags |= SID_CmdQue;
 	if (device->tag_saved_openings != 0)
 		newopenings = device->tag_saved_openings;
 	else
 		newopenings = min(device->maxtags,
 				  sim->max_tagged_dev_openings);
 	xpt_dev_ccbq_resize(path, newopenings);
 	xpt_async(AC_GETDEV_CHANGED, path, NULL);
 	xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
 	crs.ccb_h.func_code = XPT_REL_SIMQ;
 	crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY;
 	crs.openings
 	    = crs.release_timeout
 	    = crs.qfrozen_cnt
 	    = 0;
 	xpt_action((union ccb *)&crs);
 }
 
 void
 xpt_stop_tags(struct cam_path *path)
 {
 	struct ccb_relsim crs;
 	struct cam_ed *device;
 	struct cam_sim *sim;
 
 	device = path->device;
 	sim = path->bus->sim;
 	device->flags &= ~CAM_DEV_TAG_AFTER_COUNT;
 	device->tag_delay_count = 0;
 	xpt_freeze_devq(path, /*count*/1);
 	device->inq_flags &= ~SID_CmdQue;
 	xpt_dev_ccbq_resize(path, sim->max_dev_openings);
 	xpt_async(AC_GETDEV_CHANGED, path, NULL);
 	xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
 	crs.ccb_h.func_code = XPT_REL_SIMQ;
 	crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY;
 	crs.openings
 	    = crs.release_timeout
 	    = crs.qfrozen_cnt
 	    = 0;
 	xpt_action((union ccb *)&crs);
 }
 
 static void
 xpt_boot_delay(void *arg)
 {
 
 	xpt_release_boot();
 }
 
 static void
 xpt_config(void *arg)
 {
 	/*
 	 * Now that interrupts are enabled, go find our devices
 	 */
 
 	/* Setup debugging path */
 	if (cam_dflags != CAM_DEBUG_NONE) {
 		if (xpt_create_path_unlocked(&cam_dpath, NULL,
 				    CAM_DEBUG_BUS, CAM_DEBUG_TARGET,
 				    CAM_DEBUG_LUN) != CAM_REQ_CMP) {
 			printf("xpt_config: xpt_create_path() failed for debug"
 			       " target %d:%d:%d, debugging disabled\n",
 			       CAM_DEBUG_BUS, CAM_DEBUG_TARGET, CAM_DEBUG_LUN);
 			cam_dflags = CAM_DEBUG_NONE;
 		}
 	} else
 		cam_dpath = NULL;
 
 	periphdriver_init(1);
 	xpt_hold_boot();
 	callout_init(&xsoftc.boot_callout, 1);
 	callout_reset(&xsoftc.boot_callout, hz * xsoftc.boot_delay / 1000,
 	    xpt_boot_delay, NULL);
 	/* Fire up rescan thread. */
 	if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) {
 		printf("xpt_config: failed to create rescan thread.\n");
 	}
 }
 
 void
 xpt_hold_boot(void)
 {
 	xpt_lock_buses();
 	xsoftc.buses_to_config++;
 	xpt_unlock_buses();
 }
 
 void
 xpt_release_boot(void)
 {
 	xpt_lock_buses();
 	xsoftc.buses_to_config--;
 	if (xsoftc.buses_to_config == 0 && xsoftc.buses_config_done == 0) {
 		struct	xpt_task *task;
 
 		xsoftc.buses_config_done = 1;
 		xpt_unlock_buses();
 		/* Call manually because we don't have any busses */
 		task = malloc(sizeof(struct xpt_task), M_CAMXPT, M_NOWAIT);
 		if (task != NULL) {
 			TASK_INIT(&task->task, 0, xpt_finishconfig_task, task);
 			taskqueue_enqueue(taskqueue_thread, &task->task);
 		}
 	} else
 		xpt_unlock_buses();
 }
 
 /*
  * If the given device only has one peripheral attached to it, and if that
  * peripheral is the passthrough driver, announce it.  This insures that the
  * user sees some sort of announcement for every peripheral in their system.
  */
 static int
 xptpassannouncefunc(struct cam_ed *device, void *arg)
 {
 	struct cam_periph *periph;
 	int i;
 
 	for (periph = SLIST_FIRST(&device->periphs), i = 0; periph != NULL;
 	     periph = SLIST_NEXT(periph, periph_links), i++);
 
 	periph = SLIST_FIRST(&device->periphs);
 	if ((i == 1)
 	 && (strncmp(periph->periph_name, "pass", 4) == 0))
 		xpt_announce_periph(periph, NULL);
 
 	return(1);
 }
 
 static void
 xpt_finishconfig_task(void *context, int pending)
 {
 
 	periphdriver_init(2);
 	/*
 	 * Check for devices with no "standard" peripheral driver
 	 * attached.  For any devices like that, announce the
 	 * passthrough driver so the user will see something.
 	 */
 	if (!bootverbose)
 		xpt_for_all_devices(xptpassannouncefunc, NULL);
 
 	/* Release our hook so that the boot can continue. */
 	config_intrhook_disestablish(xsoftc.xpt_config_hook);
 	free(xsoftc.xpt_config_hook, M_CAMXPT);
 	xsoftc.xpt_config_hook = NULL;
 
 	free(context, M_CAMXPT);
 }
 
 cam_status
 xpt_register_async(int event, ac_callback_t *cbfunc, void *cbarg,
 		   struct cam_path *path)
 {
 	struct ccb_setasync csa;
 	cam_status status;
 	int xptpath = 0;
 
 	if (path == NULL) {
 		mtx_lock(&xsoftc.xpt_lock);
 		status = xpt_create_path(&path, /*periph*/NULL, CAM_XPT_PATH_ID,
 					 CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD);
 		if (status != CAM_REQ_CMP) {
 			mtx_unlock(&xsoftc.xpt_lock);
 			return (status);
 		}
 		xptpath = 1;
 	}
 
 	xpt_setup_ccb(&csa.ccb_h, path, CAM_PRIORITY_NORMAL);
 	csa.ccb_h.func_code = XPT_SASYNC_CB;
 	csa.event_enable = event;
 	csa.callback = cbfunc;
 	csa.callback_arg = cbarg;
 	xpt_action((union ccb *)&csa);
 	status = csa.ccb_h.status;
 
 	if (xptpath) {
 		xpt_free_path(path);
 		mtx_unlock(&xsoftc.xpt_lock);
 	}
 
 	if ((status == CAM_REQ_CMP) &&
 	    (csa.event_enable & AC_FOUND_DEVICE)) {
 		/*
 		 * Get this peripheral up to date with all
 		 * the currently existing devices.
 		 */
 		xpt_for_all_devices(xptsetasyncfunc, &csa);
 	}
 	if ((status == CAM_REQ_CMP) &&
 	    (csa.event_enable & AC_PATH_REGISTERED)) {
 		/*
 		 * Get this peripheral up to date with all
 		 * the currently existing busses.
 		 */
 		xpt_for_all_busses(xptsetasyncbusfunc, &csa);
 	}
 
 	return (status);
 }
 
 static void
 xptaction(struct cam_sim *sim, union ccb *work_ccb)
 {
 	CAM_DEBUG(work_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xptaction\n"));
 
 	switch (work_ccb->ccb_h.func_code) {
 	/* Common cases first */
 	case XPT_PATH_INQ:		/* Path routing inquiry */
 	{
 		struct ccb_pathinq *cpi;
 
 		cpi = &work_ccb->cpi;
 		cpi->version_num = 1; /* XXX??? */
 		cpi->hba_inquiry = 0;
 		cpi->target_sprt = 0;
 		cpi->hba_misc = 0;
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = 0;
 		cpi->max_lun = 0;
 		cpi->initiator_id = 0;
 		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
 		strncpy(cpi->hba_vid, "", HBA_IDLEN);
 		strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
 		cpi->unit_number = sim->unit_number;
 		cpi->bus_id = sim->bus_id;
 		cpi->base_transfer_speed = 0;
 		cpi->protocol = PROTO_UNSPECIFIED;
 		cpi->protocol_version = PROTO_VERSION_UNSPECIFIED;
 		cpi->transport = XPORT_UNSPECIFIED;
 		cpi->transport_version = XPORT_VERSION_UNSPECIFIED;
 		cpi->ccb_h.status = CAM_REQ_CMP;
 		xpt_done(work_ccb);
 		break;
 	}
 	default:
 		work_ccb->ccb_h.status = CAM_REQ_INVALID;
 		xpt_done(work_ccb);
 		break;
 	}
 }
 
 /*
  * The xpt as a "controller" has no interrupt sources, so polling
  * is a no-op.
  */
 static void
 xptpoll(struct cam_sim *sim)
 {
 }
 
 void
 xpt_lock_buses(void)
 {
 	mtx_lock(&xsoftc.xpt_topo_lock);
 }
 
 void
 xpt_unlock_buses(void)
 {
 	mtx_unlock(&xsoftc.xpt_topo_lock);
 }
 
 static void
 camisr(void *dummy)
 {
 	cam_simq_t queue;
 	struct cam_sim *sim;
 
 	mtx_lock(&cam_simq_lock);
 	TAILQ_INIT(&queue);
 	while (!TAILQ_EMPTY(&cam_simq)) {
 		TAILQ_CONCAT(&queue, &cam_simq, links);
 		mtx_unlock(&cam_simq_lock);
 
 		while ((sim = TAILQ_FIRST(&queue)) != NULL) {
 			TAILQ_REMOVE(&queue, sim, links);
 			CAM_SIM_LOCK(sim);
 			camisr_runqueue(&sim->sim_doneq);
 			sim->flags &= ~CAM_SIM_ON_DONEQ;
 			CAM_SIM_UNLOCK(sim);
 		}
 		mtx_lock(&cam_simq_lock);
 	}
 	mtx_unlock(&cam_simq_lock);
 }
 
 static void
 camisr_runqueue(void *V_queue)
 {
 	cam_isrq_t *queue = V_queue;
 	struct	ccb_hdr *ccb_h;
 
 	while ((ccb_h = TAILQ_FIRST(queue)) != NULL) {
 		int	runq;
 
 		TAILQ_REMOVE(queue, ccb_h, sim_links.tqe);
 		ccb_h->pinfo.index = CAM_UNQUEUED_INDEX;
 
 		CAM_DEBUG(ccb_h->path, CAM_DEBUG_TRACE,
 			  ("camisr\n"));
 
 		runq = FALSE;
 
 		if (ccb_h->flags & CAM_HIGH_POWER) {
 			struct highpowerlist	*hphead;
 			union ccb		*send_ccb;
 
 			mtx_lock(&xsoftc.xpt_lock);
 			hphead = &xsoftc.highpowerq;
 
 			send_ccb = (union ccb *)STAILQ_FIRST(hphead);
 
 			/*
 			 * Increment the count since this command is done.
 			 */
 			xsoftc.num_highpower++;
 
 			/*
 			 * Any high powered commands queued up?
 			 */
 			if (send_ccb != NULL) {
 
 				STAILQ_REMOVE_HEAD(hphead, xpt_links.stqe);
 				mtx_unlock(&xsoftc.xpt_lock);
 
 				xpt_release_devq(send_ccb->ccb_h.path,
 						 /*count*/1, /*runqueue*/TRUE);
 			} else
 				mtx_unlock(&xsoftc.xpt_lock);
 		}
 
 		if ((ccb_h->func_code & XPT_FC_USER_CCB) == 0) {
 			struct cam_ed *dev;
 
 			dev = ccb_h->path->device;
 
 			cam_ccbq_ccb_done(&dev->ccbq, (union ccb *)ccb_h);
 			ccb_h->path->bus->sim->devq->send_active--;
 			ccb_h->path->bus->sim->devq->send_openings++;
 			runq = TRUE;
 
 			if (((dev->flags & CAM_DEV_REL_ON_QUEUE_EMPTY) != 0
 			  && (dev->ccbq.dev_active == 0))) {
 				dev->flags &= ~CAM_DEV_REL_ON_QUEUE_EMPTY;
 				xpt_release_devq(ccb_h->path, /*count*/1,
 						 /*run_queue*/FALSE);
 			}
 
 			if (((dev->flags & CAM_DEV_REL_ON_COMPLETE) != 0
 			  && (ccb_h->status&CAM_STATUS_MASK) != CAM_REQUEUE_REQ)) {
 				dev->flags &= ~CAM_DEV_REL_ON_COMPLETE;
 				xpt_release_devq(ccb_h->path, /*count*/1,
 						 /*run_queue*/FALSE);
 			}
 
 			if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0
 			 && (--dev->tag_delay_count == 0))
 				xpt_start_tags(ccb_h->path);
 			if (!device_is_queued(dev)) {
 				(void)xpt_schedule_devq(
 				    ccb_h->path->bus->sim->devq, dev);
 			}
 		}
 
 		if (ccb_h->status & CAM_RELEASE_SIMQ) {
 			xpt_release_simq(ccb_h->path->bus->sim,
 					 /*run_queue*/TRUE);
 			ccb_h->status &= ~CAM_RELEASE_SIMQ;
 			runq = FALSE;
 		}
 
 		if ((ccb_h->flags & CAM_DEV_QFRZDIS)
 		 && (ccb_h->status & CAM_DEV_QFRZN)) {
 			xpt_release_devq(ccb_h->path, /*count*/1,
 					 /*run_queue*/TRUE);
 			ccb_h->status &= ~CAM_DEV_QFRZN;
 		} else if (runq) {
 			xpt_run_devq(ccb_h->path->bus->sim->devq);
 		}
 
 		/* Call the peripheral driver's callback */
 		(*ccb_h->cbfcnp)(ccb_h->path->periph, (union ccb *)ccb_h);
 	}
 }
Index: user/attilio/vmcontention/sys/cam/scsi/scsi_ch.c
===================================================================
--- user/attilio/vmcontention/sys/cam/scsi/scsi_ch.c	(revision 249698)
+++ user/attilio/vmcontention/sys/cam/scsi/scsi_ch.c	(revision 249699)
@@ -1,1742 +1,1893 @@
 /*-
  * Copyright (c) 1997 Justin T. Gibbs.
  * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification, immediately at the beginning of the file.
  * 2. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 /*
  * Derived from the NetBSD SCSI changer driver.
  *
  *	$NetBSD: ch.c,v 1.32 1998/01/12 09:49:12 thorpej Exp $
  *
  */
 /*-
  * Copyright (c) 1996, 1997 Jason R. Thorpe 
  * All rights reserved.
  *
  * Partially based on an autochanger driver written by Stefan Grefen
  * and on an autochanger driver written by the Systems Programming Group
  * at the University of Utah Computer Science Department.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgements:
  *	This product includes software developed by Jason R. Thorpe
  *	for And Communications, http://www.and.com/
  * 4. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 
 /*
  * Timeout definitions for various changer related commands.  They may
  * be too short for some devices (especially the timeout for INITIALIZE
  * ELEMENT STATUS).
  */
 
 static const u_int32_t	CH_TIMEOUT_MODE_SENSE                = 6000;
 static const u_int32_t	CH_TIMEOUT_MOVE_MEDIUM               = 100000;
 static const u_int32_t	CH_TIMEOUT_EXCHANGE_MEDIUM           = 100000;
 static const u_int32_t	CH_TIMEOUT_POSITION_TO_ELEMENT       = 100000;
 static const u_int32_t	CH_TIMEOUT_READ_ELEMENT_STATUS       = 10000;
 static const u_int32_t	CH_TIMEOUT_SEND_VOLTAG		     = 10000;
 static const u_int32_t	CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000;
 
 typedef enum {
 	CH_FLAG_INVALID		= 0x001
 } ch_flags;
 
 typedef enum {
 	CH_STATE_PROBE,
 	CH_STATE_NORMAL
 } ch_state;
 
 typedef enum {
 	CH_CCB_PROBE,
 	CH_CCB_WAITING
 } ch_ccb_types;
 
 typedef enum {
 	CH_Q_NONE	= 0x00,
 	CH_Q_NO_DBD	= 0x01
 } ch_quirks;
 
 #define ccb_state	ppriv_field0
 #define ccb_bp		ppriv_ptr1
 
 struct scsi_mode_sense_data {
 	struct scsi_mode_header_6 header;
 	struct scsi_mode_blk_desc blk_desc;
 	union {
 		struct page_element_address_assignment ea;
 		struct page_transport_geometry_parameters tg;
 		struct page_device_capabilities cap;
 	} pages;
 };
 
 struct ch_softc {
 	ch_flags	flags;
 	ch_state	state;
 	ch_quirks	quirks;
 	union ccb	saved_ccb;
 	struct devstat	*device_stats;
 	struct cdev     *dev;
 	int		open_count;
 
 	int		sc_picker;	/* current picker */
 
 	/*
 	 * The following information is obtained from the
 	 * element address assignment page.
 	 */
 	int		sc_firsts[CHET_MAX + 1];	/* firsts */
 	int		sc_counts[CHET_MAX + 1];	/* counts */
 
 	/*
 	 * The following mask defines the legal combinations
 	 * of elements for the MOVE MEDIUM command.
 	 */
 	u_int8_t	sc_movemask[CHET_MAX + 1];
 
 	/*
 	 * As above, but for EXCHANGE MEDIUM.
 	 */
 	u_int8_t	sc_exchangemask[CHET_MAX + 1];
 
 	/*
 	 * Quirks; see below.  XXX KDM not implemented yet
 	 */
 	int		sc_settledelay;	/* delay for settle */
 };
 
 static	d_open_t	chopen;
 static	d_close_t	chclose;
 static	d_ioctl_t	chioctl;
 static	periph_init_t	chinit;
 static  periph_ctor_t	chregister;
 static	periph_oninv_t	choninvalidate;
 static  periph_dtor_t   chcleanup;
 static  periph_start_t  chstart;
 static	void		chasync(void *callback_arg, u_int32_t code,
 				struct cam_path *path, void *arg);
 static	void		chdone(struct cam_periph *periph,
 			       union ccb *done_ccb);
 static	int		cherror(union ccb *ccb, u_int32_t cam_flags,
 				u_int32_t sense_flags);
 static	int		chmove(struct cam_periph *periph,
 			       struct changer_move *cm);
 static	int		chexchange(struct cam_periph *periph,
 				   struct changer_exchange *ce);
 static	int		chposition(struct cam_periph *periph,
 				   struct changer_position *cp);
 static	int		chgetelemstatus(struct cam_periph *periph,
+				int scsi_version, u_long cmd,
 				struct changer_element_status_request *csr);
 static	int		chsetvoltag(struct cam_periph *periph,
 				    struct changer_set_voltag_request *csvr);
 static	int		chielem(struct cam_periph *periph, 
 				unsigned int timeout);
 static	int		chgetparams(struct cam_periph *periph);
+static	int		chscsiversion(struct cam_periph *periph);
 
 static struct periph_driver chdriver =
 {
 	chinit, "ch",
 	TAILQ_HEAD_INITIALIZER(chdriver.units), /* generation */ 0
 };
 
 PERIPHDRIVER_DECLARE(ch, chdriver);
 
 static struct cdevsw ch_cdevsw = {
 	.d_version =	D_VERSION,
 	.d_flags =	D_TRACKCLOSE,
 	.d_open =	chopen,
 	.d_close =	chclose,
 	.d_ioctl =	chioctl,
 	.d_name =	"ch",
 };
 
 static MALLOC_DEFINE(M_SCSICH, "scsi_ch", "scsi_ch buffers");
 
 static void
 chinit(void)
 {
 	cam_status status;
 
 	/*
 	 * Install a global async callback.  This callback will
 	 * receive async callbacks like "new device found".
 	 */
 	status = xpt_register_async(AC_FOUND_DEVICE, chasync, NULL, NULL);
 
 	if (status != CAM_REQ_CMP) {
 		printf("ch: Failed to attach master async callback "
 		       "due to status 0x%x!\n", status);
 	}
 }
 
 static void
 chdevgonecb(void *arg)
 {
 	struct cam_sim	  *sim;
 	struct ch_softc   *softc;
 	struct cam_periph *periph;
 	int i;
 
 	periph = (struct cam_periph *)arg;
 	sim = periph->sim;
 	softc = (struct ch_softc *)periph->softc;
 
 	KASSERT(softc->open_count >= 0, ("Negative open count %d",
 		softc->open_count));
 
 	mtx_lock(sim->mtx);
 
 	/*
 	 * When we get this callback, we will get no more close calls from
 	 * devfs.  So if we have any dangling opens, we need to release the
 	 * reference held for that particular context.
 	 */
 	for (i = 0; i < softc->open_count; i++)
 		cam_periph_release_locked(periph);
 
 	softc->open_count = 0;
 
 	/*
 	 * Release the reference held for the device node, it is gone now.
 	 */
 	cam_periph_release_locked(periph);
 
 	/*
 	 * We reference the SIM lock directly here, instead of using
 	 * cam_periph_unlock().  The reason is that the final call to
 	 * cam_periph_release_locked() above could result in the periph
 	 * getting freed.  If that is the case, dereferencing the periph
 	 * with a cam_periph_unlock() call would cause a page fault.
 	 */
 	mtx_unlock(sim->mtx);
 }
 
 static void
 choninvalidate(struct cam_periph *periph)
 {
 	struct ch_softc *softc;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	/*
 	 * De-register any async callbacks.
 	 */
 	xpt_register_async(0, chasync, periph, periph->path);
 
 	softc->flags |= CH_FLAG_INVALID;
 
 	/*
 	 * Tell devfs this device has gone away, and ask for a callback
 	 * when it has cleaned up its state.
 	 */
 	destroy_dev_sched_cb(softc->dev, chdevgonecb, periph);
 
 	xpt_print(periph->path, "lost device\n");
 
 }
 
 static void
 chcleanup(struct cam_periph *periph)
 {
 	struct ch_softc *softc;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	xpt_print(periph->path, "removing device entry\n");
 
 	devstat_remove_entry(softc->device_stats);
 
 	free(softc, M_DEVBUF);
 }
 
 static void
 chasync(void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
 {
 	struct cam_periph *periph;
 
 	periph = (struct cam_periph *)callback_arg;
 
 	switch(code) {
 	case AC_FOUND_DEVICE:
 	{
 		struct ccb_getdev *cgd;
 		cam_status status;
 
 		cgd = (struct ccb_getdev *)arg;
 		if (cgd == NULL)
 			break;
 
 		if (cgd->protocol != PROTO_SCSI)
 			break;
 
 		if (SID_TYPE(&cgd->inq_data)!= T_CHANGER)
 			break;
 
 		/*
 		 * Allocate a peripheral instance for
 		 * this device and start the probe
 		 * process.
 		 */
 		status = cam_periph_alloc(chregister, choninvalidate,
 					  chcleanup, chstart, "ch",
 					  CAM_PERIPH_BIO, cgd->ccb_h.path,
 					  chasync, AC_FOUND_DEVICE, cgd);
 
 		if (status != CAM_REQ_CMP
 		 && status != CAM_REQ_INPROG)
 			printf("chasync: Unable to probe new device "
 			       "due to status 0x%x\n", status);
 
 		break;
 
 	}
 	default:
 		cam_periph_async(periph, code, path, arg);
 		break;
 	}
 }
 
 static cam_status
 chregister(struct cam_periph *periph, void *arg)
 {
 	struct ch_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
 		printf("chregister: no getdev CCB, can't register device\n");
 		return(CAM_REQ_CMP_ERR);
 	}
 
 	softc = (struct ch_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT);
 
 	if (softc == NULL) {
 		printf("chregister: Unable to probe new device. "
 		       "Unable to allocate softc\n");				
 		return(CAM_REQ_CMP_ERR);
 	}
 
 	bzero(softc, sizeof(*softc));
 	softc->state = CH_STATE_PROBE;
 	periph->softc = softc;
 	softc->quirks = CH_Q_NONE;
 
 	bzero(&cpi, sizeof(cpi));
 	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
 	cpi.ccb_h.func_code = XPT_PATH_INQ;
 	xpt_action((union ccb *)&cpi);
 
 	/*
 	 * Changers don't have a blocksize, and obviously don't support
 	 * tagged queueing.
 	 */
 	cam_periph_unlock(periph);
 	softc->device_stats = devstat_new_entry("ch",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE | DEVSTAT_NO_ORDERED_TAGS,
 			  SID_TYPE(&cgd->inq_data) |
 			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
 	/*
 	 * Acquire a reference to the periph before we create the devfs
 	 * instance for it.  We'll release this reference once the devfs
 	 * instance has been freed.
 	 */
 	if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
 		xpt_print(periph->path, "%s: lost periph during "
 			  "registration!\n", __func__);
 		cam_periph_lock(periph);
 		return (CAM_REQ_CMP_ERR);
 	}
 
 
 	/* Register the device */
 	softc->dev = make_dev(&ch_cdevsw, periph->unit_number, UID_ROOT,
 			      GID_OPERATOR, 0600, "%s%d", periph->periph_name,
 			      periph->unit_number);
 	cam_periph_lock(periph);
 	softc->dev->si_drv1 = periph;
 
 	/*
 	 * Add an async callback so that we get
 	 * notified if this device goes away.
 	 */
 	xpt_register_async(AC_LOST_DEVICE, chasync, periph, periph->path);
 
 	/*
 	 * Lock this periph until we are setup.
 	 * This first call can't block
 	 */
 	(void)cam_periph_hold(periph, PRIBIO);
 	xpt_schedule(periph, CAM_PRIORITY_DEV);
 
 	return(CAM_REQ_CMP);
 }
 
 static int
 chopen(struct cdev *dev, int flags, int fmt, struct thread *td)
 {
 	struct cam_periph *periph;
 	struct ch_softc *softc;
 	int error;
 
 	periph = (struct cam_periph *)dev->si_drv1;
 	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
 		return (ENXIO);
 
 	softc = (struct ch_softc *)periph->softc;
 
 	cam_periph_lock(periph);
 	
 	if (softc->flags & CH_FLAG_INVALID) {
 		cam_periph_release_locked(periph);
 		cam_periph_unlock(periph);
 		return(ENXIO);
 	}
 
 	if ((error = cam_periph_hold(periph, PRIBIO | PCATCH)) != 0) {
 		cam_periph_unlock(periph);
 		cam_periph_release(periph);
 		return (error);
 	}
 
 	/*
 	 * Load information about this changer device into the softc.
 	 */
 	if ((error = chgetparams(periph)) != 0) {
+		cam_periph_unhold(periph);
 		cam_periph_release_locked(periph);
 		cam_periph_unlock(periph);
 		return(error);
 	}
 
 	cam_periph_unhold(periph);
 
 	softc->open_count++;
 
 	cam_periph_unlock(periph);
 
 	return(error);
 }
 
 static int
 chclose(struct cdev *dev, int flag, int fmt, struct thread *td)
 {
 	struct	cam_sim *sim;
 	struct	cam_periph *periph;
 	struct  ch_softc *softc;
 
 	periph = (struct cam_periph *)dev->si_drv1;
 	if (periph == NULL)
 		return(ENXIO);
 
 	sim = periph->sim;
 	softc = (struct ch_softc *)periph->softc;
 
 	mtx_lock(sim->mtx);
 
 	softc->open_count--;
 
 	cam_periph_release_locked(periph);
 
 	/*
 	 * We reference the SIM lock directly here, instead of using
 	 * cam_periph_unlock().  The reason is that the call to
 	 * cam_periph_release_locked() above could result in the periph
 	 * getting freed.  If that is the case, dereferencing the periph
 	 * with a cam_periph_unlock() call would cause a page fault.
 	 *
 	 * cam_periph_release() avoids this problem using the same method,
 	 * but we're manually acquiring and dropping the lock here to
 	 * protect the open count and avoid another lock acquisition and
 	 * release.
 	 */
 	mtx_unlock(sim->mtx);
 
 	return(0);
 }
 
 static void
 chstart(struct cam_periph *periph, union ccb *start_ccb)
 {
 	struct ch_softc *softc;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	switch (softc->state) {
 	case CH_STATE_NORMAL:
 	{
 		if (periph->immediate_priority <= periph->pinfo.priority){
 			start_ccb->ccb_h.ccb_state = CH_CCB_WAITING;
 
 			SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
 					  periph_links.sle);
 			periph->immediate_priority = CAM_PRIORITY_NONE;
 			wakeup(&periph->ccb_list);
 		}
 		break;
 	}
 	case CH_STATE_PROBE:
 	{
 		int mode_buffer_len;
 		void *mode_buffer;
 
 		/*
 		 * Include the block descriptor when calculating the mode
 		 * buffer length,
 		 */
 		mode_buffer_len = sizeof(struct scsi_mode_header_6) +
 				  sizeof(struct scsi_mode_blk_desc) +
 				 sizeof(struct page_element_address_assignment);
 
 		mode_buffer = malloc(mode_buffer_len, M_SCSICH, M_NOWAIT);
 
 		if (mode_buffer == NULL) {
 			printf("chstart: couldn't malloc mode sense data\n");
 			break;
 		}
 		bzero(mode_buffer, mode_buffer_len);
 
 		/*
 		 * Get the element address assignment page.
 		 */
 		scsi_mode_sense(&start_ccb->csio,
 				/* retries */ 1,
 				/* cbfcnp */ chdone,
 				/* tag_action */ MSG_SIMPLE_Q_TAG,
 				/* dbd */ (softc->quirks & CH_Q_NO_DBD) ?
 					FALSE : TRUE,
 				/* page_code */ SMS_PAGE_CTRL_CURRENT,
 				/* page */ CH_ELEMENT_ADDR_ASSIGN_PAGE,
 				/* param_buf */ (u_int8_t *)mode_buffer,
 				/* param_len */ mode_buffer_len,
 				/* sense_len */ SSD_FULL_SIZE,
 				/* timeout */ CH_TIMEOUT_MODE_SENSE);
 
 		start_ccb->ccb_h.ccb_bp = NULL;
 		start_ccb->ccb_h.ccb_state = CH_CCB_PROBE;
 		xpt_action(start_ccb);
 		break;
 	}
 	}
 }
 
 static void
 chdone(struct cam_periph *periph, union ccb *done_ccb)
 {
 	struct ch_softc *softc;
 	struct ccb_scsiio *csio;
 
 	softc = (struct ch_softc *)periph->softc;
 	csio = &done_ccb->csio;
 
 	switch(done_ccb->ccb_h.ccb_state) {
 	case CH_CCB_PROBE:
 	{
 		struct scsi_mode_header_6 *mode_header;
 		struct page_element_address_assignment *ea;
 		char announce_buf[80];
 
 
 		mode_header = (struct scsi_mode_header_6 *)csio->data_ptr;
 
 		ea = (struct page_element_address_assignment *)
 			find_mode_page_6(mode_header);
 
 		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP){
 			
 			softc->sc_firsts[CHET_MT] = scsi_2btoul(ea->mtea);
 			softc->sc_counts[CHET_MT] = scsi_2btoul(ea->nmte);
 			softc->sc_firsts[CHET_ST] = scsi_2btoul(ea->fsea);
 			softc->sc_counts[CHET_ST] = scsi_2btoul(ea->nse);
 			softc->sc_firsts[CHET_IE] = scsi_2btoul(ea->fieea);
 			softc->sc_counts[CHET_IE] = scsi_2btoul(ea->niee);
 			softc->sc_firsts[CHET_DT] = scsi_2btoul(ea->fdtea);
 			softc->sc_counts[CHET_DT] = scsi_2btoul(ea->ndte);
 			softc->sc_picker = softc->sc_firsts[CHET_MT];
 
 #define PLURAL(c)	(c) == 1 ? "" : "s"
 			snprintf(announce_buf, sizeof(announce_buf),
 				"%d slot%s, %d drive%s, "
 				"%d picker%s, %d portal%s",
 		    		softc->sc_counts[CHET_ST],
 				PLURAL(softc->sc_counts[CHET_ST]),
 		    		softc->sc_counts[CHET_DT],
 				PLURAL(softc->sc_counts[CHET_DT]),
 		    		softc->sc_counts[CHET_MT],
 				PLURAL(softc->sc_counts[CHET_MT]),
 		    		softc->sc_counts[CHET_IE],
 				PLURAL(softc->sc_counts[CHET_IE]));
 #undef PLURAL
 		} else {
 			int error;
 
 			error = cherror(done_ccb, CAM_RETRY_SELTO,
 					SF_RETRY_UA | SF_NO_PRINT);
 			/*
 			 * Retry any UNIT ATTENTION type errors.  They
 			 * are expected at boot.
 			 */
 			if (error == ERESTART) {
 				/*
 				 * A retry was scheuled, so
 				 * just return.
 				 */
 				return;
 			} else if (error != 0) {
 				int retry_scheduled;
 				struct scsi_mode_sense_6 *sms;
 
 				sms = (struct scsi_mode_sense_6 *)
 					done_ccb->csio.cdb_io.cdb_bytes;
 
 				/*
 				 * Check to see if block descriptors were
 				 * disabled.  Some devices don't like that.
 				 * We're taking advantage of the fact that
 				 * the first few bytes of the 6 and 10 byte
 				 * mode sense commands are the same.  If
 				 * block descriptors were disabled, enable
 				 * them and re-send the command.
 				 */
 				if (sms->byte2 & SMS_DBD) {
 					sms->byte2 &= ~SMS_DBD;
 					xpt_action(done_ccb);
 					softc->quirks |= CH_Q_NO_DBD;
 					retry_scheduled = 1;
 				} else
 					retry_scheduled = 0;
 
 				/* Don't wedge this device's queue */
 				if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
 					cam_release_devq(done_ccb->ccb_h.path,
 						 /*relsim_flags*/0,
 						 /*reduction*/0,
 						 /*timeout*/0,
 						 /*getcount_only*/0);
 
 				if (retry_scheduled)
 					return;
 
 				if ((done_ccb->ccb_h.status & CAM_STATUS_MASK)
 				    == CAM_SCSI_STATUS_ERROR) 
 					scsi_sense_print(&done_ccb->csio);
 				else {
 					xpt_print(periph->path,
 					    "got CAM status %#x\n",
 					    done_ccb->ccb_h.status);
 				}
 				xpt_print(periph->path, "fatal error, failed "
 				    "to attach to device\n");
 
 				cam_periph_invalidate(periph);
 
 				announce_buf[0] = '\0';
 			}
 		}
 		if (announce_buf[0] != '\0')
 			xpt_announce_periph(periph, announce_buf);
 		softc->state = CH_STATE_NORMAL;
 		free(mode_header, M_SCSICH);
 		/*
 		 * Since our peripheral may be invalidated by an error
 		 * above or an external event, we must release our CCB
 		 * before releasing the probe lock on the peripheral.
 		 * The peripheral will only go away once the last lock
 		 * is removed, and we need it around for the CCB release
 		 * operation.
 		 */
 		xpt_release_ccb(done_ccb);
 		cam_periph_unhold(periph);
 		return;
 	}
 	case CH_CCB_WAITING:
 	{
 		/* Caller will release the CCB */
 		wakeup(&done_ccb->ccb_h.cbfcnp);
 		return;
 	}
 	default:
 		break;
 	}
 	xpt_release_ccb(done_ccb);
 }
 
 static int
 cherror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 {
 	struct ch_softc *softc;
 	struct cam_periph *periph;
 
 	periph = xpt_path_periph(ccb->ccb_h.path);
 	softc = (struct ch_softc *)periph->softc;
 
 	return (cam_periph_error(ccb, cam_flags, sense_flags,
 				 &softc->saved_ccb));
 }
 
 static int
 chioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 {
 	struct cam_periph *periph;
 	struct ch_softc *softc;
 	int error;
 
 	periph = (struct cam_periph *)dev->si_drv1;
 	if (periph == NULL)
 		return(ENXIO);
 
 	cam_periph_lock(periph);
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering chioctl\n"));
 
 	softc = (struct ch_softc *)periph->softc;
 
 	error = 0;
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, 
 		  ("trying to do ioctl %#lx\n", cmd));
 
 	/*
 	 * If this command can change the device's state, we must
 	 * have the device open for writing.
 	 */
 	switch (cmd) {
 	case CHIOGPICKER:
 	case CHIOGPARAMS:
+	case OCHIOGSTATUS:
 	case CHIOGSTATUS:
 		break;
 
 	default:
 		if ((flag & FWRITE) == 0) {
 			cam_periph_unlock(periph);
 			return (EBADF);
 		}
 	}
 
 	switch (cmd) {
 	case CHIOMOVE:
 		error = chmove(periph, (struct changer_move *)addr);
 		break;
 
 	case CHIOEXCHANGE:
 		error = chexchange(periph, (struct changer_exchange *)addr);
 		break;
 
 	case CHIOPOSITION:
 		error = chposition(periph, (struct changer_position *)addr);
 		break;
 
 	case CHIOGPICKER:
 		*(int *)addr = softc->sc_picker - softc->sc_firsts[CHET_MT];
 		break;
 
 	case CHIOSPICKER:
 	{
 		int new_picker = *(int *)addr;
 
 		if (new_picker > (softc->sc_counts[CHET_MT] - 1)) {
 			error = EINVAL;
 			break;
 		}
 		softc->sc_picker = softc->sc_firsts[CHET_MT] + new_picker;
 		break;
 	}
 	case CHIOGPARAMS:
 	{
 		struct changer_params *cp = (struct changer_params *)addr;
 
 		cp->cp_npickers = softc->sc_counts[CHET_MT];
 		cp->cp_nslots = softc->sc_counts[CHET_ST];
 		cp->cp_nportals = softc->sc_counts[CHET_IE];
 		cp->cp_ndrives = softc->sc_counts[CHET_DT];
 		break;
 	}
 	case CHIOIELEM:
 		error = chielem(periph, *(unsigned int *)addr);
 		break;
 
+	case OCHIOGSTATUS:
+	{
+		error = chgetelemstatus(periph, SCSI_REV_2, cmd,
+		    (struct changer_element_status_request *)addr);
+		break;
+	}
+
 	case CHIOGSTATUS:
 	{
-		error = chgetelemstatus(periph,
-			       (struct changer_element_status_request *) addr);
+		int scsi_version;
+
+		scsi_version = chscsiversion(periph);
+		if (scsi_version >= SCSI_REV_0) {
+			error = chgetelemstatus(periph, scsi_version, cmd,
+			    (struct changer_element_status_request *)addr);
+	  	}
+		else { /* unable to determine the SCSI version */
+			cam_periph_unlock(periph);
+			return (ENXIO);
+		}
 		break;
 	}
 
 	case CHIOSETVOLTAG:
 	{
 		error = chsetvoltag(periph,
 				    (struct changer_set_voltag_request *) addr);
 		break;
 	}
 
 	/* Implement prevent/allow? */
 
 	default:
 		error = cam_periph_ioctl(periph, cmd, addr, cherror);
 		break;
 	}
 
 	cam_periph_unlock(periph);
 	return (error);
 }
 
 static int
 chmove(struct cam_periph *periph, struct changer_move *cm)
 {
 	struct ch_softc *softc;
 	u_int16_t fromelem, toelem;
 	union ccb *ccb;
 	int error;
 
 	error = 0;
 	softc = (struct ch_softc *)periph->softc;
 
 	/*
 	 * Check arguments.
 	 */
 	if ((cm->cm_fromtype > CHET_DT) || (cm->cm_totype > CHET_DT))
 		return (EINVAL);
 	if ((cm->cm_fromunit > (softc->sc_counts[cm->cm_fromtype] - 1)) ||
 	    (cm->cm_tounit > (softc->sc_counts[cm->cm_totype] - 1)))
 		return (ENODEV);
 
 	/*
 	 * Check the request against the changer's capabilities.
 	 */
 	if ((softc->sc_movemask[cm->cm_fromtype] & (1 << cm->cm_totype)) == 0)
 		return (ENODEV);
 
 	/*
 	 * Calculate the source and destination elements.
 	 */
 	fromelem = softc->sc_firsts[cm->cm_fromtype] + cm->cm_fromunit;
 	toelem = softc->sc_firsts[cm->cm_totype] + cm->cm_tounit;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_move_medium(&ccb->csio,
 			 /* retries */ 1,
 			 /* cbfcnp */ chdone,
 			 /* tag_action */ MSG_SIMPLE_Q_TAG,
 			 /* tea */ softc->sc_picker,
 			 /* src */ fromelem,
 			 /* dst */ toelem,
 			 /* invert */ (cm->cm_flags & CM_INVERT) ? TRUE : FALSE,
 			 /* sense_len */ SSD_FULL_SIZE,
 			 /* timeout */ CH_TIMEOUT_MOVE_MEDIUM);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	xpt_release_ccb(ccb);
 
 	return(error);
 }
 
 static int
 chexchange(struct cam_periph *periph, struct changer_exchange *ce)
 {
 	struct ch_softc *softc;
 	u_int16_t src, dst1, dst2;
 	union ccb *ccb;
 	int error;
 
 	error = 0;
 	softc = (struct ch_softc *)periph->softc;
 	/*
 	 * Check arguments.
 	 */
 	if ((ce->ce_srctype > CHET_DT) || (ce->ce_fdsttype > CHET_DT) ||
 	    (ce->ce_sdsttype > CHET_DT))
 		return (EINVAL);
 	if ((ce->ce_srcunit > (softc->sc_counts[ce->ce_srctype] - 1)) ||
 	    (ce->ce_fdstunit > (softc->sc_counts[ce->ce_fdsttype] - 1)) ||
 	    (ce->ce_sdstunit > (softc->sc_counts[ce->ce_sdsttype] - 1)))
 		return (ENODEV);
 
 	/*
 	 * Check the request against the changer's capabilities.
 	 */
 	if (((softc->sc_exchangemask[ce->ce_srctype] &
 	     (1 << ce->ce_fdsttype)) == 0) ||
 	    ((softc->sc_exchangemask[ce->ce_fdsttype] &
 	     (1 << ce->ce_sdsttype)) == 0))
 		return (ENODEV);
 
 	/*
 	 * Calculate the source and destination elements.
 	 */
 	src = softc->sc_firsts[ce->ce_srctype] + ce->ce_srcunit;
 	dst1 = softc->sc_firsts[ce->ce_fdsttype] + ce->ce_fdstunit;
 	dst2 = softc->sc_firsts[ce->ce_sdsttype] + ce->ce_sdstunit;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_exchange_medium(&ccb->csio,
 			     /* retries */ 1,
 			     /* cbfcnp */ chdone,
 			     /* tag_action */ MSG_SIMPLE_Q_TAG,
 			     /* tea */ softc->sc_picker,
 			     /* src */ src,
 			     /* dst1 */ dst1,
 			     /* dst2 */ dst2,
 			     /* invert1 */ (ce->ce_flags & CE_INVERT1) ?
 			                   TRUE : FALSE,
 			     /* invert2 */ (ce->ce_flags & CE_INVERT2) ?
 			                   TRUE : FALSE,
 			     /* sense_len */ SSD_FULL_SIZE,
 			     /* timeout */ CH_TIMEOUT_EXCHANGE_MEDIUM);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	xpt_release_ccb(ccb);
 
 	return(error);
 }
 
 static int
 chposition(struct cam_periph *periph, struct changer_position *cp)
 {
 	struct ch_softc *softc;
 	u_int16_t dst;
 	union ccb *ccb;
 	int error;
 
 	error = 0;
 	softc = (struct ch_softc *)periph->softc;
 
 	/*
 	 * Check arguments.
 	 */
 	if (cp->cp_type > CHET_DT)
 		return (EINVAL);
 	if (cp->cp_unit > (softc->sc_counts[cp->cp_type] - 1))
 		return (ENODEV);
 
 	/*
 	 * Calculate the destination element.
 	 */
 	dst = softc->sc_firsts[cp->cp_type] + cp->cp_unit;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_position_to_element(&ccb->csio,
 				 /* retries */ 1,
 				 /* cbfcnp */ chdone,
 				 /* tag_action */ MSG_SIMPLE_Q_TAG,
 				 /* tea */ softc->sc_picker,
 				 /* dst */ dst,
 				 /* invert */ (cp->cp_flags & CP_INVERT) ?
 					      TRUE : FALSE,
 				 /* sense_len */ SSD_FULL_SIZE,
 				 /* timeout */ CH_TIMEOUT_POSITION_TO_ELEMENT);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	xpt_release_ccb(ccb);
 
 	return(error);
 }
 
 /*
  * Copy a volume tag to a volume_tag struct, converting SCSI byte order
  * to host native byte order in the volume serial number.  The volume
  * label as returned by the changer is transferred to user mode as
  * nul-terminated string.  Volume labels are truncated at the first
  * space, as suggested by SCSI-2.
  */
 static	void
 copy_voltag(struct changer_voltag *uvoltag, struct volume_tag *voltag)
 {
 	int i;
 	for (i=0; ivif[i];
 		if (c && c != ' ')
 			uvoltag->cv_volid[i] = c;
 	        else
 			break;
 	}
 	uvoltag->cv_serial = scsi_2btoul(voltag->vsn);
 }
 
 /*
- * Copy an an element status descriptor to a user-mode
+ * Copy an element status descriptor to a user-mode
  * changer_element_status structure.
  */
-
-static	void
+static void
 copy_element_status(struct ch_softc *softc,
 		    u_int16_t flags,
 		    struct read_element_status_descriptor *desc,
-		    struct changer_element_status *ces)
+		    struct changer_element_status *ces,
+		    int scsi_version)
 {
 	u_int16_t eaddr = scsi_2btoul(desc->eaddr);
 	u_int16_t et;
+	struct volume_tag *pvol_tag = NULL, *avol_tag = NULL;
+	struct read_element_status_device_id *devid = NULL;
 
 	ces->ces_int_addr = eaddr;
 	/* set up logical address in element status */
 	for (et = CHET_MT; et <= CHET_DT; et++) {
 		if ((softc->sc_firsts[et] <= eaddr)
 		    && ((softc->sc_firsts[et] + softc->sc_counts[et])
 			> eaddr)) {
 			ces->ces_addr = eaddr - softc->sc_firsts[et];
 			ces->ces_type = et;
 			break;
 		}
 	}
 
 	ces->ces_flags = desc->flags1;
 
 	ces->ces_sensecode = desc->sense_code;
 	ces->ces_sensequal = desc->sense_qual;
 
 	if (desc->flags2 & READ_ELEMENT_STATUS_INVERT)
 		ces->ces_flags |= CES_INVERT;
 
 	if (desc->flags2 & READ_ELEMENT_STATUS_SVALID) {
 
 		eaddr = scsi_2btoul(desc->ssea);
 
 		/* convert source address to logical format */
 		for (et = CHET_MT; et <= CHET_DT; et++) {
 			if ((softc->sc_firsts[et] <= eaddr)
 			    && ((softc->sc_firsts[et] + softc->sc_counts[et])
 				> eaddr)) {
-				ces->ces_source_addr = 
+				ces->ces_source_addr =
 					eaddr - softc->sc_firsts[et];
 				ces->ces_source_type = et;
 				ces->ces_flags |= CES_SOURCE_VALID;
 				break;
 			}
 		}
 
 		if (!(ces->ces_flags & CES_SOURCE_VALID))
 			printf("ch: warning: could not map element source "
 			       "address %ud to a valid element type\n",
 			       eaddr);
 	}
-			
 
+	/*
+	 * pvoltag and avoltag are common between SCSI-2 and later versions
+	 */
 	if (flags & READ_ELEMENT_STATUS_PVOLTAG)
-		copy_voltag(&(ces->ces_pvoltag), &(desc->pvoltag));
+		pvol_tag = &desc->voltag_devid.pvoltag;
 	if (flags & READ_ELEMENT_STATUS_AVOLTAG)
-		copy_voltag(&(ces->ces_avoltag), &(desc->avoltag));
+		avol_tag = (flags & READ_ELEMENT_STATUS_PVOLTAG) ?
+		    &desc->voltag_devid.voltag[1] :&desc->voltag_devid.pvoltag;
+	/*
+	 * For SCSI-3 and later, element status can carry designator and
+	 * other information.
+	 */
+	if (scsi_version >= SCSI_REV_SPC) {
+		if ((flags & READ_ELEMENT_STATUS_PVOLTAG) ^
+		    (flags & READ_ELEMENT_STATUS_AVOLTAG))
+			devid = &desc->voltag_devid.pvol_and_devid.devid;
+		else if (!(flags & READ_ELEMENT_STATUS_PVOLTAG) &&
+			 !(flags & READ_ELEMENT_STATUS_AVOLTAG))
+			devid = &desc->voltag_devid.devid;
+		else /* Have both PVOLTAG and AVOLTAG */
+			devid = &desc->voltag_devid.vol_tags_and_devid.devid;
+	}
 
-	if (desc->dt_scsi_flags & READ_ELEMENT_STATUS_DT_IDVALID) {
-		ces->ces_flags |= CES_SCSIID_VALID;
-		ces->ces_scsi_id = desc->dt_scsi_addr;
+	if (pvol_tag)
+		copy_voltag(&(ces->ces_pvoltag), pvol_tag);
+	if (avol_tag)
+		copy_voltag(&(ces->ces_pvoltag), avol_tag);
+	if (devid != NULL) {
+		if (devid->designator_length > 0) {
+			bcopy((void *)devid->designator,
+			      (void *)ces->ces_designator,
+			      devid->designator_length);
+			ces->ces_designator_length = devid->designator_length;
+			/*
+			 * Make sure we are always NUL terminated.  The
+			 * buffer should be sized for the maximum
+			 * designator length plus 1, but this will make sure
+			 * there is always a NUL at the end.  This won't
+			 * matter for the binary code set, since the user
+			 * will only pay attention to the length field.
+			 */
+			ces->ces_designator[
+			    MIN(sizeof(ces->ces_designator) - 1,
+			    devid->designator_length)]= '\0';
+		}
+		if (devid->piv_assoc_designator_type &
+		    READ_ELEMENT_STATUS_PIV_SET) {
+			ces->ces_flags |= CES_PIV;
+			ces->ces_protocol_id =
+			    READ_ELEMENT_STATUS_PROTOCOL_ID(
+			    devid->prot_code_set);
+		}
+		ces->ces_code_set =
+		    READ_ELEMENT_STATUS_CODE_SET(devid->prot_code_set);
+		ces->ces_assoc = READ_ELEMENT_STATUS_ASSOCIATION(
+		    devid->piv_assoc_designator_type);
+		ces->ces_designator_type = READ_ELEMENT_STATUS_DESIGNATOR_TYPE(
+		    devid->piv_assoc_designator_type);
+	} else if (scsi_version > SCSI_REV_2) {
+		/* SCSI-SPC and No devid, no designator */
+		ces->ces_designator_length = 0;
+		ces->ces_designator[0] = '\0';
+		ces->ces_protocol_id = CES_PROTOCOL_ID_FCP_4;
 	}
 
-	if (desc->dt_scsi_addr & READ_ELEMENT_STATUS_DT_LUVALID) {
-		ces->ces_flags |= CES_LUN_VALID;
-		ces->ces_scsi_lun = 
-			desc->dt_scsi_flags & READ_ELEMENT_STATUS_DT_LUNMASK;
+	if (scsi_version <= SCSI_REV_2) {
+		if (desc->dt_or_obsolete.scsi_2.dt_scsi_flags &
+		    READ_ELEMENT_STATUS_DT_IDVALID) {
+			ces->ces_flags |= CES_SCSIID_VALID;
+			ces->ces_scsi_id =
+			    desc->dt_or_obsolete.scsi_2.dt_scsi_addr;
+		}
+
+		if (desc->dt_or_obsolete.scsi_2.dt_scsi_addr &
+		    READ_ELEMENT_STATUS_DT_LUVALID) {
+			ces->ces_flags |= CES_LUN_VALID;
+			ces->ces_scsi_lun =
+			    desc->dt_or_obsolete.scsi_2.dt_scsi_flags &
+			    READ_ELEMENT_STATUS_DT_LUNMASK;
+		}
 	}
 }
 
 static int
-chgetelemstatus(struct cam_periph *periph, 
+chgetelemstatus(struct cam_periph *periph, int scsi_version, u_long cmd,
 		struct changer_element_status_request *cesr)
 {
 	struct read_element_status_header *st_hdr;
 	struct read_element_status_page_header *pg_hdr;
 	struct read_element_status_descriptor *desc;
 	caddr_t data = NULL;
 	size_t size, desclen;
 	int avail, i, error = 0;
 	struct changer_element_status *user_data = NULL;
 	struct ch_softc *softc;
 	union ccb *ccb;
 	int chet = cesr->cesr_element_type;
 	int want_voltags = (cesr->cesr_flags & CESR_VOLTAGS) ? 1 : 0;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	/* perform argument checking */
 
 	/*
 	 * Perform a range check on the cesr_element_{base,count}
 	 * request argument fields.
 	 */
 	if ((softc->sc_counts[chet] - cesr->cesr_element_base) <= 0
 	    || (cesr->cesr_element_base + cesr->cesr_element_count)
 	        > softc->sc_counts[chet])
 		return (EINVAL);
 
 	/*
 	 * Request one descriptor for the given element type.  This
 	 * is used to determine the size of the descriptor so that
 	 * we can allocate enough storage for all of them.  We assume
 	 * that the first one can fit into 1k.
 	 */
 	cam_periph_unlock(periph);
 	data = (caddr_t)malloc(1024, M_DEVBUF, M_WAITOK);
 
 	cam_periph_lock(periph);
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_read_element_status(&ccb->csio,
 				 /* retries */ 1,
 				 /* cbfcnp */ chdone,
 				 /* tag_action */ MSG_SIMPLE_Q_TAG,
 				 /* voltag */ want_voltags,
 				 /* sea */ softc->sc_firsts[chet],
+				 /* dvcid */ 1,
+				 /* curdata */ 1,
 				 /* count */ 1,
 				 /* data_ptr */ data,
 				 /* dxfer_len */ 1024,
 				 /* sense_len */ SSD_FULL_SIZE,
 				 /* timeout */ CH_TIMEOUT_READ_ELEMENT_STATUS);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	if (error)
 		goto done;
 	cam_periph_unlock(periph);
 
 	st_hdr = (struct read_element_status_header *)data;
 	pg_hdr = (struct read_element_status_page_header *)((uintptr_t)st_hdr +
 		  sizeof(struct read_element_status_header));
 	desclen = scsi_2btoul(pg_hdr->edl);
 
 	size = sizeof(struct read_element_status_header) +
 	       sizeof(struct read_element_status_page_header) +
 	       (desclen * cesr->cesr_element_count);
-
 	/*
 	 * Reallocate storage for descriptors and get them from the
 	 * device.
 	 */
 	free(data, M_DEVBUF);
 	data = (caddr_t)malloc(size, M_DEVBUF, M_WAITOK);
 
 	cam_periph_lock(periph);
 	scsi_read_element_status(&ccb->csio,
 				 /* retries */ 1,
 				 /* cbfcnp */ chdone,
 				 /* tag_action */ MSG_SIMPLE_Q_TAG,
 				 /* voltag */ want_voltags,
 				 /* sea */ softc->sc_firsts[chet]
 				 + cesr->cesr_element_base,
+				 /* dvcid */ 1,
+				 /* curdata */ 1,
 				 /* count */ cesr->cesr_element_count,
 				 /* data_ptr */ data,
 				 /* dxfer_len */ size,
 				 /* sense_len */ SSD_FULL_SIZE,
 				 /* timeout */ CH_TIMEOUT_READ_ELEMENT_STATUS);
-	
+
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	if (error)
 		goto done;
 	cam_periph_unlock(periph);
 
 	/*
 	 * Fill in the user status array.
 	 */
 	st_hdr = (struct read_element_status_header *)data;
 	pg_hdr = (struct read_element_status_page_header *)((uintptr_t)st_hdr +
 		  sizeof(struct read_element_status_header));
 	avail = scsi_2btoul(st_hdr->count);
 
 	if (avail != cesr->cesr_element_count) {
 		xpt_print(periph->path,
 		    "warning, READ ELEMENT STATUS avail != count\n");
 	}
 
 	user_data = (struct changer_element_status *)
 		malloc(avail * sizeof(struct changer_element_status),
 		       M_DEVBUF, M_WAITOK | M_ZERO);
 
 	desc = (struct read_element_status_descriptor *)((uintptr_t)data +
 		sizeof(struct read_element_status_header) +
 		sizeof(struct read_element_status_page_header));
 	/*
 	 * Set up the individual element status structures
 	 */
 	for (i = 0; i < avail; ++i) {
-		struct changer_element_status *ces = &(user_data[i]);
+		struct changer_element_status *ces;
 
-		copy_element_status(softc, pg_hdr->flags, desc, ces);
+		/*
+		 * In the changer_element_status structure, fields from
+		 * the beginning to the field of ces_scsi_lun are common
+		 * between SCSI-2 and SCSI-3, while all the rest are new
+		 * from SCSI-3. In order to maintain backward compatibility
+		 * of the chio command, the ces pointer, below, is computed
+		 * such that it lines up with the structure boundary
+		 * corresponding to the SCSI version.
+		 */
+		ces = cmd == OCHIOGSTATUS ?
+		    (struct changer_element_status *)
+		    ((unsigned char *)user_data + i *
+		     (offsetof(struct changer_element_status,ces_scsi_lun)+1)):
+		    &user_data[i];
 
+		copy_element_status(softc, pg_hdr->flags, desc,
+				    ces, scsi_version);
+
 		desc = (struct read_element_status_descriptor *)
-		       ((uintptr_t)desc + desclen);
+		       ((unsigned char *)desc + desclen);
 	}
 
 	/* Copy element status structures out to userspace. */
-	error = copyout(user_data,
-			cesr->cesr_element_status,
-			avail * sizeof(struct changer_element_status));
+	if (cmd == OCHIOGSTATUS)
+		error = copyout(user_data,
+				cesr->cesr_element_status,
+				avail* (offsetof(struct changer_element_status,
+				ces_scsi_lun) + 1));
+	else
+		error = copyout(user_data,
+				cesr->cesr_element_status,
+				avail * sizeof(struct changer_element_status));
+
 	cam_periph_lock(periph);
 
  done:
 	xpt_release_ccb(ccb);
 
 	if (data != NULL)
 		free(data, M_DEVBUF);
 	if (user_data != NULL)
 		free(user_data, M_DEVBUF);
 
 	return (error);
 }
 
 static int
 chielem(struct cam_periph *periph,
 	unsigned int timeout)
 {
 	union ccb *ccb;
 	struct ch_softc *softc;
 	int error;
 
 	if (!timeout) {
 		timeout = CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS;
 	} else {
 		timeout *= 1000;
 	}
 
 	error = 0;
 	softc = (struct ch_softc *)periph->softc;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_initialize_element_status(&ccb->csio,
 				      /* retries */ 1,
 				      /* cbfcnp */ chdone,
 				      /* tag_action */ MSG_SIMPLE_Q_TAG,
 				      /* sense_len */ SSD_FULL_SIZE,
 				      /* timeout */ timeout);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	xpt_release_ccb(ccb);
 
 	return(error);
 }
 
 static int
 chsetvoltag(struct cam_periph *periph,
 	    struct changer_set_voltag_request *csvr)
 {
 	union ccb *ccb;
 	struct ch_softc *softc;
 	u_int16_t ea;
 	u_int8_t sac;
 	struct scsi_send_volume_tag_parameters ssvtp;
 	int error;
 	int i;
 
 	error = 0;
 	softc = (struct ch_softc *)periph->softc;
 
 	bzero(&ssvtp, sizeof(ssvtp));
 	for (i=0; icsvr_type > CHET_DT)
 		return EINVAL;
 	if (csvr->csvr_addr > (softc->sc_counts[csvr->csvr_type] - 1))
 		return ENODEV;
 
 	ea = softc->sc_firsts[csvr->csvr_type] + csvr->csvr_addr;
 
 	if (csvr->csvr_flags & CSVR_ALTERNATE) {
 		switch (csvr->csvr_flags & CSVR_MODE_MASK) {
 		case CSVR_MODE_SET:
 			sac = SEND_VOLUME_TAG_ASSERT_ALTERNATE;
 			break;
 		case CSVR_MODE_REPLACE:
 			sac = SEND_VOLUME_TAG_REPLACE_ALTERNATE;
 			break;
 		case CSVR_MODE_CLEAR:
 			sac = SEND_VOLUME_TAG_UNDEFINED_ALTERNATE;
 			break;
 		default:
 			error = EINVAL;
 			goto out;
 		}
 	} else {
 		switch (csvr->csvr_flags & CSVR_MODE_MASK) {
 		case CSVR_MODE_SET:
 			sac = SEND_VOLUME_TAG_ASSERT_PRIMARY;
 			break;
 		case CSVR_MODE_REPLACE:
 			sac = SEND_VOLUME_TAG_REPLACE_PRIMARY;
 			break;
 		case CSVR_MODE_CLEAR:
 			sac = SEND_VOLUME_TAG_UNDEFINED_PRIMARY;
 			break;
 		default:
 			error = EINVAL;
 			goto out;
 		}
 	}
 
 	memcpy(ssvtp.vitf, csvr->csvr_voltag.cv_volid,
 	       min(strlen(csvr->csvr_voltag.cv_volid), sizeof(ssvtp.vitf)));
 	scsi_ulto2b(csvr->csvr_voltag.cv_serial, ssvtp.minvsn);
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	scsi_send_volume_tag(&ccb->csio,
 			     /* retries */ 1,
 			     /* cbfcnp */ chdone,
 			     /* tag_action */ MSG_SIMPLE_Q_TAG,
 			     /* element_address */ ea,
 			     /* send_action_code */ sac,
 			     /* parameters */ &ssvtp,
 			     /* sense_len */ SSD_FULL_SIZE,
 			     /* timeout */ CH_TIMEOUT_SEND_VOLTAG);
 	
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /*sense_flags*/ SF_RETRY_UA,
 				  softc->device_stats);
 
 	xpt_release_ccb(ccb);
 
  out:
 	return error;
 }
 
 static int
 chgetparams(struct cam_periph *periph)
 {
 	union ccb *ccb;
 	struct ch_softc *softc;
 	void *mode_buffer;
 	int mode_buffer_len;
 	struct page_element_address_assignment *ea;
 	struct page_device_capabilities *cap;
 	int error, from, dbd;
 	u_int8_t *moves, *exchanges;
 
 	error = 0;
 
 	softc = (struct ch_softc *)periph->softc;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
 
 	/*
 	 * The scsi_mode_sense_data structure is just a convenience
 	 * structure that allows us to easily calculate the worst-case
 	 * storage size of the mode sense buffer.
 	 */
 	mode_buffer_len = sizeof(struct scsi_mode_sense_data);
 
 	mode_buffer = malloc(mode_buffer_len, M_SCSICH, M_NOWAIT);
 
 	if (mode_buffer == NULL) {
 		printf("chgetparams: couldn't malloc mode sense data\n");
 		return(ENOSPC);
 	}
 
 	bzero(mode_buffer, mode_buffer_len);
 
 	if (softc->quirks & CH_Q_NO_DBD)
 		dbd = FALSE;
 	else
 		dbd = TRUE;
 
 	/*
 	 * Get the element address assignment page.
 	 */
 	scsi_mode_sense(&ccb->csio,
 			/* retries */ 1,
 			/* cbfcnp */ chdone,
 			/* tag_action */ MSG_SIMPLE_Q_TAG,
 			/* dbd */ dbd,
 			/* page_code */ SMS_PAGE_CTRL_CURRENT,
 			/* page */ CH_ELEMENT_ADDR_ASSIGN_PAGE,
 			/* param_buf */ (u_int8_t *)mode_buffer,
 			/* param_len */ mode_buffer_len,
 			/* sense_len */ SSD_FULL_SIZE,
 			/* timeout */ CH_TIMEOUT_MODE_SENSE);
 
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /* sense_flags */ SF_RETRY_UA|SF_NO_PRINT,
 				  softc->device_stats);
 
 	if (error) {
 		if (dbd) {
 			struct scsi_mode_sense_6 *sms;
 
 			sms = (struct scsi_mode_sense_6 *)
 				ccb->csio.cdb_io.cdb_bytes;
 
 			sms->byte2 &= ~SMS_DBD;
 			error = cam_periph_runccb(ccb, cherror,
 						  /*cam_flags*/ CAM_RETRY_SELTO,
 				  		  /*sense_flags*/ SF_RETRY_UA,
 						  softc->device_stats);
 		} else {
 			/*
 			 * Since we disabled sense printing above, print
 			 * out the sense here since we got an error.
 			 */
 			scsi_sense_print(&ccb->csio);
 		}
 
 		if (error) {
 			xpt_print(periph->path,
 			    "chgetparams: error getting element "
 			    "address page\n");
 			xpt_release_ccb(ccb);
 			free(mode_buffer, M_SCSICH);
 			return(error);
 		}
 	}
 
 	ea = (struct page_element_address_assignment *)
 		find_mode_page_6((struct scsi_mode_header_6 *)mode_buffer);
 
 	softc->sc_firsts[CHET_MT] = scsi_2btoul(ea->mtea);
 	softc->sc_counts[CHET_MT] = scsi_2btoul(ea->nmte);
 	softc->sc_firsts[CHET_ST] = scsi_2btoul(ea->fsea);
 	softc->sc_counts[CHET_ST] = scsi_2btoul(ea->nse);
 	softc->sc_firsts[CHET_IE] = scsi_2btoul(ea->fieea);
 	softc->sc_counts[CHET_IE] = scsi_2btoul(ea->niee);
 	softc->sc_firsts[CHET_DT] = scsi_2btoul(ea->fdtea);
 	softc->sc_counts[CHET_DT] = scsi_2btoul(ea->ndte);
 
 	bzero(mode_buffer, mode_buffer_len);
 
 	/*
 	 * Now get the device capabilities page.
 	 */
 	scsi_mode_sense(&ccb->csio,
 			/* retries */ 1,
 			/* cbfcnp */ chdone,
 			/* tag_action */ MSG_SIMPLE_Q_TAG,
 			/* dbd */ dbd,
 			/* page_code */ SMS_PAGE_CTRL_CURRENT,
 			/* page */ CH_DEVICE_CAP_PAGE,
 			/* param_buf */ (u_int8_t *)mode_buffer,
 			/* param_len */ mode_buffer_len,
 			/* sense_len */ SSD_FULL_SIZE,
 			/* timeout */ CH_TIMEOUT_MODE_SENSE);
 	
 	error = cam_periph_runccb(ccb, cherror, /*cam_flags*/ CAM_RETRY_SELTO,
 				  /* sense_flags */ SF_RETRY_UA | SF_NO_PRINT,
 				  softc->device_stats);
 
 	if (error) {
 		if (dbd) {
 			struct scsi_mode_sense_6 *sms;
 
 			sms = (struct scsi_mode_sense_6 *)
 				ccb->csio.cdb_io.cdb_bytes;
 
 			sms->byte2 &= ~SMS_DBD;
 			error = cam_periph_runccb(ccb, cherror,
 						  /*cam_flags*/ CAM_RETRY_SELTO,
 				  		  /*sense_flags*/ SF_RETRY_UA,
 						  softc->device_stats);
 		} else {
 			/*
 			 * Since we disabled sense printing above, print
 			 * out the sense here since we got an error.
 			 */
 			scsi_sense_print(&ccb->csio);
 		}
 
 		if (error) {
 			xpt_print(periph->path,
 			    "chgetparams: error getting device "
 			    "capabilities page\n");
 			xpt_release_ccb(ccb);
 			free(mode_buffer, M_SCSICH);
 			return(error);
 		}
 	}
 
 	xpt_release_ccb(ccb);
 
 	cap = (struct page_device_capabilities *)
 		find_mode_page_6((struct scsi_mode_header_6 *)mode_buffer);
 
 	bzero(softc->sc_movemask, sizeof(softc->sc_movemask));
 	bzero(softc->sc_exchangemask, sizeof(softc->sc_exchangemask));
 	moves = cap->move_from;
 	exchanges = cap->exchange_with;
 	for (from = CHET_MT; from <= CHET_MAX; ++from) {
 		softc->sc_movemask[from] = moves[from];
 		softc->sc_exchangemask[from] = exchanges[from];
 	}
 
 	free(mode_buffer, M_SCSICH);
 
 	return(error);
 }
 
+static int
+chscsiversion(struct cam_periph *periph)
+{
+	struct scsi_inquiry_data *inq_data;
+	struct ccb_getdev *cgd;
+	int dev_scsi_version;
+	struct cam_sim *sim;
+
+	sim = xpt_path_sim(periph->path);
+	mtx_assert(sim->mtx, MA_OWNED);
+	if ((cgd = (struct ccb_getdev *)xpt_alloc_ccb_nowait()) == NULL)
+		return (-1);
+	/*
+	 * Get the device information.
+	 */
+	xpt_setup_ccb(&cgd->ccb_h,
+		      periph->path,
+		      CAM_PRIORITY_NORMAL);
+	cgd->ccb_h.func_code = XPT_GDEV_TYPE;
+	xpt_action((union ccb *)cgd);
+
+	if (cgd->ccb_h.status != CAM_REQ_CMP) {
+		xpt_free_ccb((union ccb *)cgd);
+		return -1;
+	}
+
+	inq_data = &cgd->inq_data;
+	dev_scsi_version = inq_data->version;
+	xpt_free_ccb((union ccb *)cgd);
+
+	return dev_scsi_version;
+}
+
 void
 scsi_move_medium(struct ccb_scsiio *csio, u_int32_t retries,
 		 void (*cbfcnp)(struct cam_periph *, union ccb *),
 		 u_int8_t tag_action, u_int32_t tea, u_int32_t src,
 		 u_int32_t dst, int invert, u_int8_t sense_len,
 		 u_int32_t timeout)
 {
 	struct scsi_move_medium *scsi_cmd;
 
 	scsi_cmd = (struct scsi_move_medium *)&csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = MOVE_MEDIUM;
 
 	scsi_ulto2b(tea, scsi_cmd->tea);
 	scsi_ulto2b(src, scsi_cmd->src);
 	scsi_ulto2b(dst, scsi_cmd->dst);
 
 	if (invert)
 		scsi_cmd->invert |= MOVE_MEDIUM_INVERT;
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_NONE,
 		      tag_action,
 		      /*data_ptr*/ NULL,
 		      /*dxfer_len*/ 0,
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
 
 void
 scsi_exchange_medium(struct ccb_scsiio *csio, u_int32_t retries,
 		     void (*cbfcnp)(struct cam_periph *, union ccb *),
 		     u_int8_t tag_action, u_int32_t tea, u_int32_t src,
 		     u_int32_t dst1, u_int32_t dst2, int invert1,
 		     int invert2, u_int8_t sense_len, u_int32_t timeout)
 {
 	struct scsi_exchange_medium *scsi_cmd;
 
 	scsi_cmd = (struct scsi_exchange_medium *)&csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = EXCHANGE_MEDIUM;
 
 	scsi_ulto2b(tea, scsi_cmd->tea);
 	scsi_ulto2b(src, scsi_cmd->src);
 	scsi_ulto2b(dst1, scsi_cmd->fdst);
 	scsi_ulto2b(dst2, scsi_cmd->sdst);
 
 	if (invert1)
 		scsi_cmd->invert |= EXCHANGE_MEDIUM_INV1;
 
 	if (invert2)
 		scsi_cmd->invert |= EXCHANGE_MEDIUM_INV2;
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_NONE,
 		      tag_action,
 		      /*data_ptr*/ NULL,
 		      /*dxfer_len*/ 0,
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
 
 void
 scsi_position_to_element(struct ccb_scsiio *csio, u_int32_t retries,
 			 void (*cbfcnp)(struct cam_periph *, union ccb *),
 			 u_int8_t tag_action, u_int32_t tea, u_int32_t dst,
 			 int invert, u_int8_t sense_len, u_int32_t timeout)
 {
 	struct scsi_position_to_element *scsi_cmd;
 
 	scsi_cmd = (struct scsi_position_to_element *)&csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = POSITION_TO_ELEMENT;
 
 	scsi_ulto2b(tea, scsi_cmd->tea);
 	scsi_ulto2b(dst, scsi_cmd->dst);
 
 	if (invert)
 		scsi_cmd->invert |= POSITION_TO_ELEMENT_INVERT;
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_NONE,
 		      tag_action,
 		      /*data_ptr*/ NULL,
 		      /*dxfer_len*/ 0,
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
 
 void
 scsi_read_element_status(struct ccb_scsiio *csio, u_int32_t retries,
 			 void (*cbfcnp)(struct cam_periph *, union ccb *),
 			 u_int8_t tag_action, int voltag, u_int32_t sea,
+			 int curdata, int dvcid,
 			 u_int32_t count, u_int8_t *data_ptr,
 			 u_int32_t dxfer_len, u_int8_t sense_len,
 			 u_int32_t timeout)
 {
 	struct scsi_read_element_status *scsi_cmd;
 
 	scsi_cmd = (struct scsi_read_element_status *)&csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = READ_ELEMENT_STATUS;
 
 	scsi_ulto2b(sea, scsi_cmd->sea);
 	scsi_ulto2b(count, scsi_cmd->count);
 	scsi_ulto3b(dxfer_len, scsi_cmd->len);
+	if (dvcid)
+		scsi_cmd->flags |= READ_ELEMENT_STATUS_DVCID;
+	if (curdata)
+		scsi_cmd->flags |= READ_ELEMENT_STATUS_CURDATA;
 
 	if (voltag)
 		scsi_cmd->byte2 |= READ_ELEMENT_STATUS_VOLTAG;
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_IN,
 		      tag_action,
 		      data_ptr,
 		      dxfer_len,
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
 
 void
 scsi_initialize_element_status(struct ccb_scsiio *csio, u_int32_t retries,
 			       void (*cbfcnp)(struct cam_periph *, union ccb *),
 			       u_int8_t tag_action, u_int8_t sense_len,
 			       u_int32_t timeout)
 {
 	struct scsi_initialize_element_status *scsi_cmd;
 
 	scsi_cmd = (struct scsi_initialize_element_status *)
 		    &csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = INITIALIZE_ELEMENT_STATUS;
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_NONE,
 		      tag_action,
 		      /* data_ptr */ NULL,
 		      /* dxfer_len */ 0,
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
 
 void
 scsi_send_volume_tag(struct ccb_scsiio *csio, u_int32_t retries,
 		     void (*cbfcnp)(struct cam_periph *, union ccb *),
 		     u_int8_t tag_action, 
 		     u_int16_t element_address,
 		     u_int8_t send_action_code,
 		     struct scsi_send_volume_tag_parameters *parameters,
 		     u_int8_t sense_len, u_int32_t timeout)
 {
 	struct scsi_send_volume_tag *scsi_cmd;
 
 	scsi_cmd = (struct scsi_send_volume_tag *) &csio->cdb_io.cdb_bytes;
 	bzero(scsi_cmd, sizeof(*scsi_cmd));
 
 	scsi_cmd->opcode = SEND_VOLUME_TAG;
 	scsi_ulto2b(element_address, scsi_cmd->ea);
 	scsi_cmd->sac = send_action_code;
 	scsi_ulto2b(sizeof(*parameters), scsi_cmd->pll);
 
 	cam_fill_csio(csio,
 		      retries,
 		      cbfcnp,
 		      /*flags*/ CAM_DIR_OUT,
 		      tag_action,
 		      /* data_ptr */ (u_int8_t *) parameters,
 		      sizeof(*parameters),
 		      sense_len,
 		      sizeof(*scsi_cmd),
 		      timeout);
 }
Index: user/attilio/vmcontention/sys/cam/scsi/scsi_ch.h
===================================================================
--- user/attilio/vmcontention/sys/cam/scsi/scsi_ch.h	(revision 249698)
+++ user/attilio/vmcontention/sys/cam/scsi/scsi_ch.h	(revision 249699)
@@ -1,477 +1,510 @@
 /* $FreeBSD$ */
 /*	$NetBSD: scsi_changer.h,v 1.11 1998/02/13 08:28:32 enami Exp $	*/
 
 /*-
  * Copyright (c) 1996 Jason R. Thorpe 
  * All rights reserved.
  *
  * Partially based on an autochanger driver written by Stefan Grefen
  * and on an autochanger driver written by the Systems Programming Group
  * at the University of Utah Computer Science Department.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgements:
  *	This product includes software developed by Jason R. Thorpe
  *	for And Communications, http://www.and.com/
  * 4. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 /*
  * SCSI changer interface description
  */
 
 /*-
  * Partially derived from software written by Stefan Grefen
  * (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
  * based on the SCSI System by written Julian Elischer (julian@tfs.com)
  * for TRW Financial Systems.
  *
  * TRW Financial Systems, in accordance with their agreement with Carnegie
  * Mellon University, makes this software available to CMU to distribute
  * or use in any manner that they see fit as long as this message is kept with 
  * the software. For this reason TFS also grants any other persons or
  * organisations permission to use or modify this software.
  *
  * TFS supplies this software to be publicly redistributed
  * on the understanding that TFS is not responsible for the correct
  * functioning of this software in any circumstances.
  *
  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  */
 
 #ifndef _SCSI_SCSI_CH_H
 #define _SCSI_SCSI_CH_H 1
 
 #include 
 
 /*
  * SCSI command format
  */
 
 /*
  * Exchange the medium in the source element with the medium
  * located at the destination element.
  */
 struct scsi_exchange_medium {
 	u_int8_t	opcode;
 #define EXCHANGE_MEDIUM		0xa6
 	u_int8_t	byte2;
 	u_int8_t	tea[2];	/* transport element address */
 	u_int8_t	src[2];	/* source address */
 	u_int8_t	fdst[2]; /* first destination address */
 	u_int8_t	sdst[2]; /* second destination address */
 	u_int8_t	invert;
 #define EXCHANGE_MEDIUM_INV1	0x01
 #define EXCHANGE_MEDIUM_INV2	0x02
 	u_int8_t	control;
 };
 
 /*
  * Cause the medium changer to check all elements for medium and any
  * other status relevant to the element.
  */
 struct scsi_initialize_element_status {
 	u_int8_t	opcode;
 #define INITIALIZE_ELEMENT_STATUS	0x07
 	u_int8_t	byte2;
 	u_int8_t	reserved[3];
 	u_int8_t	control;
 };
 
 /*
  * Request the changer to move a unit of media from the source element
  * to the destination element.
  */
 struct scsi_move_medium {
 	u_int8_t	opcode;
 	u_int8_t	byte2;
 	u_int8_t	tea[2];	/* transport element address */
 	u_int8_t	src[2];	/* source element address */
 	u_int8_t	dst[2];	/* destination element address */
 	u_int8_t	reserved[2];
 	u_int8_t	invert;
 #define MOVE_MEDIUM_INVERT	0x01
 	u_int8_t	control;
 };
 
 /*
  * Position the specified transport element (picker) in front of
  * the destination element specified.
  */
 struct scsi_position_to_element {
 	u_int8_t	opcode;
 	u_int8_t	byte2;
 	u_int8_t	tea[2];	/* transport element address */
 	u_int8_t	dst[2];	/* destination element address */
 	u_int8_t	reserved[2];
 	u_int8_t	invert;
 #define POSITION_TO_ELEMENT_INVERT	0x01
 	u_int8_t	control;
 };
 
 /*
  * Request that the changer report the status of its internal elements.
  */
 struct scsi_read_element_status {
 	u_int8_t	opcode;
 	u_int8_t	byte2;
-#define READ_ELEMENT_STATUS_VOLTAG	0x10	/* report volume tag info */
+#define	READ_ELEMENT_STATUS_VOLTAG	0x10	/* report volume tag info */
 	/* ...next 4 bits are an element type code... */
 	u_int8_t	sea[2];	/* starting element address */
 	u_int8_t	count[2]; /* number of elements */
-	u_int8_t	reserved0;
+	u_int8_t	flags;
+#define	READ_ELEMENT_STATUS_DVCID	0x01 /* report device serial number */
+#define	READ_ELEMENT_STATUS_CURDATA	0x02 /* allow motion during command */
+
 	u_int8_t	len[3];	/* length of data buffer */
 	u_int8_t	reserved1;
 	u_int8_t	control;
 };
 
 struct scsi_request_volume_element_address {
 	u_int8_t	opcode;
 	u_int8_t	byte2;
-#define REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG	0x10
+#define	REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG	0x10
 	/* ...next 4 bits are an element type code... */
 	u_int8_t	eaddr[2];	/* element address */
 	u_int8_t	count[2];	/* number of elements */
 	u_int8_t	reserved0;
 	u_int8_t	len[3];		/* length of data buffer */
 	u_int8_t	reserved1;
 	u_int8_t	control;
 };
 
 /* XXX scsi_release */
 
 /*
  * Changer-specific mode page numbers.
  */
 #define	CH_ELEMENT_ADDR_ASSIGN_PAGE	0x1D
 #define	CH_TRANS_GEOM_PARAMS_PAGE	0x1E
 #define	CH_DEVICE_CAP_PAGE		0x1F
 
 /*
  * Data returned by READ ELEMENT STATUS consists of an 8-byte header
  * followed by one or more read_element_status_pages.
  */
 struct read_element_status_header {
 	u_int8_t	fear[2];  /* first element address reported */
 	u_int8_t	count[2]; /* number of elements available */
 	u_int8_t	reserved;
 	u_int8_t	nbytes[3]; /* byte count of all pages */
 };
 
 struct read_element_status_page_header {
 	u_int8_t	type;	/* element type code; see type codes below */
 	u_int8_t	flags;
-#define READ_ELEMENT_STATUS_AVOLTAG	0x40
-#define READ_ELEMENT_STATUS_PVOLTAG	0x80
+#define	READ_ELEMENT_STATUS_AVOLTAG	0x40
+#define	READ_ELEMENT_STATUS_PVOLTAG	0x80
 	u_int8_t	edl[2];	/* element descriptor length */
 	u_int8_t	reserved;
 	u_int8_t	nbytes[3]; /* byte count of all descriptors */
 };
 
 /*
  * Format of a volume tag
  */
 
 struct volume_tag {
 	u_int8_t	vif[32];	/* volume identification field */
 	u_int8_t	reserved[2];
 	u_int8_t	vsn[2];		/* volume sequence number */
 };
 
+struct read_element_status_device_id {
+	u_int8_t	prot_code_set;
+#define	READ_ELEMENT_STATUS_CODE_SET(p) ((p) & 0x0F)
+#define	READ_ELEMENT_STATUS_PROTOCOL_ID(p) ((p) >> 4)
+
+	u_int8_t	piv_assoc_designator_type;
+#define	READ_ELEMENT_STATUS_PIV_SET 0x80
+#define	READ_ELEMENT_STATUS_ASSOCIATION(p) ((p) >> 4)
+#define	READ_ELEMENT_STATUS_DESIGNATOR_TYPE(p) ((p) & 0x0F)
+
+	u_int8_t	reserved2;
+	u_int8_t	designator_length;
+	u_int8_t	designator[256]; /* Allocate max length */
+};
+
 struct read_element_status_descriptor {
 	u_int8_t	eaddr[2];	/* element address */
 	u_int8_t	flags1;
 
-#define READ_ELEMENT_STATUS_FULL	0x01
-#define READ_ELEMENT_STATUS_IMPEXP	0x02
-#define READ_ELEMENT_STATUS_EXCEPT	0x04
-#define READ_ELEMENT_STATUS_ACCESS	0x08
-#define READ_ELEMENT_STATUS_EXENAB	0x10
-#define READ_ELEMENT_STATUS_INENAB	0x20
+#define	READ_ELEMENT_STATUS_FULL	0x01
+#define	READ_ELEMENT_STATUS_IMPEXP	0x02
+#define	READ_ELEMENT_STATUS_EXCEPT	0x04
+#define	READ_ELEMENT_STATUS_ACCESS	0x08
+#define	READ_ELEMENT_STATUS_EXENAB	0x10
+#define	READ_ELEMENT_STATUS_INENAB	0x20
 
-#define READ_ELEMENT_STATUS_MT_MASK1	0x05
-#define READ_ELEMENT_STATUS_ST_MASK1	0x0c
-#define READ_ELEMENT_STATUS_IE_MASK1	0x3f
-#define READ_ELEMENT_STATUS_DT_MASK1	0x0c
+#define	READ_ELEMENT_STATUS_MT_MASK1	0x05
+#define	READ_ELEMENT_STATUS_ST_MASK1	0x0c
+#define	READ_ELEMENT_STATUS_IE_MASK1	0x3f
+#define	READ_ELEMENT_STATUS_DT_MASK1	0x0c
 
 	u_int8_t	reserved0;
 	u_int8_t	sense_code;
 	u_int8_t	sense_qual;
 
-	/*
-	 * dt_scsi_flags and dt_scsi_addr are valid only on data transport
-	 * elements.  These bytes are undefined for all other element types.
-	 */
-	u_int8_t	dt_scsi_flags;
+	union {
+		struct {
+			u_int8_t	dt_scsi_flags;
 
-#define READ_ELEMENT_STATUS_DT_LUNMASK	0x07
-#define READ_ELEMENT_STATUS_DT_LUVALID	0x10
-#define READ_ELEMENT_STATUS_DT_IDVALID	0x20
-#define READ_ELEMENT_STATUS_DT_NOTBUS	0x80
+#define	READ_ELEMENT_STATUS_DT_LUNMASK	0x07
+#define	READ_ELEMENT_STATUS_DT_LUVALID	0x10
+#define	READ_ELEMENT_STATUS_DT_IDVALID	0x20
+#define	READ_ELEMENT_STATUS_DT_NOTBUS	0x80
 
-	u_int8_t	dt_scsi_addr;
+			u_int8_t	dt_scsi_addr;
+			u_int8_t	reserved1;
+		} scsi_2;
 
-	u_int8_t	reserved1;
+		/* reserved and obsolete (as of SCSI-3) fields */
+		u_int8_t	reserved_or_obsolete[3];
+	} dt_or_obsolete;
 
 	u_int8_t	flags2;
-#define READ_ELEMENT_STATUS_INVERT	0x40
-#define READ_ELEMENT_STATUS_SVALID	0x80
+#define	READ_ELEMENT_STATUS_INVERT		0x40
+#define	READ_ELEMENT_STATUS_SVALID		0x80
+#define	READ_ELEMENT_STATUS_ED			0x80
+#define	READ_ELEMENT_STATUS_MEDIA_TYPE_MASK	0x07
+
 	u_int8_t	ssea[2];	/* source storage element address */
 
-	struct volume_tag pvoltag;	/* omitted if PVOLTAG == 0 */
-	struct volume_tag avoltag;	/* omitted if AVOLTAG == 0 */
-
-	/* Other data may follow */
+	union {
+		struct volume_tag			pvoltag;
+		struct volume_tag 			voltag[2];
+		struct read_element_status_device_id	devid;
+		struct {
+			struct volume_tag			pvoltag;
+			struct read_element_status_device_id	devid;
+		} pvol_and_devid;
+		struct {
+			struct volume_tag			voltag[2];
+			struct read_element_status_device_id	devid;
+		} vol_tags_and_devid;
+	} voltag_devid;
 };
 
 /* XXX add data returned by REQUEST VOLUME ELEMENT ADDRESS */
 
 /* Element type codes */
 #define ELEMENT_TYPE_MASK	0x0f	/* Note: these aren't bits */
 #define ELEMENT_TYPE_ALL	0x00
 #define ELEMENT_TYPE_MT		0x01
 #define ELEMENT_TYPE_ST		0x02
 #define ELEMENT_TYPE_IE		0x03
 #define ELEMENT_TYPE_DT		0x04
 
 /*
  * XXX The following definitions should be common to all SCSI device types.
  */
 #define PGCODE_MASK	0x3f	/* valid page number bits in pg_code */
 #define PGCODE_PS	0x80	/* indicates page is savable */
 
 /*
  * Send volume tag information to the changer
  */
 
 struct scsi_send_volume_tag {
 	u_int8_t	opcode;
 #define SEND_VOLUME_TAG	0xb6
 	u_int8_t	byte2;
 	u_int8_t	ea[2];		/* element address */
 	u_int8_t	reserved2;
   	u_int8_t	sac;		/* send action code */
 
 #define SEND_VOLUME_TAG_ASSERT_PRIMARY		0x08
 #define SEND_VOLUME_TAG_ASSERT_ALTERNATE	0x09
 #define SEND_VOLUME_TAG_REPLACE_PRIMARY		0x0a
 #define SEND_VOLUME_TAG_REPLACE_ALTERNATE	0x0b
 #define SEND_VOLUME_TAG_UNDEFINED_PRIMARY	0x0c
 #define SEND_VOLUME_TAG_UNDEFINED_ALTERNATE	0x0d
 
 	u_int8_t	reserved4[2];
 	u_int8_t	pll[2];		/* parameter list length */
 	u_int8_t	reserved5;
 	u_int8_t	control;
 };
 
 /*
  * Parameter format for SEND VOLUME TAG
  */
 
 struct scsi_send_volume_tag_parameters {
 	u_int8_t	vitf[32];	/* volume tag identification template */
 	u_int8_t	reserved1[2];
 	u_int8_t	minvsn[2];	/* minimum volume sequence number */
 	u_int8_t	reserved2[2];
 	u_int8_t	maxvsn[2];	/* maximum volume sequence number */
 };
 
 /*
  * Device capabilities page.
  *
  * This page defines characteristics of the elemenet types in the
  * medium changer device.
  *
  * Note in the definitions below, the following abbreviations are
  * used:
  *		MT	Medium transport element (picker)
  *		ST	Storage transport element (slot)
  *		IE	Import/export element (portal)
  *		DT	Data tranfer element (tape/disk drive)
  */
 struct page_device_capabilities {
 	u_int8_t	pg_code;	/* page code (0x1f) */
 	u_int8_t	pg_length;	/* page length (0x12) */
 
 	/*
 	 * The STOR_xx bits indicate that an element of a given
 	 * type may provide independent storage for a unit of
 	 * media.  The top four bits of this value are reserved.
 	 */
 	u_int8_t	stor;
 #define STOR_MT		0x01
 #define STOR_ST		0x02
 #define STOR_IE		0x04
 #define STOR_DT		0x08
 
 	u_int8_t	reserved0;
 
 	/*
 	 * The MOVE_TO_yy bits indicate the changer supports
 	 * moving a unit of medium from an element of a given type to an
 	 * element of type yy.  This is used to determine if a given
 	 * MOVE MEDIUM command is legal.  The top four bits of each
 	 * of these values are reserved.
 	 */
 	u_int8_t	move_from[CHET_MAX + 1];
 #define MOVE_TO_MT	0x01
 #define MOVE_TO_ST	0x02
 #define MOVE_TO_IE	0x04
 #define MOVE_TO_DT	0x08
 
 	u_int8_t	reserved1[4];
 
 	/*
 	 * Similar to above, but for EXCHANGE MEDIUM.
 	 */
 	u_int8_t	exchange_with[CHET_MAX + 1];
 #define EXCHANGE_WITH_MT	0x01
 #define EXCHANGE_WITH_ST	0x02
 #define EXCHANGE_WITH_IE	0x04
 #define EXCHANGE_WITH_DT	0x08
 };
 
 /*
  * Medium changer elemement address assignment page.
  *
  * Some of these fields can be a little confusing, so an explanation
  * is in order.
  *
  * Each component within a medium changer apparatus is called an
  * "element".
  *
  * The "medium transport element address" is the address of the first
  * picker (robotic arm).  "Number of medium transport elements" tells
  * us how many pickers exist in the changer.
  *
  * The "first storage element address" is the address of the first
  * slot in the tape or disk magazine.  "Number of storage elements" tells
  * us how many slots exist in the changer.
  *
  * The "first import/export element address" is the address of the first
  * medium portal accessible both by the medium changer and an outside
  * human operator.  This is where the changer might deposit tapes destined
  * for some vault.  The "number of import/export elements" tells us
  * not many of these portals exist in the changer.  NOTE: this number may
  * be 0.
  *
  * The "first data transfer element address" is the address of the first
  * tape or disk drive in the changer.  "Number of data transfer elements"
  * tells us how many drives exist in the changer.
  */
 struct page_element_address_assignment {
 	u_int8_t	pg_code;	/* page code (0x1d) */
 	u_int8_t	pg_length;	/* page length (0x12) */
 
 	/* Medium transport element address */
 	u_int8_t	mtea[2];
 
 	/* Number of medium transport elements */
 	u_int8_t	nmte[2];
 
 	/* First storage element address */
 	u_int8_t	fsea[2];
 
 	/* Number of storage elements */
 	u_int8_t	nse[2];
 
 	/* First import/export element address */
 	u_int8_t	fieea[2];
 
 	/* Number of import/export elements */
 	u_int8_t	niee[2];
 
 	/* First data transfer element address */
 	u_int8_t	fdtea[2];
 
 	/* Number of data trafer elements */
 	u_int8_t	ndte[2];
 
 	u_int8_t	reserved[2];
 };
 
 /*
  * Transport geometry parameters page.
  *
  * Defines whether each medium transport element is a member of a set of
  * elements that share a common robotics subsystem and whether the element
  * is capable of media rotation.  One transport geometry descriptor is
  * transferred for each medium transport element, beginning with the first
  * medium transport element (other than the default transport element address
  * of 0).
  */
 struct page_transport_geometry_parameters {
 	u_int8_t	pg_code;	/* page code (0x1e) */
 	u_int8_t	pg_length;	/* page length; variable */
 
 	/* Transport geometry descriptor(s) are here. */
 
 	u_int8_t	misc;
 #define CAN_ROTATE	0x01
 
 	/* Member number in transport element set. */
 	u_int8_t	member;
 };
 
 __BEGIN_DECLS
 void scsi_move_medium(struct ccb_scsiio *csio, u_int32_t retries,
 		      void (*cbfcnp)(struct cam_periph *, union ccb *),
 		      u_int8_t tag_action, u_int32_t tea, u_int32_t src,
 		      u_int32_t dst, int invert, u_int8_t sense_len,
 		      u_int32_t timeout);
 
 void scsi_exchange_medium(struct ccb_scsiio *csio, u_int32_t retries,
 			  void (*cbfcnp)(struct cam_periph *, union ccb *),
 			  u_int8_t tag_action, u_int32_t tea, u_int32_t src,
 			  u_int32_t dst1, u_int32_t dst2, int invert1,
 			  int invert2, u_int8_t sense_len, u_int32_t timeout);
 
 void scsi_position_to_element(struct ccb_scsiio *csio, u_int32_t retries,
 			      void (*cbfcnp)(struct cam_periph *, union ccb *),
 			      u_int8_t tag_action, u_int32_t tea, u_int32_t dst,
 			      int invert, u_int8_t sense_len,
 			      u_int32_t timeout);
 
 void scsi_read_element_status(struct ccb_scsiio *csio, u_int32_t retries,
 			      void (*cbfcnp)(struct cam_periph *, union ccb *),
 			      u_int8_t tag_action, int voltag, u_int32_t sea,
+			      int curdata, int dvcid,
 			      u_int32_t count, u_int8_t *data_ptr,
 			      u_int32_t dxfer_len, u_int8_t sense_len,
 			      u_int32_t timeout);
 
 void scsi_initialize_element_status(struct ccb_scsiio *csio, u_int32_t retries,
 			       void (*cbfcnp)(struct cam_periph *, union ccb *),
 			       u_int8_t tag_action, u_int8_t sense_len,
 			       u_int32_t timeout);
 void scsi_send_volume_tag(struct ccb_scsiio *csio, u_int32_t retries,
 			  void (*cbfcnp)(struct cam_periph *, union ccb *),
 			  u_int8_t tag_action, 
 			  u_int16_t element_address,
 			  u_int8_t send_action_code,
 			  struct scsi_send_volume_tag_parameters *parameters,
 			  u_int8_t sense_len, u_int32_t timeout);
 __END_DECLS
 
 #endif /* _SCSI_SCSI_CH_H */
Index: user/attilio/vmcontention/sys/conf/files
===================================================================
--- user/attilio/vmcontention/sys/conf/files	(revision 249698)
+++ user/attilio/vmcontention/sys/conf/files	(revision 249699)
@@ -1,3656 +1,3658 @@
 # $FreeBSD$
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
 # dependency lines other than the first are silently ignored.
 #
 acpi_quirks.h			optional acpi				   \
 	dependency	"$S/tools/acpi_quirks2h.awk $S/dev/acpica/acpi_quirks" \
 	compile-with	"${AWK} -f $S/tools/acpi_quirks2h.awk $S/dev/acpica/acpi_quirks" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"acpi_quirks.h"
 aicasm				optional ahc | ahd			   \
 	dependency	"$S/dev/aic7xxx/aicasm/*.[chyl]"		   \
 	compile-with	"CC='${CC}' ${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \
 	no-obj no-implicit-rule						   \
 	clean		"aicasm* y.tab.h"
 aic7xxx_seq.h			optional ahc				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic7xxx_seq.h"					   \
 	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic7xxx_reg.h			optional ahc				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic7xxx_reg.h"					   \
 	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic7xxx_reg_print.c		optional ahc				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h -p aic7xxx_reg_print.c -i $S/dev/aic7xxx/aic7xxx_osm.h $S/dev/aic7xxx/aic7xxx.seq"   \
 	no-obj no-implicit-rule local					   \
 	clean		"aic7xxx_reg_print.c"				   \
 	dependency	"$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic7xxx_reg_print.o		optional ahc ahc_reg_pretty_print	   \
 	compile-with	"${NORMAL_C}"					   \
 	no-implicit-rule local
 aic79xx_seq.h		optional ahd pci				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic79xx_seq.h"					   \
 	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic79xx_reg.h		optional ahd pci				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule before-depend local			   \
 	clean		"aic79xx_reg.h"					   \
 	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic79xx_reg_print.c	optional ahd pci				   \
 	compile-with	"./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic79xx_seq.h -r aic79xx_reg.h -p aic79xx_reg_print.c -i $S/dev/aic7xxx/aic79xx_osm.h $S/dev/aic7xxx/aic79xx.seq"   \
 	no-obj no-implicit-rule local					   \
 	clean		"aic79xx_reg_print.c"				   \
 	dependency	"$S/dev/aic7xxx/aic79xx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm"
 aic79xx_reg_print.o		optional ahd pci ahd_reg_pretty_print	   \
 	compile-with	"${NORMAL_C}"					   \
 	no-implicit-rule local
 #
 # The 'fdt_dtb_file' target covers an actual DTB file name, which is derived
 # from the specified source (DTS) file: .dts -> .dtb
 #
 fdt_dtb_file			optional fdt \
 	compile-with "if [ -f $S/boot/fdt/dts/${FDT_DTS_FILE} ]; then dtc -O dtb -o ${FDT_DTS_FILE:R}.dtb -b 0 -p 1024 $S/boot/fdt/dts/${FDT_DTS_FILE}; fi" \
 	no-obj no-implicit-rule before-depend	\
 	clean		"${FDT_DTS_FILE:R}.dtb"
 fdt_static_dtb.h		optional fdt fdt_dtb_static \
 	compile-with "sh $S/tools/fdt/make_dtbh.sh ${FDT_DTS_FILE} ." \
 	no-obj no-implicit-rule before-depend \
 	clean		"fdt_static_dtb.h"
 feeder_eq_gen.h			optional sound				   \
 	dependency	"$S/tools/sound/feeder_eq_mkfilter.awk"		   \
 	compile-with	"${AWK} -f $S/tools/sound/feeder_eq_mkfilter.awk -- ${FEEDER_EQ_PRESETS} > feeder_eq_gen.h" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"feeder_eq_gen.h"
 feeder_rate_gen.h		optional sound				   \
 	dependency	"$S/tools/sound/feeder_rate_mkfilter.awk"	   \
 	compile-with	"${AWK} -f $S/tools/sound/feeder_rate_mkfilter.awk -- ${FEEDER_RATE_PRESETS} > feeder_rate_gen.h" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"feeder_rate_gen.h"
 snd_fxdiv_gen.h			optional sound				   \
 	dependency	"$S/tools/sound/snd_fxdiv_gen.awk"		   \
 	compile-with	"${AWK} -f $S/tools/sound/snd_fxdiv_gen.awk -- > snd_fxdiv_gen.h" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"snd_fxdiv_gen.h"
 miidevs.h			optional miibus | mii			   \
 	dependency	"$S/tools/miidevs2h.awk $S/dev/mii/miidevs"	   \
 	compile-with	"${AWK} -f $S/tools/miidevs2h.awk $S/dev/mii/miidevs" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"miidevs.h"
 pccarddevs.h			standard				   \
 	dependency	"$S/tools/pccarddevs2h.awk $S/dev/pccard/pccarddevs" \
 	compile-with	"${AWK} -f $S/tools/pccarddevs2h.awk $S/dev/pccard/pccarddevs" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"pccarddevs.h"
 teken_state.h		optional sc					   \
 	dependency	"$S/teken/gensequences $S/teken/sequences" \
 	compile-with	"${AWK} -f $S/teken/gensequences $S/teken/sequences > teken_state.h" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"teken_state.h"
 usbdevs.h			optional usb				   \
 	dependency	"$S/tools/usbdevs2h.awk $S/dev/usb/usbdevs" \
 	compile-with	"${AWK} -f $S/tools/usbdevs2h.awk $S/dev/usb/usbdevs -h" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"usbdevs.h"
 usbdevs_data.h			optional usb				   \
 	dependency	"$S/tools/usbdevs2h.awk $S/dev/usb/usbdevs" \
 	compile-with	"${AWK} -f $S/tools/usbdevs2h.awk $S/dev/usb/usbdevs -d" \
 	no-obj no-implicit-rule before-depend				   \
 	clean		"usbdevs_data.h"
 cam/cam.c			optional scbus
 cam/cam_periph.c		optional scbus
 cam/cam_queue.c			optional scbus
 cam/cam_sim.c			optional scbus
 cam/cam_xpt.c			optional scbus
 cam/ata/ata_all.c		optional scbus
 cam/ata/ata_xpt.c		optional scbus
 cam/ata/ata_pmp.c		optional scbus
 cam/scsi/scsi_xpt.c		optional scbus
 cam/scsi/scsi_all.c		optional scbus
 cam/scsi/scsi_cd.c		optional cd
 cam/scsi/scsi_ch.c		optional ch
 cam/ata/ata_da.c		optional ada | da
 cam/ctl/ctl.c			optional ctl
 cam/ctl/ctl_backend.c		optional ctl
 cam/ctl/ctl_backend_block.c	optional ctl
 cam/ctl/ctl_backend_ramdisk.c	optional ctl
 cam/ctl/ctl_cmd_table.c		optional ctl
 cam/ctl/ctl_frontend.c		optional ctl
 cam/ctl/ctl_frontend_cam_sim.c	optional ctl
 cam/ctl/ctl_frontend_internal.c	optional ctl
 cam/ctl/ctl_mem_pool.c		optional ctl
 cam/ctl/ctl_scsi_all.c		optional ctl
 cam/ctl/ctl_error.c		optional ctl
 cam/ctl/ctl_util.c		optional ctl
 cam/ctl/scsi_ctl.c		optional ctl
 cam/scsi/scsi_da.c		optional da
 cam/scsi/scsi_low.c		optional ct | ncv | nsp | stg
 cam/scsi/scsi_pass.c		optional pass
 cam/scsi/scsi_pt.c		optional pt
 cam/scsi/scsi_sa.c		optional sa
 cam/scsi/scsi_enc.c		optional ses
 cam/scsi/scsi_enc_ses.c		optional ses
 cam/scsi/scsi_enc_safte.c	optional ses
 cam/scsi/scsi_sg.c		optional sg
 cam/scsi/scsi_targ_bh.c		optional targbh
 cam/scsi/scsi_target.c		optional targ
 cam/scsi/smp_all.c		optional scbus
 # shared between zfs and dtrace
 cddl/compat/opensolaris/kern/opensolaris.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_cmn_err.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_kmem.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_misc.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_sunddi.c			optional zfs compile-with "${ZFS_C}"
 # zfs specific
 cddl/compat/opensolaris/kern/opensolaris_acl.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_kobj.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_kstat.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_lookup.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_policy.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_string.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_sysevent.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_taskq.c			optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_uio.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_vfs.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_vm.c				optional zfs compile-with "${ZFS_C}"
 cddl/compat/opensolaris/kern/opensolaris_zone.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/acl/acl_common.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/avl/avl.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/nvpair/fnvpair.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/nvpair/nvpair.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/nvpair/nvpair_alloc_fixed.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/unicode/u8_textprep.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfeature_common.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_comutil.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_deleg.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_fletcher.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zfs_prop.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zpool_prop.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/common/zfs/zprop_common.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/gfs.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/vnode.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/bplist.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/ddt_zap.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_diff.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c			optional zfs compile-with "${ZFS_C}" \
 	warning "kernel contains CDDL licensed ZFS filesystem"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/gzip.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/lzjb.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/uberblock.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/unique.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_debug.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_sa.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zle.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zrlock.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/os/callb.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/os/fm.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/os/list.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/os/nvpair_alloc_system.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/adler32.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/deflate.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/inffast.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/inflate.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/inftrees.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c		optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/trees.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/zmod.c				optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.c			optional zfs compile-with "${ZFS_C}"
 cddl/contrib/opensolaris/uts/common/zmod/zutil.c			optional zfs compile-with "${ZFS_C}"
 compat/freebsd32/freebsd32_ioctl.c	optional compat_freebsd32
 compat/freebsd32/freebsd32_misc.c	optional compat_freebsd32
 compat/freebsd32/freebsd32_syscalls.c	optional compat_freebsd32
 compat/freebsd32/freebsd32_sysent.c	optional compat_freebsd32
 contrib/altq/altq/altq_cbq.c		optional altq
 contrib/altq/altq/altq_cdnr.c		optional altq
 contrib/altq/altq/altq_hfsc.c		optional altq
 contrib/altq/altq/altq_priq.c		optional altq
 contrib/altq/altq/altq_red.c		optional altq
 contrib/altq/altq/altq_rio.c		optional altq
 contrib/altq/altq/altq_rmclass.c	optional altq
 contrib/altq/altq/altq_subr.c		optional altq
 contrib/dev/acpica/components/debugger/dbcmds.c		optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbconvert.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbdisply.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbexec.c		optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbfileio.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbhistry.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbinput.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbmethod.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbnames.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbstats.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbutils.c	optional acpi acpi_debug
 contrib/dev/acpica/components/debugger/dbxface.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmbuffer.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmdeferred.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmnames.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmopcode.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmobject.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmresrc.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmresrcl.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmresrcl2.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmresrcs.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmutils.c	optional acpi acpi_debug
 contrib/dev/acpica/components/disassembler/dmwalk.c	optional acpi acpi_debug
 contrib/dev/acpica/components/dispatcher/dsargs.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dscontrol.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsfield.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsinit.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsmethod.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsmthdat.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsobject.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsopcode.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dsutils.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dswexec.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dswload.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dswload2.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dswscope.c	optional acpi
 contrib/dev/acpica/components/dispatcher/dswstate.c	optional acpi
 contrib/dev/acpica/components/events/evevent.c		optional acpi
 contrib/dev/acpica/components/events/evglock.c		optional acpi
 contrib/dev/acpica/components/events/evgpe.c		optional acpi
 contrib/dev/acpica/components/events/evgpeblk.c		optional acpi
 contrib/dev/acpica/components/events/evgpeinit.c	optional acpi
 contrib/dev/acpica/components/events/evgpeutil.c	optional acpi
 contrib/dev/acpica/components/events/evhandler.c	optional acpi
 contrib/dev/acpica/components/events/evmisc.c		optional acpi
 contrib/dev/acpica/components/events/evregion.c		optional acpi
 contrib/dev/acpica/components/events/evrgnini.c		optional acpi
 contrib/dev/acpica/components/events/evsci.c		optional acpi
 contrib/dev/acpica/components/events/evxface.c		optional acpi
 contrib/dev/acpica/components/events/evxfevnt.c		optional acpi
 contrib/dev/acpica/components/events/evxfgpe.c		optional acpi
 contrib/dev/acpica/components/events/evxfregn.c		optional acpi
 contrib/dev/acpica/components/executer/exconfig.c	optional acpi
 contrib/dev/acpica/components/executer/exconvrt.c	optional acpi
 contrib/dev/acpica/components/executer/excreate.c	optional acpi
 contrib/dev/acpica/components/executer/exdebug.c	optional acpi
 contrib/dev/acpica/components/executer/exdump.c		optional acpi
 contrib/dev/acpica/components/executer/exfield.c	optional acpi
 contrib/dev/acpica/components/executer/exfldio.c	optional acpi
 contrib/dev/acpica/components/executer/exmisc.c		optional acpi
 contrib/dev/acpica/components/executer/exmutex.c	optional acpi
 contrib/dev/acpica/components/executer/exnames.c	optional acpi
 contrib/dev/acpica/components/executer/exoparg1.c	optional acpi
 contrib/dev/acpica/components/executer/exoparg2.c	optional acpi
 contrib/dev/acpica/components/executer/exoparg3.c	optional acpi
 contrib/dev/acpica/components/executer/exoparg6.c	optional acpi
 contrib/dev/acpica/components/executer/exprep.c		optional acpi
 contrib/dev/acpica/components/executer/exregion.c	optional acpi
 contrib/dev/acpica/components/executer/exresnte.c	optional acpi
 contrib/dev/acpica/components/executer/exresolv.c	optional acpi
 contrib/dev/acpica/components/executer/exresop.c	optional acpi
 contrib/dev/acpica/components/executer/exstore.c	optional acpi
 contrib/dev/acpica/components/executer/exstoren.c	optional acpi
 contrib/dev/acpica/components/executer/exstorob.c	optional acpi
 contrib/dev/acpica/components/executer/exsystem.c	optional acpi
 contrib/dev/acpica/components/executer/exutils.c	optional acpi
 contrib/dev/acpica/components/hardware/hwacpi.c		optional acpi
 contrib/dev/acpica/components/hardware/hwesleep.c	optional acpi
 contrib/dev/acpica/components/hardware/hwgpe.c		optional acpi
 contrib/dev/acpica/components/hardware/hwpci.c		optional acpi
 contrib/dev/acpica/components/hardware/hwregs.c		optional acpi
 contrib/dev/acpica/components/hardware/hwsleep.c	optional acpi
 contrib/dev/acpica/components/hardware/hwtimer.c	optional acpi
 contrib/dev/acpica/components/hardware/hwvalid.c	optional acpi
 contrib/dev/acpica/components/hardware/hwxface.c	optional acpi
 contrib/dev/acpica/components/hardware/hwxfsleep.c	optional acpi
 contrib/dev/acpica/components/namespace/nsaccess.c	optional acpi
 contrib/dev/acpica/components/namespace/nsalloc.c	optional acpi
+contrib/dev/acpica/components/namespace/nsarguments.c	optional acpi
 contrib/dev/acpica/components/namespace/nsconvert.c	optional acpi
 contrib/dev/acpica/components/namespace/nsdump.c	optional acpi
 contrib/dev/acpica/components/namespace/nseval.c	optional acpi
 contrib/dev/acpica/components/namespace/nsinit.c	optional acpi
 contrib/dev/acpica/components/namespace/nsload.c	optional acpi
 contrib/dev/acpica/components/namespace/nsnames.c	optional acpi
 contrib/dev/acpica/components/namespace/nsobject.c	optional acpi
 contrib/dev/acpica/components/namespace/nsparse.c	optional acpi
 contrib/dev/acpica/components/namespace/nspredef.c	optional acpi
 contrib/dev/acpica/components/namespace/nsprepkg.c	optional acpi
 contrib/dev/acpica/components/namespace/nsrepair.c	optional acpi
 contrib/dev/acpica/components/namespace/nsrepair2.c	optional acpi
 contrib/dev/acpica/components/namespace/nssearch.c	optional acpi
 contrib/dev/acpica/components/namespace/nsutils.c	optional acpi
 contrib/dev/acpica/components/namespace/nswalk.c	optional acpi
 contrib/dev/acpica/components/namespace/nsxfeval.c	optional acpi
 contrib/dev/acpica/components/namespace/nsxfname.c	optional acpi
 contrib/dev/acpica/components/namespace/nsxfobj.c	optional acpi
 contrib/dev/acpica/components/parser/psargs.c		optional acpi
 contrib/dev/acpica/components/parser/psloop.c		optional acpi
 contrib/dev/acpica/components/parser/psobject.c		optional acpi
 contrib/dev/acpica/components/parser/psopcode.c		optional acpi
 contrib/dev/acpica/components/parser/psopinfo.c		optional acpi
 contrib/dev/acpica/components/parser/psparse.c		optional acpi
 contrib/dev/acpica/components/parser/psscope.c		optional acpi
 contrib/dev/acpica/components/parser/pstree.c		optional acpi
 contrib/dev/acpica/components/parser/psutils.c		optional acpi
 contrib/dev/acpica/components/parser/pswalk.c		optional acpi
 contrib/dev/acpica/components/parser/psxface.c		optional acpi
 contrib/dev/acpica/components/resources/rsaddr.c	optional acpi
 contrib/dev/acpica/components/resources/rscalc.c	optional acpi
 contrib/dev/acpica/components/resources/rscreate.c	optional acpi
 contrib/dev/acpica/components/resources/rsdump.c	optional acpi
 contrib/dev/acpica/components/resources/rsdumpinfo.c	optional acpi
 contrib/dev/acpica/components/resources/rsinfo.c	optional acpi
 contrib/dev/acpica/components/resources/rsio.c		optional acpi
 contrib/dev/acpica/components/resources/rsirq.c		optional acpi
 contrib/dev/acpica/components/resources/rslist.c	optional acpi
 contrib/dev/acpica/components/resources/rsmemory.c	optional acpi
 contrib/dev/acpica/components/resources/rsmisc.c	optional acpi
 contrib/dev/acpica/components/resources/rsserial.c	optional acpi
 contrib/dev/acpica/components/resources/rsutils.c	optional acpi
 contrib/dev/acpica/components/resources/rsxface.c	optional acpi
 contrib/dev/acpica/components/tables/tbfadt.c		optional acpi
 contrib/dev/acpica/components/tables/tbfind.c		optional acpi
 contrib/dev/acpica/components/tables/tbinstal.c		optional acpi
 contrib/dev/acpica/components/tables/tbutils.c		optional acpi
 contrib/dev/acpica/components/tables/tbxface.c		optional acpi
 contrib/dev/acpica/components/tables/tbxfload.c		optional acpi
 contrib/dev/acpica/components/tables/tbxfroot.c		optional acpi
 contrib/dev/acpica/components/utilities/utaddress.c	optional acpi
 contrib/dev/acpica/components/utilities/utalloc.c	optional acpi
 contrib/dev/acpica/components/utilities/utcache.c	optional acpi
 contrib/dev/acpica/components/utilities/utcopy.c	optional acpi
 contrib/dev/acpica/components/utilities/utdebug.c	optional acpi
 contrib/dev/acpica/components/utilities/utdecode.c	optional acpi
 contrib/dev/acpica/components/utilities/utdelete.c	optional acpi
 contrib/dev/acpica/components/utilities/uteval.c	optional acpi
 contrib/dev/acpica/components/utilities/utexcep.c	optional acpi
 contrib/dev/acpica/components/utilities/utglobal.c	optional acpi
 contrib/dev/acpica/components/utilities/utids.c		optional acpi
 contrib/dev/acpica/components/utilities/utinit.c	optional acpi
 contrib/dev/acpica/components/utilities/utlock.c	optional acpi
 contrib/dev/acpica/components/utilities/utmath.c	optional acpi
 contrib/dev/acpica/components/utilities/utmisc.c	optional acpi
 contrib/dev/acpica/components/utilities/utmutex.c	optional acpi
 contrib/dev/acpica/components/utilities/utobject.c	optional acpi
 contrib/dev/acpica/components/utilities/utosi.c		optional acpi
 contrib/dev/acpica/components/utilities/utownerid.c	optional acpi
 contrib/dev/acpica/components/utilities/utpredef.c	optional acpi
 contrib/dev/acpica/components/utilities/utresrc.c	optional acpi
 contrib/dev/acpica/components/utilities/utstate.c	optional acpi
 contrib/dev/acpica/components/utilities/utstring.c	optional acpi
 contrib/dev/acpica/components/utilities/utxface.c	optional acpi
 contrib/dev/acpica/components/utilities/utxferror.c	optional acpi
 contrib/dev/acpica/components/utilities/utxfinit.c	optional acpi
 #contrib/dev/acpica/components/utilities/utxfmutex.c	optional acpi
 contrib/ipfilter/netinet/fil.c	optional ipfilter inet \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_auth.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_fil_freebsd.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_frag.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_log.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_nat.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_proxy.c optional ipfilter inet \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_state.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_lookup.c optional ipfilter inet \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN} -Wno-error -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_pool.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_htable.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/ip_sync.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/ipfilter/netinet/mlfk_ipl.c optional ipfilter inet \
 	compile-with "${NORMAL_C} -I$S/contrib/ipfilter"
 contrib/libfdt/fdt.c		optional fdt
 contrib/libfdt/fdt_ro.c		optional fdt
 contrib/libfdt/fdt_rw.c		optional fdt
 contrib/libfdt/fdt_strerror.c	optional fdt
 contrib/libfdt/fdt_sw.c		optional fdt
 contrib/libfdt/fdt_wip.c	optional fdt
 contrib/ngatm/netnatm/api/cc_conn.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C_NOWERROR} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_data.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_dump.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_port.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_sig.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/cc_user.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/api/unisap.c optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/misc/straddr.c optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/misc/unimsg_common.c optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/msg/traffic.c optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/msg/uni_ie.c optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/msg/uni_msg.c optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/saal/saal_sscfu.c	optional ngatm_sscfu \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/saal/saal_sscop.c	optional ngatm_sscop \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_call.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_coord.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_party.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_print.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_reset.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_uni.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_unimsgcpy.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 contrib/ngatm/netnatm/sig/sig_verify.c optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 crypto/blowfish/bf_ecb.c	optional ipsec
 crypto/blowfish/bf_skey.c	optional crypto | ipsec
 crypto/camellia/camellia.c	optional crypto | ipsec
 crypto/camellia/camellia-api.c	optional crypto | ipsec
 crypto/des/des_ecb.c		optional crypto | ipsec
 crypto/des/des_setkey.c		optional crypto | ipsec
 crypto/rc4/rc4.c		optional netgraph_mppc_encryption | kgssapi
 crypto/rijndael/rijndael-alg-fst.c optional crypto | geom_bde | \
 					 ipsec | random | wlan_ccmp
 crypto/rijndael/rijndael-api-fst.c optional geom_bde | random
 crypto/rijndael/rijndael-api.c	optional crypto | ipsec | wlan_ccmp
 crypto/sha1.c			optional carp | crypto | ipsec | \
 					 netgraph_mppc_encryption | sctp
 crypto/sha2/sha2.c		optional crypto | geom_bde | ipsec | random | \
 					 sctp | zfs
 ddb/db_access.c			optional ddb
 ddb/db_break.c			optional ddb
 ddb/db_capture.c		optional ddb
 ddb/db_command.c		optional ddb
 ddb/db_examine.c		optional ddb
 ddb/db_expr.c			optional ddb
 ddb/db_input.c			optional ddb
 ddb/db_lex.c			optional ddb
 ddb/db_main.c			optional ddb
 ddb/db_output.c			optional ddb
 ddb/db_print.c			optional ddb
 ddb/db_ps.c			optional ddb
 ddb/db_run.c			optional ddb
 ddb/db_script.c			optional ddb
 ddb/db_sym.c			optional ddb
 ddb/db_thread.c			optional ddb
 ddb/db_textdump.c		optional ddb
 ddb/db_variables.c		optional ddb
 ddb/db_watch.c			optional ddb
 ddb/db_write_cmd.c		optional ddb
 #dev/dpt/dpt_control.c		optional dpt
 dev/aac/aac.c			optional aac
 dev/aac/aac_cam.c		optional aacp aac
 dev/aac/aac_debug.c		optional aac
 dev/aac/aac_disk.c		optional aac
 dev/aac/aac_linux.c		optional aac compat_linux
 dev/aac/aac_pci.c		optional aac pci
 dev/acpi_support/acpi_wmi.c	optional acpi_wmi acpi
 dev/acpi_support/acpi_asus.c	optional acpi_asus acpi
 dev/acpi_support/acpi_asus_wmi.c	optional acpi_asus_wmi acpi
 dev/acpi_support/acpi_fujitsu.c	optional acpi_fujitsu acpi
 dev/acpi_support/acpi_hp.c	optional acpi_hp acpi
 dev/acpi_support/acpi_ibm.c	optional acpi_ibm acpi
 dev/acpi_support/acpi_panasonic.c optional acpi_panasonic acpi
 dev/acpi_support/acpi_sony.c	optional acpi_sony acpi
 dev/acpi_support/acpi_toshiba.c	optional acpi_toshiba acpi
 dev/acpi_support/atk0110.c	optional aibs acpi
 dev/acpica/Osd/OsdDebug.c	optional acpi
 dev/acpica/Osd/OsdHardware.c	optional acpi
 dev/acpica/Osd/OsdInterrupt.c	optional acpi
 dev/acpica/Osd/OsdMemory.c	optional acpi
 dev/acpica/Osd/OsdSchedule.c	optional acpi
 dev/acpica/Osd/OsdStream.c	optional acpi
 dev/acpica/Osd/OsdSynch.c	optional acpi
 dev/acpica/Osd/OsdTable.c	optional acpi
 dev/acpica/acpi.c		optional acpi
 dev/acpica/acpi_acad.c		optional acpi
 dev/acpica/acpi_battery.c	optional acpi
 dev/acpica/acpi_button.c	optional acpi
 dev/acpica/acpi_cmbat.c		optional acpi
 dev/acpica/acpi_cpu.c		optional acpi
 dev/acpica/acpi_ec.c		optional acpi
 dev/acpica/acpi_hpet.c		optional acpi
 dev/acpica/acpi_isab.c		optional acpi isa
 dev/acpica/acpi_lid.c		optional acpi
 dev/acpica/acpi_package.c	optional acpi
 dev/acpica/acpi_pci.c		optional acpi pci
 dev/acpica/acpi_pci_link.c	optional acpi pci
 dev/acpica/acpi_pcib.c		optional acpi pci
 dev/acpica/acpi_pcib_acpi.c	optional acpi pci
 dev/acpica/acpi_pcib_pci.c	optional acpi pci
 dev/acpica/acpi_perf.c		optional acpi
 dev/acpica/acpi_powerres.c	optional acpi
 dev/acpica/acpi_quirk.c		optional acpi
 dev/acpica/acpi_resource.c	optional acpi
 dev/acpica/acpi_smbat.c		optional acpi
 dev/acpica/acpi_thermal.c	optional acpi
 dev/acpica/acpi_throttle.c	optional acpi
 dev/acpica/acpi_timer.c		optional acpi
 dev/acpica/acpi_video.c		optional acpi_video acpi
 dev/acpica/acpi_dock.c		optional acpi_dock acpi
 dev/adlink/adlink.c		optional adlink
 dev/advansys/adv_eisa.c		optional adv eisa
 dev/advansys/adv_pci.c		optional adv pci
 dev/advansys/advansys.c		optional adv
 dev/advansys/advlib.c		optional adv
 dev/advansys/advmcode.c		optional adv
 dev/advansys/adw_pci.c		optional adw pci
 dev/advansys/adwcam.c		optional adw
 dev/advansys/adwlib.c		optional adw
 dev/advansys/adwmcode.c		optional adw
 dev/ae/if_ae.c			optional ae pci
 dev/age/if_age.c		optional age pci
 dev/agp/agp.c			optional agp pci
 dev/agp/agp_if.m		optional agp pci
 dev/aha/aha.c			optional aha
 dev/aha/aha_isa.c		optional aha isa
 dev/aha/aha_mca.c		optional aha mca
 dev/ahb/ahb.c			optional ahb eisa
 dev/ahci/ahci.c			optional ahci pci
 dev/ahci/ahciem.c		optional ahci pci
 dev/aic/aic.c			optional aic
 dev/aic/aic_pccard.c		optional aic pccard
 dev/aic7xxx/ahc_eisa.c		optional ahc eisa
 dev/aic7xxx/ahc_isa.c		optional ahc isa
 dev/aic7xxx/ahc_pci.c		optional ahc pci \
 	compile-with "${NORMAL_C} ${NO_WCONSTANT_CONVERSION}"
 dev/aic7xxx/ahd_pci.c		optional ahd pci \
 	compile-with "${NORMAL_C} ${NO_WCONSTANT_CONVERSION}"
 dev/aic7xxx/aic7770.c		optional ahc
 dev/aic7xxx/aic79xx.c		optional ahd pci
 dev/aic7xxx/aic79xx_osm.c	optional ahd pci
 dev/aic7xxx/aic79xx_pci.c	optional ahd pci
 dev/aic7xxx/aic7xxx.c		optional ahc
 dev/aic7xxx/aic7xxx_93cx6.c	optional ahc
 dev/aic7xxx/aic7xxx_osm.c	optional ahc
 dev/aic7xxx/aic7xxx_pci.c	optional ahc pci
 dev/alc/if_alc.c		optional alc pci
 dev/ale/if_ale.c		optional ale pci
 dev/altera/avgen/altera_avgen.c		optional altera_avgen
 dev/altera/avgen/altera_avgen_fdt.c	optional altera_avgen fdt
 dev/altera/avgen/altera_avgen_nexus.c	optional altera_avgen
 dev/altera/sdcard/altera_sdcard.c	optional altera_sdcard
 dev/altera/sdcard/altera_sdcard_disk.c	optional altera_sdcard
 dev/altera/sdcard/altera_sdcard_io.c	optional altera_sdcard
 dev/altera/sdcard/altera_sdcard_fdt.c	optional altera_sdcard fdt
 dev/altera/sdcard/altera_sdcard_nexus.c	optional altera_sdcard
 dev/amr/amr.c			optional amr
 dev/amr/amr_cam.c		optional amrp amr
 dev/amr/amr_disk.c		optional amr
 dev/amr/amr_linux.c		optional amr compat_linux
 dev/amr/amr_pci.c		optional amr pci
 dev/an/if_an.c			optional an
 dev/an/if_an_isa.c		optional an isa
 dev/an/if_an_pccard.c		optional an pccard
 dev/an/if_an_pci.c		optional an pci
 dev/asr/asr.c			optional asr pci \
 	compile-with "${NORMAL_C} ${NO_WARRAY_BOUNDS}"
 #
 dev/ata/ata_if.m		optional ata | atacore
 dev/ata/ata-all.c		optional ata | atacore
 dev/ata/ata-dma.c		optional ata | atacore
 dev/ata/ata-lowlevel.c		optional ata | atacore
 dev/ata/ata-sata.c		optional ata | atacore
 dev/ata/ata-card.c		optional ata pccard | atapccard
 dev/ata/ata-cbus.c		optional ata pc98 | atapc98
 dev/ata/ata-isa.c		optional ata isa | ataisa
 dev/ata/ata-pci.c		optional ata pci | atapci
 dev/ata/chipsets/ata-ahci.c	optional ata pci | ataahci | ataacerlabs | \
 					 ataati | ataintel | atajmicron | \
 					 atavia | atanvidia
 dev/ata/chipsets/ata-acard.c	optional ata pci | ataacard
 dev/ata/chipsets/ata-acerlabs.c	optional ata pci | ataacerlabs
 dev/ata/chipsets/ata-adaptec.c	optional ata pci | ataadaptec
 dev/ata/chipsets/ata-amd.c	optional ata pci | ataamd
 dev/ata/chipsets/ata-ati.c	optional ata pci | ataati
 dev/ata/chipsets/ata-cenatek.c	optional ata pci | atacenatek
 dev/ata/chipsets/ata-cypress.c	optional ata pci | atacypress
 dev/ata/chipsets/ata-cyrix.c	optional ata pci | atacyrix
 dev/ata/chipsets/ata-highpoint.c	optional ata pci | atahighpoint
 dev/ata/chipsets/ata-intel.c	optional ata pci | ataintel
 dev/ata/chipsets/ata-ite.c	optional ata pci | ataite
 dev/ata/chipsets/ata-jmicron.c	optional ata pci | atajmicron
 dev/ata/chipsets/ata-marvell.c	optional ata pci | atamarvell | ataadaptec
 dev/ata/chipsets/ata-micron.c	optional ata pci | atamicron
 dev/ata/chipsets/ata-national.c	optional ata pci | atanational
 dev/ata/chipsets/ata-netcell.c	optional ata pci | atanetcell
 dev/ata/chipsets/ata-nvidia.c	optional ata pci | atanvidia
 dev/ata/chipsets/ata-promise.c	optional ata pci | atapromise
 dev/ata/chipsets/ata-serverworks.c	optional ata pci | ataserverworks
 dev/ata/chipsets/ata-siliconimage.c	optional ata pci | atasiliconimage | ataati
 dev/ata/chipsets/ata-sis.c	optional ata pci | atasis
 dev/ata/chipsets/ata-via.c	optional ata pci | atavia
 #
 dev/ath/if_ath_pci.c		optional ath_pci pci \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 #
 dev/ath/if_ath_ahb.c		optional ath_ahb \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 #
 dev/ath/if_ath.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_beacon.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_debug.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_keycache.c	optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_led.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_tx.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_tx_edma.c	optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_tx_ht.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_tdma.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_sysctl.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_rx.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_rx_edma.c	optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/if_ath_spectral.c	optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ah_osdep.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 #
 dev/ath/ath_hal/ah.c		optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_eeprom_v1.c	optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_eeprom_v3.c	optional ath_hal | ath_ar5211 | ath_ar5212 \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_eeprom_v14.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_eeprom_v4k.c \
 	optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_eeprom_9287.c \
 	optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_hal/ah_regdomain.c	optional ath \
 	compile-with "${NORMAL_C} ${NO_WSHIFT_COUNT_NEGATIVE} ${NO_WSHIFT_COUNT_OVERFLOW} -I$S/dev/ath"
 # ar5210
 dev/ath/ath_hal/ar5210/ar5210_attach.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_beacon.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_interrupts.c	optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_keycache.c	optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_misc.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_phy.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_power.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_recv.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_reset.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5210/ar5210_xmit.c		optional ath_hal | ath_ar5210 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar5211
 dev/ath/ath_hal/ar5211/ar5211_attach.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_beacon.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_interrupts.c	optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_keycache.c	optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_misc.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_phy.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_power.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_recv.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_reset.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5211/ar5211_xmit.c		optional ath_hal | ath_ar5211 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar5212
 dev/ath/ath_hal/ar5212/ar5212_ani.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_attach.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_beacon.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_eeprom.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_gpio.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_interrupts.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_keycache.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_misc.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_phy.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_power.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_recv.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_reset.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_rfgain.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5212_xmit.c \
 	optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 | ath_ar9280 | \
 	ath_ar9285 ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar5416 (depends on ar5212)
 dev/ath/ath_hal/ar5416/ar5416_ani.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_attach.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_beacon.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_btcoex.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_cal.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_cal_iq.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_cal_adcgain.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_cal_adcdc.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_eeprom.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_gpio.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_interrupts.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_keycache.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_misc.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_phy.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_power.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_radar.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_recv.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_reset.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_spectral.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar5416_xmit.c \
 	optional ath_hal | ath_ar5416 | ath_ar9160 | ath_ar9280 | ath_ar9285 | \
 	ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar9130 (depends upon ar5416) - also requires AH_SUPPORT_AR9130
 #
 # Since this is an embedded MAC SoC, there's no need to compile it into the
 # default HAL.
 dev/ath/ath_hal/ar9001/ar9130_attach.c optional ath_ar9130 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9001/ar9130_phy.c optional ath_ar9130 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9001/ar9130_eeprom.c optional ath_ar9130 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar9160 (depends on ar5416)
 dev/ath/ath_hal/ar9001/ar9160_attach.c optional ath_hal | ath_ar9160 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar9280 (depends on ar5416)
 dev/ath/ath_hal/ar9002/ar9280_attach.c optional ath_hal | ath_ar9280 | \
 	ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9280_olc.c optional ath_hal | ath_ar9280 | \
 	ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar9285 (depends on ar5416 and ar9280)
 dev/ath/ath_hal/ar9002/ar9285_attach.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_btcoex.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_reset.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_cal.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_phy.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_diversity.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ar9287 (depends on ar5416)
 dev/ath/ath_hal/ar9002/ar9287_attach.c optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9287_reset.c optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9287_cal.c optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9287_olc.c optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 
 # rf backends
 dev/ath/ath_hal/ar5212/ar2316.c	optional ath_rf2316 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar2317.c	optional ath_rf2317 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar2413.c	optional ath_hal | ath_rf2413 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar2425.c	optional ath_hal | ath_rf2425 | ath_rf2417 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5111.c	optional ath_hal | ath_rf5111 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5112.c	optional ath_hal | ath_rf5112 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5212/ar5413.c	optional ath_hal | ath_rf5413 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar5416/ar2133.c optional ath_hal | ath_ar5416 | \
 	ath_ar9130 | ath_ar9160 | ath_ar9280 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9280.c optional ath_hal | ath_ar9280 | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285.c optional ath_hal | ath_ar9285 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9287.c optional ath_hal | ath_ar9287 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # ath rate control algorithms
 dev/ath/ath_rate/amrr/amrr.c	optional ath_rate_amrr \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_rate/onoe/onoe.c	optional ath_rate_onoe \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 dev/ath/ath_rate/sample/sample.c	optional ath_rate_sample \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 # ath DFS modules
 dev/ath/ath_dfs/null/dfs_null.c	optional ath \
 	compile-with "${NORMAL_C} -I$S/dev/ath"
 #
 dev/bce/if_bce.c		optional bce
 dev/bfe/if_bfe.c		optional bfe
 dev/bge/if_bge.c		optional bge
 dev/bktr/bktr_audio.c		optional bktr pci
 dev/bktr/bktr_card.c		optional bktr pci
 dev/bktr/bktr_core.c		optional bktr pci
 dev/bktr/bktr_i2c.c		optional bktr pci smbus
 dev/bktr/bktr_os.c		optional bktr pci
 dev/bktr/bktr_tuner.c		optional bktr pci
 dev/bktr/msp34xx.c		optional bktr pci
 dev/buslogic/bt.c		optional bt
 dev/buslogic/bt_eisa.c		optional bt eisa
 dev/buslogic/bt_isa.c		optional bt isa
 dev/buslogic/bt_mca.c		optional bt mca
 dev/buslogic/bt_pci.c		optional bt pci
 dev/bwi/bwimac.c		optional bwi
 dev/bwi/bwiphy.c		optional bwi
 dev/bwi/bwirf.c			optional bwi
 dev/bwi/if_bwi.c		optional bwi
 dev/bwi/if_bwi_pci.c		optional bwi pci
 # XXX Work around clang warning, until maintainer approves fix.
 dev/bwn/if_bwn.c		optional bwn siba_bwn \
 	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
 dev/bxe/if_bxe.c		optional bxe
 dev/bxe/bxe_link.c		optional bxe
 dev/cardbus/cardbus.c		optional cardbus
 dev/cardbus/cardbus_cis.c	optional cardbus
 dev/cardbus/cardbus_device.c	optional cardbus
 dev/cas/if_cas.c		optional cas
 dev/cfi/cfi_bus_nexus.c		optional cfi
 dev/cfi/cfi_core.c		optional cfi
 dev/cfi/cfi_dev.c		optional cfi
 dev/cfi/cfi_disk.c		optional cfid
 dev/ciss/ciss.c			optional ciss
 dev/cm/smc90cx6.c		optional cm
 dev/cmx/cmx.c			optional cmx
 dev/cmx/cmx_pccard.c		optional cmx pccard
 dev/cpufreq/ichss.c		optional cpufreq
 dev/cs/if_cs.c			optional cs
 dev/cs/if_cs_isa.c		optional cs isa
 dev/cs/if_cs_pccard.c		optional cs pccard
 dev/cxgb/cxgb_main.c		optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/cxgb_sge.c		optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_mc5.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_vsc7323.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_vsc8211.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_ael1002.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_aq100x.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_mv88e1xxx.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_xgmac.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_t3_hw.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/common/cxgb_tn1010.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/sys/uipc_mvec.c	optional cxgb pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgb/cxgb_t3fw.c		optional cxgb cxgb_t3fw \
 	compile-with "${NORMAL_C} -I$S/dev/cxgb"
 dev/cxgbe/t4_main.c		optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 dev/cxgbe/t4_sge.c		optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 dev/cxgbe/t4_l2t.c		optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 dev/cxgbe/common/t4_hw.c	optional cxgbe pci \
 	compile-with "${NORMAL_C} -I$S/dev/cxgbe"
 t4fw_cfg.c		optional cxgbe					\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk t4fw_cfg.fw:t4fw_cfg t4fw_cfg_uwire.fw:t4fw_cfg_uwire t4fw.fw:t4fw -mt4fw_cfg -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"t4fw_cfg.c"
 t4fw_cfg.fwo		optional cxgbe					\
 	dependency	"t4fw_cfg.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"t4fw_cfg.fwo"
 t4fw_cfg.fw		optional cxgbe					\
 	dependency	"$S/dev/cxgbe/firmware/t4fw_cfg.txt"		\
 	compile-with	"${CP} ${.ALLSRC} ${.TARGET}"			\
 	no-obj no-implicit-rule						\
 	clean		"t4fw_cfg.fw"
 t4fw_cfg_uwire.fwo	optional cxgbe					\
 	dependency	"t4fw_cfg_uwire.fw"				\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"t4fw_cfg_uwire.fwo"
 t4fw_cfg_uwire.fw	optional cxgbe					\
 	dependency	"$S/dev/cxgbe/firmware/t4fw_cfg_uwire.txt"	\
 	compile-with	"${CP} ${.ALLSRC} ${.TARGET}"			\
 	no-obj no-implicit-rule						\
 	clean		"t4fw_cfg_uwire.fw"
 t4fw.fwo		optional cxgbe					\
 	dependency	"t4fw.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"t4fw.fwo"
 t4fw.fw			optional cxgbe					\
 	dependency	"$S/dev/cxgbe/firmware/t4fw-1.8.4.0.bin.uu"	\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"t4fw.fw"
 dev/cy/cy.c			optional cy
 dev/cy/cy_isa.c			optional cy isa
 dev/cy/cy_pci.c			optional cy pci
 dev/dc/if_dc.c			optional dc pci
 dev/dc/dcphy.c			optional dc pci
 dev/dc/pnphy.c			optional dc pci
 dev/dcons/dcons.c		optional dcons
 dev/dcons/dcons_crom.c		optional dcons_crom
 dev/dcons/dcons_os.c		optional dcons
 dev/de/if_de.c			optional de pci
 dev/digi/CX.c			optional digi_CX
 dev/digi/CX_PCI.c		optional digi_CX_PCI
 dev/digi/EPCX.c			optional digi_EPCX
 dev/digi/EPCX_PCI.c		optional digi_EPCX_PCI
 dev/digi/Xe.c			optional digi_Xe
 dev/digi/Xem.c			optional digi_Xem
 dev/digi/Xr.c			optional digi_Xr
 dev/digi/digi.c			optional digi
 dev/digi/digi_isa.c		optional digi isa
 dev/digi/digi_pci.c		optional digi pci
 dev/dpt/dpt_eisa.c		optional dpt eisa
 dev/dpt/dpt_pci.c		optional dpt pci
 dev/dpt/dpt_scsi.c		optional dpt
 dev/drm/ati_pcigart.c		optional drm
 dev/drm/drm_agpsupport.c	optional drm
 dev/drm/drm_auth.c		optional drm
 dev/drm/drm_bufs.c		optional drm
 dev/drm/drm_context.c		optional drm
 dev/drm/drm_dma.c		optional drm
 dev/drm/drm_drawable.c		optional drm
 dev/drm/drm_drv.c		optional drm
 dev/drm/drm_fops.c		optional drm
 dev/drm/drm_hashtab.c		optional drm
 dev/drm/drm_ioctl.c		optional drm
 dev/drm/drm_irq.c		optional drm
 dev/drm/drm_lock.c		optional drm
 dev/drm/drm_memory.c		optional drm
 dev/drm/drm_mm.c		optional drm
 dev/drm/drm_pci.c		optional drm
 dev/drm/drm_scatter.c		optional drm
 dev/drm/drm_sman.c		optional drm
 dev/drm/drm_sysctl.c		optional drm
 dev/drm/drm_vm.c		optional drm
 dev/drm/i915_dma.c		optional i915drm
 dev/drm/i915_drv.c		optional i915drm
 dev/drm/i915_irq.c		optional i915drm
 dev/drm/i915_mem.c		optional i915drm
 dev/drm/i915_suspend.c		optional i915drm
 dev/drm/mach64_dma.c		optional mach64drm
 dev/drm/mach64_drv.c		optional mach64drm
 dev/drm/mach64_irq.c		optional mach64drm
 dev/drm/mach64_state.c		optional mach64drm
 dev/drm/mga_dma.c		optional mgadrm
 dev/drm/mga_drv.c		optional mgadrm
 dev/drm/mga_irq.c		optional mgadrm
 dev/drm/mga_state.c		optional mgadrm
 dev/drm/mga_warp.c		optional mgadrm
 dev/drm/r128_cce.c		optional r128drm \
 	compile-with "${NORMAL_C} ${NO_WUNUSED_VALUE} ${NO_WCONSTANT_CONVERSION}"
 dev/drm/r128_drv.c		optional r128drm
 dev/drm/r128_irq.c		optional r128drm
 dev/drm/r128_state.c		optional r128drm \
 	compile-with "${NORMAL_C} ${NO_WUNUSED_VALUE}"
 dev/drm/r300_cmdbuf.c		optional radeondrm
 dev/drm/r600_blit.c		optional radeondrm
 dev/drm/r600_cp.c		optional radeondrm \
 	compile-with "${NORMAL_C} ${NO_WUNUSED_VALUE} ${NO_WCONSTANT_CONVERSION}"
 dev/drm/radeon_cp.c		optional radeondrm \
 	compile-with "${NORMAL_C} ${NO_WUNUSED_VALUE} ${NO_WCONSTANT_CONVERSION}"
 dev/drm/radeon_cs.c		optional radeondrm
 dev/drm/radeon_drv.c		optional radeondrm
 dev/drm/radeon_irq.c		optional radeondrm
 dev/drm/radeon_mem.c		optional radeondrm
 dev/drm/radeon_state.c		optional radeondrm
 dev/drm/savage_bci.c		optional savagedrm
 dev/drm/savage_drv.c		optional savagedrm
 dev/drm/savage_state.c		optional savagedrm
 dev/drm/sis_drv.c		optional sisdrm
 dev/drm/sis_ds.c		optional sisdrm
 dev/drm/sis_mm.c		optional sisdrm
 dev/drm/tdfx_drv.c		optional tdfxdrm
 dev/drm/via_dma.c		optional viadrm
 dev/drm/via_dmablit.c		optional viadrm
 dev/drm/via_drv.c		optional viadrm
 dev/drm/via_irq.c		optional viadrm
 dev/drm/via_map.c		optional viadrm
 dev/drm/via_mm.c		optional viadrm
 dev/drm/via_verifier.c		optional viadrm
 dev/drm/via_video.c		optional viadrm
 dev/ed/if_ed.c			optional ed
 dev/ed/if_ed_novell.c		optional ed
 dev/ed/if_ed_rtl80x9.c		optional ed
 dev/ed/if_ed_pccard.c		optional ed pccard
 dev/ed/if_ed_pci.c		optional ed pci
 dev/eisa/eisa_if.m		standard
 dev/eisa/eisaconf.c		optional eisa
 dev/e1000/if_em.c		optional em \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/if_lem.c		optional em \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/if_igb.c		optional igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_80003es2lan.c	optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82540.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82541.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82542.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82543.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82571.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_82575.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_ich8lan.c	optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_i210.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_api.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_mac.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_manage.c	optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_nvm.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_phy.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_vf.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_mbx.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/e1000/e1000_osdep.c		optional em | igb \
 	compile-with "${NORMAL_C} -I$S/dev/e1000"
 dev/et/if_et.c			optional et
 dev/en/if_en_pci.c		optional en pci
 dev/en/midway.c			optional en
 dev/ep/if_ep.c			optional ep
 dev/ep/if_ep_eisa.c		optional ep eisa
 dev/ep/if_ep_isa.c		optional ep isa
 dev/ep/if_ep_mca.c		optional ep mca
 dev/ep/if_ep_pccard.c		optional ep pccard
 dev/esp/esp_pci.c		optional esp pci
 dev/esp/ncr53c9x.c		optional esp
 dev/etherswitch/arswitch/arswitch.c		optional arswitch
 dev/etherswitch/arswitch/arswitch_reg.c		optional arswitch
 dev/etherswitch/arswitch/arswitch_phy.c		optional arswitch
 dev/etherswitch/arswitch/arswitch_8216.c	optional arswitch
 dev/etherswitch/arswitch/arswitch_8226.c	optional arswitch
 dev/etherswitch/arswitch/arswitch_8316.c	optional arswitch
 dev/etherswitch/arswitch/arswitch_7240.c	optional arswitch
 dev/etherswitch/etherswitch.c		optional etherswitch
 dev/etherswitch/etherswitch_if.m	optional etherswitch
 dev/etherswitch/mdio_if.m		optional miiproxy
 dev/etherswitch/mdio.c			optional miiproxy
 dev/etherswitch/miiproxy.c		optional miiproxy
 dev/etherswitch/rtl8366/rtl8366rb.c	optional rtl8366rb
+dev/etherswitch/ukswitch/ukswitch.c	optional ukswitch
 dev/ex/if_ex.c			optional ex
 dev/ex/if_ex_isa.c		optional ex isa
 dev/ex/if_ex_pccard.c		optional ex pccard
 dev/exca/exca.c			optional cbb
 dev/fatm/if_fatm.c		optional fatm pci
 dev/fb/splash.c			optional splash
 dev/fdt/fdt_common.c		optional fdt
 dev/fdt/fdt_pci.c		optional fdt pci
 dev/fdt/fdt_slicer.c		optional fdt cfi | fdt nand
 dev/fdt/fdt_static_dtb.S	optional fdt fdt_dtb_static \
 	dependency	"$S/boot/fdt/dts/${FDT_DTS_FILE}"
 dev/fdt/fdtbus.c		optional fdt
 dev/fdt/simplebus.c		optional fdt
 dev/fe/if_fe.c			optional fe
 dev/fe/if_fe_pccard.c		optional fe pccard
 dev/firewire/firewire.c		optional firewire
 dev/firewire/fwcrom.c		optional firewire
 dev/firewire/fwdev.c		optional firewire
 dev/firewire/fwdma.c		optional firewire
 dev/firewire/fwmem.c		optional firewire
 dev/firewire/fwohci.c		optional firewire
 dev/firewire/fwohci_pci.c	optional firewire pci
 dev/firewire/if_fwe.c		optional fwe
 dev/firewire/if_fwip.c		optional fwip
 dev/firewire/sbp.c		optional sbp
 dev/firewire/sbp_targ.c		optional sbp_targ
 dev/flash/at45d.c		optional at45d
 dev/flash/mx25l.c		optional mx25l
 dev/fxp/if_fxp.c		optional fxp
 dev/fxp/inphy.c			optional fxp
 dev/gem/if_gem.c		optional gem
 dev/gem/if_gem_pci.c		optional gem pci
 dev/gem/if_gem_sbus.c		optional gem sbus
 dev/gpio/gpiobus.c		optional gpio				\
 	dependency	"gpiobus_if.h"
 dev/gpio/gpioc.c		optional gpio				\
 	dependency	"gpio_if.h"
 dev/gpio/gpioiic.c		optional gpioiic
 dev/gpio/gpioled.c		optional gpioled
 dev/gpio/gpio_if.m		optional gpio
 dev/gpio/gpiobus_if.m		optional gpio
 dev/hatm/if_hatm.c		optional hatm pci
 dev/hatm/if_hatm_intr.c		optional hatm pci
 dev/hatm/if_hatm_ioctl.c	optional hatm pci
 dev/hatm/if_hatm_rx.c		optional hatm pci
 dev/hatm/if_hatm_tx.c		optional hatm pci
 dev/hifn/hifn7751.c		optional hifn
 dev/hme/if_hme.c		optional hme
 dev/hme/if_hme_pci.c		optional hme pci
 dev/hme/if_hme_sbus.c		optional hme sbus
 dev/hptiop/hptiop.c		optional hptiop scbus
 dev/hwpmc/hwpmc_logging.c	optional hwpmc
 dev/hwpmc/hwpmc_mod.c		optional hwpmc
 dev/hwpmc/hwpmc_soft.c		optional hwpmc
 dev/ichsmb/ichsmb.c		optional ichsmb
 dev/ichsmb/ichsmb_pci.c		optional ichsmb pci
 dev/ida/ida.c			optional ida
 dev/ida/ida_disk.c		optional ida
 dev/ida/ida_eisa.c		optional ida eisa
 dev/ida/ida_pci.c		optional ida pci
 dev/ie/if_ie.c			optional ie isa nowerror
 dev/ie/if_ie_isa.c		optional ie isa
 dev/ieee488/ibfoo.c		optional pcii | tnt4882
 dev/ieee488/pcii.c		optional pcii
 dev/ieee488/tnt4882.c		optional tnt4882
 dev/ieee488/upd7210.c		optional pcii | tnt4882
 dev/iicbus/ad7418.c		optional ad7418
 dev/iicbus/ds133x.c		optional ds133x
 dev/iicbus/ds1374.c		optional ds1374
 dev/iicbus/ds1672.c		optional ds1672
 dev/iicbus/icee.c		optional icee
 dev/iicbus/if_ic.c		optional ic
 dev/iicbus/iic.c		optional iic
 dev/iicbus/iicbb.c		optional iicbb
 dev/iicbus/iicbb_if.m		optional iicbb
 dev/iicbus/iicbus.c		optional iicbus
 dev/iicbus/iicbus_if.m		optional iicbus
 dev/iicbus/iiconf.c		optional iicbus
 dev/iicbus/iicsmb.c		optional iicsmb				\
 	dependency	"iicbus_if.h"
 dev/iicbus/iicoc.c		optional iicoc
 dev/iicbus/pcf8563.c		optional pcf8563
 dev/iicbus/s35390a.c		optional s35390a
 dev/iir/iir.c			optional iir
 dev/iir/iir_ctrl.c		optional iir
 dev/iir/iir_pci.c		optional iir pci
 # XXX Work around clang warning, until maintainer approves fix.
 dev/ips/ips.c			optional ips \
 	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
 dev/ips/ips_commands.c		optional ips
 dev/ips/ips_disk.c		optional ips
 dev/ips/ips_ioctl.c		optional ips
 dev/ips/ips_pci.c		optional ips pci
 dev/ipw/if_ipw.c		optional ipw
 ipwbssfw.c			optional ipwbssfw | ipwfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk ipw_bss.fw:ipw_bss:130 -lintel_ipw -mipw_bss -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"ipwbssfw.c"
 ipw_bss.fwo			optional ipwbssfw | ipwfw		\
 	dependency	"ipw_bss.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"ipw_bss.fwo"
 ipw_bss.fw			optional ipwbssfw | ipwfw		\
 	dependency	"$S/contrib/dev/ipw/ipw2100-1.3.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"ipw_bss.fw"
 ipwibssfw.c			optional ipwibssfw | ipwfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk ipw_ibss.fw:ipw_ibss:130 -lintel_ipw -mipw_ibss -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"ipwibssfw.c"
 ipw_ibss.fwo			optional ipwibssfw | ipwfw		\
 	dependency	"ipw_ibss.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"ipw_ibss.fwo"
 ipw_ibss.fw			optional ipwibssfw | ipwfw		\
 	dependency	"$S/contrib/dev/ipw/ipw2100-1.3-i.fw.uu"	\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"ipw_ibss.fw"
 ipwmonitorfw.c			optional ipwmonitorfw | ipwfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk ipw_monitor.fw:ipw_monitor:130 -lintel_ipw -mipw_monitor -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"ipwmonitorfw.c"
 ipw_monitor.fwo			optional ipwmonitorfw | ipwfw		\
 	dependency	"ipw_monitor.fw"				\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"ipw_monitor.fwo"
 ipw_monitor.fw			optional ipwmonitorfw | ipwfw		\
 	dependency	"$S/contrib/dev/ipw/ipw2100-1.3-p.fw.uu"	\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"ipw_monitor.fw"
 dev/iscsi/initiator/iscsi.c	optional iscsi_initiator scbus
 dev/iscsi/initiator/iscsi_subr.c	optional iscsi_initiator scbus
 dev/iscsi/initiator/isc_cam.c	optional iscsi_initiator scbus
 dev/iscsi/initiator/isc_soc.c	optional iscsi_initiator scbus
 dev/iscsi/initiator/isc_sm.c	optional iscsi_initiator scbus
 dev/iscsi/initiator/isc_subr.c	optional iscsi_initiator scbus
 dev/isf/isf.c			optional isf
 dev/isf/isf_fdt.c		optional isf fdt
 dev/isf/isf_nexus.c		optional isf
 dev/isp/isp.c			optional isp
 dev/isp/isp_freebsd.c		optional isp
 dev/isp/isp_library.c		optional isp
 dev/isp/isp_pci.c		optional isp pci
 dev/isp/isp_sbus.c		optional isp sbus
 dev/isp/isp_target.c		optional isp
 dev/ispfw/ispfw.c		optional ispfw
 dev/iwi/if_iwi.c		optional iwi
 iwibssfw.c			optional iwibssfw | iwifw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwi_bss.fw:iwi_bss:300 -lintel_iwi -miwi_bss -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwibssfw.c"
 iwi_bss.fwo			optional iwibssfw | iwifw		\
 	dependency	"iwi_bss.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwi_bss.fwo"
 iwi_bss.fw			optional iwibssfw | iwifw		\
 	dependency	"$S/contrib/dev/iwi/ipw2200-bss.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwi_bss.fw"
 iwiibssfw.c			optional iwiibssfw | iwifw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwi_ibss.fw:iwi_ibss:300 -lintel_iwi -miwi_ibss -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwiibssfw.c"
 iwi_ibss.fwo			optional iwiibssfw | iwifw		\
 	dependency	"iwi_ibss.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwi_ibss.fwo"
 iwi_ibss.fw			optional iwiibssfw | iwifw		\
 	dependency	"$S/contrib/dev/iwi/ipw2200-ibss.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwi_ibss.fw"
 iwimonitorfw.c			optional iwimonitorfw | iwifw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwi_monitor.fw:iwi_monitor:300 -lintel_iwi -miwi_monitor -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwimonitorfw.c"
 iwi_monitor.fwo			optional iwimonitorfw | iwifw		\
 	dependency	"iwi_monitor.fw"				\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwi_monitor.fwo"
 iwi_monitor.fw			optional iwimonitorfw | iwifw		\
 	dependency	"$S/contrib/dev/iwi/ipw2200-sniffer.fw.uu"	\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwi_monitor.fw"
 dev/iwn/if_iwn.c		optional iwn
 iwn1000fw.c			optional iwn1000fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn1000.fw:iwn1000fw -miwn1000fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn1000fw.c"
 iwn1000fw.fwo			optional iwn1000fw | iwnfw		\
 	dependency	"iwn1000.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn1000fw.fwo"
 iwn1000.fw			optional iwn1000fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-1000-39.31.5.1.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn1000.fw"
 iwn4965fw.c			optional iwn4965fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn4965.fw:iwn4965fw -miwn4965fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn4965fw.c"
 iwn4965fw.fwo			optional iwn4965fw | iwnfw		\
 	dependency	"iwn4965.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn4965fw.fwo"
 iwn4965.fw			optional iwn4965fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-4965-228.61.2.24.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn4965.fw"
 iwn5000fw.c			optional iwn5000fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn5000.fw:iwn5000fw -miwn5000fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn5000fw.c"
 iwn5000fw.fwo		optional iwn5000fw | iwnfw			\
 	dependency	"iwn5000.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn5000fw.fwo"
 iwn5000.fw			optional iwn5000fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-5000-8.83.5.1.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn5000.fw"
 iwn5150fw.c			optional iwn5150fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn5150.fw:iwn5150fw -miwn5150fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn5150fw.c"
 iwn5150fw.fwo			optional iwn5150fw | iwnfw		\
 	dependency	"iwn5150.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn5150fw.fwo"
 iwn5150.fw			optional iwn5150fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-5150-8.24.2.2.fw.uu"\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn5150.fw"
 iwn6000fw.c			optional iwn6000fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn6000.fw:iwn6000fw -miwn6000fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn6000fw.c"
 iwn6000fw.fwo			optional iwn6000fw | iwnfw		\
 	dependency	"iwn6000.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn6000fw.fwo"
 iwn6000.fw			optional iwn6000fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-6000-9.221.4.1.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn6000.fw"
 iwn6000g2afw.c			optional iwn6000g2afw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn6000g2a.fw:iwn6000g2afw -miwn6000g2afw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn6000g2afw.c"
 iwn6000g2afw.fwo		optional iwn6000g2afw | iwnfw		\
 	dependency	"iwn6000g2a.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn6000g2afw.fwo"
 iwn6000g2a.fw			optional iwn6000g2afw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-6000g2a-17.168.5.2.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn6000g2a.fw"
 iwn6000g2bfw.c			optional iwn6000g2bfw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn6000g2b.fw:iwn6000g2bfw -miwn6000g2bfw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn6000g2bfw.c"
 iwn6000g2bfw.fwo		optional iwn6000g2bfw | iwnfw		\
 	dependency	"iwn6000g2b.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn6000g2bfw.fwo"
 iwn6000g2b.fw			optional iwn6000g2bfw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-6000g2b-17.168.5.2.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn6000g2b.fw"
 iwn6050fw.c			optional iwn6050fw | iwnfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk iwn6050.fw:iwn6050fw -miwn6050fw -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"iwn6050fw.c"
 iwn6050fw.fwo			optional iwn6050fw | iwnfw		\
 	dependency	"iwn6050.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"iwn6050fw.fwo"
 iwn6050.fw			optional iwn6050fw | iwnfw		\
 	dependency	"$S/contrib/dev/iwn/iwlwifi-6050-41.28.5.1.fw.uu" \
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"iwn6050.fw"
 dev/ixgb/if_ixgb.c		optional ixgb
 dev/ixgb/ixgb_ee.c		optional ixgb
 dev/ixgb/ixgb_hw.c		optional ixgb
 dev/ixgbe/ixgbe.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe -DSMP -DIXGBE_FDIR"
 dev/ixgbe/ixv.c			optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_phy.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_api.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_common.c	optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_mbx.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_vf.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_82598.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_82599.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/ixgbe/ixgbe_x540.c		optional ixgbe inet \
 	compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/jme/if_jme.c		optional jme pci
 dev/joy/joy.c			optional joy
 dev/joy/joy_isa.c		optional joy isa
 dev/joy/joy_pccard.c		optional joy pccard
 dev/kbdmux/kbdmux.c		optional kbdmux
 dev/ksyms/ksyms.c		optional ksyms
 dev/le/am7990.c			optional le
 dev/le/am79900.c		optional le
 dev/le/if_le_pci.c		optional le pci
 dev/le/lance.c			optional le
 dev/led/led.c			standard
 dev/lge/if_lge.c		optional lge
 dev/lmc/if_lmc.c		optional lmc
 dev/malo/if_malo.c		optional malo
 dev/malo/if_malohal.c		optional malo
 dev/malo/if_malo_pci.c		optional malo pci
 dev/mc146818/mc146818.c		optional mc146818
 dev/mca/mca_bus.c		optional mca
 dev/mcd/mcd.c			optional mcd isa nowerror
 dev/mcd/mcd_isa.c		optional mcd isa nowerror
 dev/md/md.c			optional md
 dev/mem/memdev.c		optional mem
 dev/mem/memutil.c		optional mem
 dev/mfi/mfi.c			optional mfi
 dev/mfi/mfi_debug.c		optional mfi
 dev/mfi/mfi_pci.c		optional mfi pci
 dev/mfi/mfi_disk.c		optional mfi
 dev/mfi/mfi_syspd.c		optional mfi
 dev/mfi/mfi_tbolt.c		optional mfi
 dev/mfi/mfi_linux.c		optional mfi compat_linux
 dev/mfi/mfi_cam.c		optional mfip scbus
 dev/mii/acphy.c			optional miibus | acphy
 dev/mii/amphy.c			optional miibus | amphy
 dev/mii/atphy.c			optional miibus | atphy
 dev/mii/axphy.c			optional miibus | axphy
 dev/mii/bmtphy.c		optional miibus | bmtphy
 dev/mii/brgphy.c		optional miibus | brgphy
 dev/mii/ciphy.c			optional miibus | ciphy
 dev/mii/e1000phy.c		optional miibus | e1000phy
 dev/mii/gentbi.c		optional miibus | gentbi
 dev/mii/icsphy.c		optional miibus | icsphy
 dev/mii/ip1000phy.c		optional miibus | ip1000phy
 dev/mii/jmphy.c			optional miibus | jmphy
 dev/mii/lxtphy.c		optional miibus | lxtphy
 dev/mii/mii.c			optional miibus | mii
 dev/mii/mii_bitbang.c		optional miibus | mii_bitbang
 dev/mii/mii_physubr.c		optional miibus | mii
 dev/mii/miibus_if.m		optional miibus | mii
 dev/mii/mlphy.c			optional miibus | mlphy
 dev/mii/nsgphy.c		optional miibus | nsgphy
 dev/mii/nsphy.c			optional miibus | nsphy
 dev/mii/nsphyter.c		optional miibus | nsphyter
 dev/mii/pnaphy.c		optional miibus | pnaphy
 dev/mii/qsphy.c			optional miibus | qsphy
 dev/mii/rdcphy.c		optional miibus | rdcphy
 dev/mii/rgephy.c		optional miibus | rgephy
 dev/mii/rlphy.c			optional miibus | rlphy
 dev/mii/rlswitch.c		optional rlswitch
 dev/mii/smcphy.c		optional miibus | smcphy
 dev/mii/smscphy.c		optional miibus | smscphy
 dev/mii/tdkphy.c		optional miibus | tdkphy
 dev/mii/tlphy.c			optional miibus | tlphy
 dev/mii/truephy.c		optional miibus | truephy
 dev/mii/ukphy.c			optional miibus | mii
 dev/mii/ukphy_subr.c		optional miibus | mii
 dev/mii/xmphy.c			optional miibus | xmphy
 dev/mk48txx/mk48txx.c		optional mk48txx
 dev/mlx/mlx.c			optional mlx
 dev/mlx/mlx_disk.c		optional mlx
 dev/mlx/mlx_pci.c		optional mlx pci
 dev/mly/mly.c			optional mly
 dev/mmc/mmc.c			optional mmc
 dev/mmc/mmcbr_if.m		standard
 dev/mmc/mmcbus_if.m		standard
 dev/mmc/mmcsd.c			optional mmcsd
 dev/mn/if_mn.c			optional mn pci
 dev/mps/mps.c			optional mps
 dev/mps/mps_config.c		optional mps
 # XXX Work around clang warning, until maintainer approves fix.
 dev/mps/mps_mapping.c		optional mps \
 	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
 dev/mps/mps_pci.c		optional mps pci
 dev/mps/mps_sas.c		optional mps \
 	compile-with "${NORMAL_C} ${NO_WUNNEEDED_INTERNAL_DECL}"
 dev/mps/mps_sas_lsi.c		optional mps
 dev/mps/mps_table.c		optional mps
 dev/mps/mps_user.c		optional mps
 dev/mpt/mpt.c			optional mpt
 dev/mpt/mpt_cam.c		optional mpt
 dev/mpt/mpt_debug.c		optional mpt
 dev/mpt/mpt_pci.c		optional mpt pci
 dev/mpt/mpt_raid.c		optional mpt
 dev/mpt/mpt_user.c		optional mpt
 dev/msk/if_msk.c		optional msk
 dev/mvs/mvs.c			optional mvs
 dev/mvs/mvs_if.m		optional mvs
 dev/mvs/mvs_pci.c		optional mvs pci
 dev/mwl/if_mwl.c		optional mwl
 dev/mwl/if_mwl_pci.c		optional mwl pci
 dev/mwl/mwlhal.c		optional mwl
 mwlfw.c				optional mwlfw				\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk mw88W8363.fw:mw88W8363fw mwlboot.fw:mwlboot -mmwl -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"mwlfw.c"
 mw88W8363.fwo		optional mwlfw					\
 	dependency	"mw88W8363.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"mw88W8363.fwo"
 mw88W8363.fw		optional mwlfw					\
 	dependency	"$S/contrib/dev/mwl/mw88W8363.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"mw88W8363.fw"
 mwlboot.fwo		optional mwlfw					\
 	dependency	"mwlboot.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"mwlboot.fwo"
 mwlboot.fw		optional mwlfw					\
 	dependency	"$S/contrib/dev/mwl/mwlboot.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"mwlboot.fw"
 dev/mxge/if_mxge.c		optional mxge pci
 dev/mxge/mxge_eth_z8e.c		optional mxge pci
 dev/mxge/mxge_ethp_z8e.c	optional mxge pci
 dev/mxge/mxge_rss_eth_z8e.c	optional mxge pci
 dev/mxge/mxge_rss_ethp_z8e.c	optional mxge pci
 dev/my/if_my.c			optional my
 dev/nand/nand.c			optional nand
 dev/nand/nand_bbt.c		optional nand
 dev/nand/nand_cdev.c		optional nand
 dev/nand/nand_generic.c		optional nand
 dev/nand/nand_geom.c		optional nand
 dev/nand/nand_id.c		optional nand
 dev/nand/nandbus.c		optional nand
 dev/nand/nandbus_if.m		optional nand
 dev/nand/nand_if.m		optional nand
 dev/nand/nandsim.c		optional nandsim nand
 dev/nand/nandsim_chip.c		optional nandsim nand
 dev/nand/nandsim_ctrl.c		optional nandsim nand
 dev/nand/nandsim_log.c		optional nandsim nand
 dev/nand/nandsim_swap.c		optional nandsim nand
 dev/nand/nfc_if.m		optional nand
 dev/ncv/ncr53c500.c		optional ncv
 dev/ncv/ncr53c500_pccard.c	optional ncv pccard
 dev/netmap/netmap.c		optional netmap
 dev/nge/if_nge.c		optional nge
 dev/nxge/if_nxge.c		optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-device.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-mm.c	optional nxge
 dev/nxge/xgehal/xge-queue.c	optional nxge
 dev/nxge/xgehal/xgehal-driver.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-ring.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-channel.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-fifo.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-stats.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nxge/xgehal/xgehal-config.c	optional nxge
 dev/nxge/xgehal/xgehal-mgmt.c	optional nxge \
 	compile-with "${NORMAL_C} ${NO_WSELF_ASSIGN}"
 dev/nmdm/nmdm.c			optional nmdm
 dev/nsp/nsp.c			optional nsp
 dev/nsp/nsp_pccard.c		optional nsp pccard
 dev/null/null.c			standard
 dev/oce/oce_hw.c		optional oce pci
 dev/oce/oce_if.c		optional oce pci
 dev/oce/oce_mbox.c		optional oce pci
 dev/oce/oce_queue.c		optional oce pci
 dev/oce/oce_sysctl.c		optional oce pci
 dev/oce/oce_util.c		optional oce pci
 dev/ofw/ofw_bus_if.m		optional fdt
 dev/ofw/ofw_bus_subr.c		optional fdt
 dev/ofw/ofw_fdt.c		optional fdt
 dev/ofw/ofw_if.m		optional fdt
 dev/ofw/openfirm.c		optional fdt
 dev/ofw/openfirmio.c		optional fdt
 dev/patm/if_patm.c		optional patm pci
 dev/patm/if_patm_attach.c	optional patm pci
 dev/patm/if_patm_intr.c		optional patm pci
 dev/patm/if_patm_ioctl.c	optional patm pci
 dev/patm/if_patm_rtables.c	optional patm pci
 dev/patm/if_patm_rx.c		optional patm pci
 dev/patm/if_patm_tx.c		optional patm pci
 dev/pbio/pbio.c			optional pbio isa
 dev/pccard/card_if.m		standard
 dev/pccard/pccard.c		optional pccard
 dev/pccard/pccard_cis.c		optional pccard
 dev/pccard/pccard_cis_quirks.c	optional pccard
 dev/pccard/pccard_device.c	optional pccard
 dev/pccard/power_if.m		standard
 dev/pccbb/pccbb.c		optional cbb
 dev/pccbb/pccbb_isa.c		optional cbb isa
 dev/pccbb/pccbb_pci.c		optional cbb pci
 dev/pcf/pcf.c			optional pcf
 dev/pci/eisa_pci.c		optional pci eisa
 dev/pci/fixup_pci.c		optional pci
 dev/pci/hostb_pci.c		optional pci
 dev/pci/ignore_pci.c		optional pci
 dev/pci/isa_pci.c		optional pci isa
 dev/pci/pci.c			optional pci
 dev/pci/pci_if.m		standard
 dev/pci/pci_pci.c		optional pci
 dev/pci/pci_subr.c		optional pci
 dev/pci/pci_user.c		optional pci
 dev/pci/pcib_if.m		standard
 dev/pci/vga_pci.c		optional pci
 dev/pcn/if_pcn.c		optional pcn pci
 dev/pdq/if_fea.c		optional fea eisa
 dev/pdq/if_fpa.c		optional fpa pci
 dev/pdq/pdq.c			optional nowerror fea eisa | fpa pci
 dev/pdq/pdq_ifsubr.c		optional nowerror fea eisa | fpa pci
 dev/ppbus/if_plip.c		optional plip
 dev/ppbus/immio.c		optional vpo
 dev/ppbus/lpbb.c		optional lpbb
 dev/ppbus/lpt.c			optional lpt
 dev/ppbus/pcfclock.c		optional pcfclock
 dev/ppbus/ppb_1284.c		optional ppbus
 dev/ppbus/ppb_base.c		optional ppbus
 dev/ppbus/ppb_msq.c		optional ppbus
 dev/ppbus/ppbconf.c		optional ppbus
 dev/ppbus/ppbus_if.m		optional ppbus
 dev/ppbus/ppi.c			optional ppi
 dev/ppbus/pps.c			optional pps
 dev/ppbus/vpo.c			optional vpo
 dev/ppbus/vpoio.c		optional vpo
 dev/ppc/ppc.c			optional ppc
 dev/ppc/ppc_acpi.c		optional ppc acpi
 dev/ppc/ppc_isa.c		optional ppc isa
 dev/ppc/ppc_pci.c		optional ppc pci
 dev/ppc/ppc_puc.c		optional ppc puc
 dev/pst/pst-iop.c		optional pst
 dev/pst/pst-pci.c		optional pst pci
 dev/pst/pst-raid.c		optional pst
 dev/pty/pty.c			optional pty
 dev/puc/puc.c			optional puc
 dev/puc/puc_cfg.c		optional puc
 dev/puc/puc_pccard.c		optional puc pccard
 dev/puc/puc_pci.c		optional puc pci
 dev/puc/pucdata.c		optional puc pci
 dev/quicc/quicc_core.c		optional quicc
 dev/ral/rt2560.c		optional ral
 dev/ral/rt2661.c		optional ral
 dev/ral/rt2860.c		optional ral
 dev/ral/if_ral_pci.c		optional ral pci
 rt2561fw.c			optional rt2561fw | ralfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk rt2561.fw:rt2561fw -mrt2561 -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"rt2561fw.c"
 rt2561fw.fwo			optional rt2561fw | ralfw		\
 	dependency	"rt2561.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"rt2561fw.fwo"
 rt2561.fw			optional rt2561fw | ralfw		\
 	dependency	"$S/contrib/dev/ral/rt2561.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"rt2561.fw"
 rt2561sfw.c			optional rt2561sfw | ralfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk rt2561s.fw:rt2561sfw -mrt2561s -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"rt2561sfw.c"
 rt2561sfw.fwo			optional rt2561sfw | ralfw		\
 	dependency	"rt2561s.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"rt2561sfw.fwo"
 rt2561s.fw			optional rt2561sfw | ralfw		\
 	dependency	"$S/contrib/dev/ral/rt2561s.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"rt2561s.fw"
 rt2661fw.c			optional rt2661fw | ralfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk rt2661.fw:rt2661fw -mrt2661 -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"rt2661fw.c"
 rt2661fw.fwo			optional rt2661fw | ralfw		\
 	dependency	"rt2661.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"rt2661fw.fwo"
 rt2661.fw			optional rt2661fw | ralfw		\
 	dependency	"$S/contrib/dev/ral/rt2661.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"rt2661.fw"
 rt2860fw.c			optional rt2860fw | ralfw		\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk rt2860.fw:rt2860fw -mrt2860 -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"rt2860fw.c"
 rt2860fw.fwo			optional rt2860fw | ralfw		\
 	dependency	"rt2860.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"rt2860fw.fwo"
 rt2860.fw			optional rt2860fw | ralfw		\
 	dependency	"$S/contrib/dev/ral/rt2860.fw.uu"		\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"rt2860.fw"
 dev/random/harvest.c		standard
 dev/random/hash.c		optional random
 dev/random/probe.c		optional random
 dev/random/randomdev.c		optional random
 dev/random/randomdev_soft.c	optional random
 dev/random/yarrow.c		optional random
 dev/rc/rc.c			optional rc
 dev/re/if_re.c			optional re
 dev/rndtest/rndtest.c		optional rndtest
 dev/rp/rp.c			optional rp
 dev/rp/rp_isa.c			optional rp isa
 dev/rp/rp_pci.c			optional rp pci
 dev/safe/safe.c			optional safe
 dev/scc/scc_if.m		optional scc
 dev/scc/scc_bfe_ebus.c		optional scc ebus
 dev/scc/scc_bfe_quicc.c		optional scc quicc
 dev/scc/scc_bfe_sbus.c		optional scc fhc | scc sbus
 dev/scc/scc_core.c		optional scc
 dev/scc/scc_dev_quicc.c		optional scc quicc
 dev/scc/scc_dev_sab82532.c	optional scc
 dev/scc/scc_dev_z8530.c		optional scc
 dev/scd/scd.c			optional scd isa
 dev/scd/scd_isa.c		optional scd isa
 dev/sdhci/sdhci.c		optional sdhci
 dev/sdhci/sdhci_if.m		optional sdhci
 dev/sdhci/sdhci_pci.c		optional sdhci pci
 dev/sf/if_sf.c			optional sf pci
 dev/sge/if_sge.c		optional sge pci
 dev/si/si.c			optional si
 dev/si/si2_z280.c		optional si
 dev/si/si3_t225.c		optional si
 dev/si/si_eisa.c		optional si eisa
 dev/si/si_isa.c			optional si isa
 dev/si/si_pci.c			optional si pci
 dev/siba/siba.c			optional siba
 dev/siba/siba_bwn.c		optional siba_bwn pci
 dev/siba/siba_cc.c		optional siba
 dev/siba/siba_core.c		optional siba | siba_bwn pci
 dev/siba/siba_pcib.c		optional siba pci
 dev/siis/siis.c			optional siis pci
 dev/sis/if_sis.c		optional sis pci
 dev/sk/if_sk.c			optional sk pci
 dev/smbus/smb.c			optional smb
 dev/smbus/smbconf.c		optional smbus
 dev/smbus/smbus.c		optional smbus
 dev/smbus/smbus_if.m		optional smbus
 dev/smc/if_smc.c		optional smc
 dev/sn/if_sn.c			optional sn
 dev/sn/if_sn_isa.c		optional sn isa
 dev/sn/if_sn_pccard.c		optional sn pccard
 dev/snp/snp.c			optional snp
 dev/sound/clone.c		optional sound
 dev/sound/unit.c		optional sound
 dev/sound/isa/ad1816.c		optional snd_ad1816 isa
 dev/sound/isa/ess.c		optional snd_ess isa
 dev/sound/isa/gusc.c		optional snd_gusc isa
 dev/sound/isa/mss.c		optional snd_mss isa
 dev/sound/isa/sb16.c		optional snd_sb16 isa
 dev/sound/isa/sb8.c		optional snd_sb8 isa
 dev/sound/isa/sbc.c		optional snd_sbc isa
 dev/sound/isa/sndbuf_dma.c	optional sound isa
 dev/sound/pci/als4000.c		optional snd_als4000 pci
 dev/sound/pci/atiixp.c		optional snd_atiixp pci
 dev/sound/pci/cmi.c		optional snd_cmi pci
 dev/sound/pci/cs4281.c		optional snd_cs4281 pci
 dev/sound/pci/csa.c		optional snd_csa pci
 dev/sound/pci/csapcm.c		optional snd_csa pci
 dev/sound/pci/ds1.c		optional snd_ds1 pci
 dev/sound/pci/emu10k1.c		optional snd_emu10k1 pci
 dev/sound/pci/emu10kx.c		optional snd_emu10kx pci
 dev/sound/pci/emu10kx-pcm.c	optional snd_emu10kx pci
 dev/sound/pci/emu10kx-midi.c	optional snd_emu10kx pci
 dev/sound/pci/envy24.c		optional snd_envy24 pci
 dev/sound/pci/envy24ht.c	optional snd_envy24ht pci
 dev/sound/pci/es137x.c		optional snd_es137x pci
 dev/sound/pci/fm801.c		optional snd_fm801 pci
 dev/sound/pci/ich.c		optional snd_ich pci
 dev/sound/pci/maestro.c		optional snd_maestro pci
 dev/sound/pci/maestro3.c	optional snd_maestro3 pci
 dev/sound/pci/neomagic.c	optional snd_neomagic pci
 dev/sound/pci/solo.c		optional snd_solo pci
 dev/sound/pci/spicds.c		optional snd_spicds pci
 dev/sound/pci/t4dwave.c		optional snd_t4dwave pci
 dev/sound/pci/via8233.c		optional snd_via8233 pci
 dev/sound/pci/via82c686.c	optional snd_via82c686 pci
 dev/sound/pci/vibes.c		optional snd_vibes pci
 dev/sound/pci/hda/hdaa.c	optional snd_hda pci
 dev/sound/pci/hda/hdaa_patches.c	optional snd_hda pci
 dev/sound/pci/hda/hdac.c	optional snd_hda pci
 dev/sound/pci/hda/hdac_if.m	optional snd_hda pci
 dev/sound/pci/hda/hdacc.c	optional snd_hda pci
 dev/sound/pci/hdspe.c		optional snd_hdspe pci
 dev/sound/pci/hdspe-pcm.c	optional snd_hdspe pci
 dev/sound/pcm/ac97.c		optional sound
 dev/sound/pcm/ac97_if.m		optional sound
 dev/sound/pcm/ac97_patch.c	optional sound
 dev/sound/pcm/buffer.c		optional sound	\
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/channel.c		optional sound
 dev/sound/pcm/channel_if.m	optional sound
 dev/sound/pcm/dsp.c		optional sound
 dev/sound/pcm/feeder.c		optional sound
 dev/sound/pcm/feeder_chain.c	optional sound
 dev/sound/pcm/feeder_eq.c	optional sound	\
 	dependency	"feeder_eq_gen.h"	\
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/feeder_if.m	optional sound
 dev/sound/pcm/feeder_format.c	optional sound  \
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/feeder_matrix.c	optional sound  \
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/feeder_mixer.c	optional sound  \
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/feeder_rate.c	optional sound	\
 	dependency	"feeder_rate_gen.h"	\
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/feeder_volume.c	optional sound  \
 	dependency	"snd_fxdiv_gen.h"
 dev/sound/pcm/mixer.c		optional sound
 dev/sound/pcm/mixer_if.m	optional sound
 dev/sound/pcm/sndstat.c		optional sound
 dev/sound/pcm/sound.c		optional sound
 dev/sound/pcm/vchan.c		optional sound
 dev/sound/usb/uaudio.c		optional snd_uaudio usb
 dev/sound/usb/uaudio_pcm.c	optional snd_uaudio usb
 dev/sound/midi/midi.c		optional sound
 dev/sound/midi/mpu401.c		optional sound
 dev/sound/midi/mpu_if.m		optional sound
 dev/sound/midi/mpufoi_if.m	optional sound
 dev/sound/midi/sequencer.c	optional sound
 dev/sound/midi/synth_if.m	optional sound
 dev/spibus/spibus.c		optional spibus				\
 	dependency	"spibus_if.h"
 dev/spibus/spibus_if.m		optional spibus
 dev/ste/if_ste.c		optional ste pci
 dev/stg/tmc18c30.c		optional stg
 dev/stg/tmc18c30_isa.c		optional stg isa
 dev/stg/tmc18c30_pccard.c	optional stg pccard
 dev/stg/tmc18c30_pci.c		optional stg pci
 dev/stg/tmc18c30_subr.c		optional stg
 dev/stge/if_stge.c		optional stge
 dev/streams/streams.c		optional streams
 dev/sym/sym_hipd.c		optional sym				\
 	dependency	"$S/dev/sym/sym_{conf,defs}.h"
 dev/syscons/blank/blank_saver.c	optional blank_saver
 dev/syscons/daemon/daemon_saver.c optional daemon_saver
 dev/syscons/dragon/dragon_saver.c optional dragon_saver
 dev/syscons/fade/fade_saver.c	optional fade_saver
 dev/syscons/fire/fire_saver.c	optional fire_saver
 dev/syscons/green/green_saver.c	optional green_saver
 dev/syscons/logo/logo.c		optional logo_saver
 dev/syscons/logo/logo_saver.c	optional logo_saver
 dev/syscons/rain/rain_saver.c	optional rain_saver
 dev/syscons/schistory.c		optional sc
 dev/syscons/scmouse.c		optional sc
 dev/syscons/scterm.c		optional sc
 dev/syscons/scvidctl.c		optional sc
 dev/syscons/snake/snake_saver.c	optional snake_saver
 dev/syscons/star/star_saver.c	optional star_saver
 dev/syscons/syscons.c		optional sc
 dev/syscons/sysmouse.c		optional sc
 dev/syscons/warp/warp_saver.c	optional warp_saver
 dev/tdfx/tdfx_linux.c		optional tdfx_linux tdfx compat_linux
 dev/tdfx/tdfx_pci.c		optional tdfx pci
 dev/ti/if_ti.c			optional ti pci
 dev/tl/if_tl.c			optional tl pci
 dev/trm/trm.c			optional trm
 dev/twa/tw_cl_init.c		optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twa/tw_cl_intr.c		optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twa/tw_cl_io.c		optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twa/tw_cl_misc.c		optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twa/tw_osl_cam.c		optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twa/tw_osl_freebsd.c	optional twa \
 	compile-with "${NORMAL_C} -I$S/dev/twa"
 dev/twe/twe.c			optional twe
 dev/twe/twe_freebsd.c		optional twe
 dev/tws/tws.c			optional tws
 dev/tws/tws_cam.c		optional tws
 dev/tws/tws_hdm.c		optional tws
 dev/tws/tws_services.c		optional tws
 dev/tws/tws_user.c		optional tws
 dev/tx/if_tx.c			optional tx
 dev/txp/if_txp.c		optional txp
 dev/uart/uart_bus_acpi.c	optional uart acpi
 #dev/uart/uart_bus_cbus.c	optional uart cbus
 dev/uart/uart_bus_ebus.c	optional uart ebus
 dev/uart/uart_bus_fdt.c		optional uart fdt
 dev/uart/uart_bus_isa.c		optional uart isa
 dev/uart/uart_bus_pccard.c	optional uart pccard
 dev/uart/uart_bus_pci.c		optional uart pci
 dev/uart/uart_bus_puc.c		optional uart puc
 dev/uart/uart_bus_scc.c		optional uart scc
 dev/uart/uart_core.c		optional uart
 dev/uart/uart_dbg.c		optional uart gdb
 dev/uart/uart_dev_ns8250.c	optional uart uart_ns8250
 dev/uart/uart_dev_pl011.c	optional uart pl011
 dev/uart/uart_dev_quicc.c	optional uart quicc
 dev/uart/uart_dev_sab82532.c	optional uart uart_sab82532
 dev/uart/uart_dev_sab82532.c	optional uart scc
 dev/uart/uart_dev_z8530.c	optional uart uart_z8530
 dev/uart/uart_dev_z8530.c	optional uart scc
 dev/uart/uart_if.m		optional uart
 dev/uart/uart_subr.c		optional uart
 dev/uart/uart_tty.c		optional uart
 dev/ubsec/ubsec.c		optional ubsec
 #
 # USB controller drivers
 #
 dev/usb/controller/at91dci.c		optional at91dci
 dev/usb/controller/at91dci_atmelarm.c	optional at91dci at91rm9200
 dev/usb/controller/musb_otg.c		optional musb
 dev/usb/controller/musb_otg_atmelarm.c	optional musb at91rm9200
 dev/usb/controller/dwc_otg.c		optional dwcotg
 dev/usb/controller/ehci.c		optional ehci
 dev/usb/controller/ehci_pci.c		optional ehci pci
 dev/usb/controller/ohci.c		optional ohci
 dev/usb/controller/ohci_atmelarm.c	optional ohci at91rm9200
 dev/usb/controller/ohci_pci.c		optional ohci pci
 dev/usb/controller/uhci.c		optional uhci
 dev/usb/controller/uhci_pci.c		optional uhci pci
 dev/usb/controller/xhci.c		optional xhci
 dev/usb/controller/xhci_pci.c		optional xhci pci
 dev/usb/controller/uss820dci.c		optional uss820dci
 dev/usb/controller/uss820dci_atmelarm.c	optional uss820dci at91rm9200
 dev/usb/controller/usb_controller.c	optional usb
 #
 # USB storage drivers
 #
 dev/usb/storage/umass.c		optional umass
 dev/usb/storage/urio.c		optional urio
 dev/usb/storage/ustorage_fs.c	optional usfs
 #
 # USB core
 #
 dev/usb/usb_busdma.c		optional usb
 dev/usb/usb_compat_linux.c	optional usb
 dev/usb/usb_core.c		optional usb
 dev/usb/usb_debug.c		optional usb
 dev/usb/usb_dev.c		optional usb
 dev/usb/usb_device.c		optional usb
 dev/usb/usb_dynamic.c		optional usb
 dev/usb/usb_error.c		optional usb
 dev/usb/usb_generic.c		optional usb
 dev/usb/usb_handle_request.c	optional usb
 dev/usb/usb_hid.c		optional usb
 dev/usb/usb_hub.c		optional usb
 dev/usb/usb_if.m		optional usb
 dev/usb/usb_lookup.c		optional usb
 dev/usb/usb_mbuf.c		optional usb
 dev/usb/usb_msctest.c		optional usb
 dev/usb/usb_parse.c		optional usb
 dev/usb/usb_pf.c		optional usb
 dev/usb/usb_process.c		optional usb
 dev/usb/usb_request.c		optional usb
 dev/usb/usb_transfer.c		optional usb
 dev/usb/usb_util.c		optional usb
 #
 # USB network drivers
 #
 dev/usb/net/if_aue.c		optional aue
 dev/usb/net/if_axe.c		optional axe
 dev/usb/net/if_cdce.c		optional cdce
 dev/usb/net/if_cue.c		optional cue
 dev/usb/net/if_ipheth.c		optional ipheth
 dev/usb/net/if_kue.c		optional kue
 dev/usb/net/if_mos.c		optional mos
 dev/usb/net/if_rue.c		optional rue
 dev/usb/net/if_smsc.c		optional smsc
 dev/usb/net/if_udav.c		optional udav
 dev/usb/net/if_usie.c		optional usie
 dev/usb/net/ruephy.c		optional rue
 dev/usb/net/usb_ethernet.c	optional aue | axe | cdce | cue | kue | mos | \
 					 rue | smsc | udav | ipheth
 dev/usb/net/uhso.c		optional uhso
 #
 # USB WLAN drivers
 #
 dev/usb/wlan/if_rum.c		optional rum
 dev/usb/wlan/if_run.c		optional run
 runfw.c				optional runfw							\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk runfw:runfw -mrunfw -c${.TARGET}"	\
 	no-implicit-rule before-depend local							\
 	clean		"runfw.c"
 runfw.fwo			optional runfw							\
 	dependency	"runfw"									\
 	compile-with	"${NORMAL_FWO}"								\
 	no-implicit-rule									\
 	clean		"runfw.fwo"
 runfw				optional runfw							\
 	dependency	"$S/contrib/dev/run/rt2870.fw.uu"					\
 	compile-with	"${NORMAL_FW}"								\
 	no-obj no-implicit-rule									\
 	clean		"runfw"
 dev/usb/wlan/if_uath.c		optional uath
 dev/usb/wlan/if_upgt.c		optional upgt
 dev/usb/wlan/if_ural.c		optional ural
 dev/usb/wlan/if_urtw.c		optional urtw
 dev/usb/wlan/if_zyd.c		optional zyd
 #
 # USB serial and parallel port drivers
 #
 dev/usb/serial/u3g.c		optional u3g
 dev/usb/serial/uark.c		optional uark
 dev/usb/serial/ubsa.c		optional ubsa
 dev/usb/serial/ubser.c		optional ubser
 dev/usb/serial/uchcom.c		optional uchcom
 dev/usb/serial/ucycom.c		optional ucycom
 dev/usb/serial/ufoma.c		optional ufoma
 dev/usb/serial/uftdi.c		optional uftdi
 dev/usb/serial/ugensa.c		optional ugensa
 dev/usb/serial/uipaq.c		optional uipaq
 dev/usb/serial/ulpt.c		optional ulpt
 dev/usb/serial/umcs.c		optional umcs
 dev/usb/serial/umct.c		optional umct
 dev/usb/serial/umodem.c		optional umodem
 dev/usb/serial/umoscom.c	optional umoscom
 dev/usb/serial/uplcom.c		optional uplcom
 dev/usb/serial/uslcom.c		optional uslcom
 dev/usb/serial/uvisor.c		optional uvisor
 dev/usb/serial/uvscom.c		optional uvscom
 dev/usb/serial/usb_serial.c 	optional ucom | u3g | uark | ubsa | ubser | \
 					 uchcom | ucycom | ufoma | uftdi | \
 					 ugensa | uipaq | umcs | umct | \
 					 umodem | umoscom | uplcom | usie | \
 					 uslcom | uvisor | uvscom
 #
 # USB misc drivers
 #
 dev/usb/misc/ufm.c		optional ufm
 dev/usb/misc/udbp.c		optional udbp
 #
 # USB input drivers
 #
 dev/usb/input/atp.c		optional atp
 dev/usb/input/uep.c		optional uep
 dev/usb/input/uhid.c		optional uhid
 dev/usb/input/ukbd.c		optional ukbd
 dev/usb/input/ums.c		optional ums
 #
 # USB quirks
 #
 dev/usb/quirk/usb_quirk.c	optional usb
 #
 # USB templates
 #
 dev/usb/template/usb_template.c		optional usb_template
 dev/usb/template/usb_template_audio.c	optional usb_template
 dev/usb/template/usb_template_cdce.c	optional usb_template
 dev/usb/template/usb_template_kbd.c	optional usb_template
 dev/usb/template/usb_template_modem.c	optional usb_template
 dev/usb/template/usb_template_mouse.c	optional usb_template
 dev/usb/template/usb_template_msc.c	optional usb_template
 dev/usb/template/usb_template_mtp.c	optional usb_template
 #
 # USB END
 #
 dev/utopia/idtphy.c		optional utopia
 dev/utopia/suni.c		optional utopia
 dev/utopia/utopia.c		optional utopia
 dev/vge/if_vge.c		optional vge
 
 dev/vkbd/vkbd.c			optional vkbd
 dev/vr/if_vr.c			optional vr pci
 dev/vte/if_vte.c		optional vte pci
 dev/vx/if_vx.c			optional vx
 dev/vx/if_vx_eisa.c		optional vx eisa
 dev/vx/if_vx_pci.c		optional vx pci
 dev/vxge/vxge.c				optional vxge
 dev/vxge/vxgehal/vxgehal-ifmsg.c	optional vxge
 dev/vxge/vxgehal/vxgehal-mrpcim.c	optional vxge
 dev/vxge/vxgehal/vxge-queue.c		optional vxge
 dev/vxge/vxgehal/vxgehal-ring.c		optional vxge
 dev/vxge/vxgehal/vxgehal-swapper.c	optional vxge
 dev/vxge/vxgehal/vxgehal-mgmt.c		optional vxge
 dev/vxge/vxgehal/vxgehal-srpcim.c	optional vxge
 dev/vxge/vxgehal/vxgehal-config.c	optional vxge
 dev/vxge/vxgehal/vxgehal-blockpool.c	optional vxge
 dev/vxge/vxgehal/vxgehal-doorbells.c	optional vxge
 dev/vxge/vxgehal/vxgehal-mgmtaux.c	optional vxge
 dev/vxge/vxgehal/vxgehal-device.c	optional vxge
 dev/vxge/vxgehal/vxgehal-mm.c		optional vxge
 dev/vxge/vxgehal/vxgehal-driver.c	optional vxge
 dev/vxge/vxgehal/vxgehal-virtualpath.c	optional vxge
 dev/vxge/vxgehal/vxgehal-channel.c	optional vxge
 dev/vxge/vxgehal/vxgehal-fifo.c		optional vxge
 dev/watchdog/watchdog.c		standard
 dev/wb/if_wb.c			optional wb pci
 dev/wds/wd7000.c		optional wds isa
 dev/wi/if_wi.c			optional wi
 dev/wi/if_wi_pccard.c		optional wi pccard
 dev/wi/if_wi_pci.c		optional wi pci
 dev/wl/if_wl.c			optional wl isa
 dev/wpi/if_wpi.c		optional wpi pci
 wpifw.c			optional wpifw					\
 	compile-with	"${AWK} -f $S/tools/fw_stub.awk wpi.fw:wpifw:153229 -mwpi -c${.TARGET}" \
 	no-implicit-rule before-depend local				\
 	clean		"wpifw.c"
 wpifw.fwo			optional wpifw				\
 	dependency	"wpi.fw"					\
 	compile-with	"${NORMAL_FWO}"					\
 	no-implicit-rule						\
 	clean		"wpifw.fwo"
 wpi.fw			optional wpifw					\
 	dependency	"$S/contrib/dev/wpi/iwlwifi-3945-15.32.2.9.fw.uu"	\
 	compile-with	"${NORMAL_FW}"					\
 	no-obj no-implicit-rule						\
 	clean		"wpi.fw"
 dev/xe/if_xe.c			optional xe
 dev/xe/if_xe_pccard.c		optional xe pccard
 dev/xen/balloon/balloon.c	optional xen | xenhvm
 dev/xen/blkfront/blkfront.c	optional xen | xenhvm
 dev/xen/blkback/blkback.c	optional xen | xenhvm
 dev/xen/console/console.c	optional xen
 dev/xen/console/xencons_ring.c	optional xen
 dev/xen/control/control.c	optional xen | xenhvm
 dev/xen/netback/netback.c	optional xen | xenhvm
 dev/xen/netfront/netfront.c	optional xen | xenhvm
 dev/xen/xenpci/xenpci.c		optional xenpci
 dev/xen/xenpci/evtchn.c         optional xenpci
 dev/xl/if_xl.c			optional xl pci
 dev/xl/xlphy.c			optional xl pci
 fs/deadfs/dead_vnops.c		standard
 fs/devfs/devfs_devs.c		standard
 fs/devfs/devfs_dir.c		standard
 fs/devfs/devfs_rule.c		standard
 fs/devfs/devfs_vfsops.c		standard
 fs/devfs/devfs_vnops.c		standard
 fs/fdescfs/fdesc_vfsops.c	optional fdescfs
 fs/fdescfs/fdesc_vnops.c	optional fdescfs
 fs/fifofs/fifo_vnops.c		standard
 fs/fuse/fuse_device.c		optional fuse
 fs/fuse/fuse_file.c		optional fuse
 fs/fuse/fuse_internal.c		optional fuse
 fs/fuse/fuse_io.c		optional fuse
 fs/fuse/fuse_ipc.c		optional fuse
 fs/fuse/fuse_main.c		optional fuse
 fs/fuse/fuse_node.c		optional fuse
 fs/fuse/fuse_vfsops.c		optional fuse
 fs/fuse/fuse_vnops.c		optional fuse
 fs/msdosfs/msdosfs_conv.c	optional msdosfs
 fs/msdosfs/msdosfs_denode.c	optional msdosfs
 fs/msdosfs/msdosfs_fat.c	optional msdosfs
 fs/msdosfs/msdosfs_fileno.c	optional msdosfs
 fs/msdosfs/msdosfs_iconv.c	optional msdosfs_iconv
 fs/msdosfs/msdosfs_lookup.c	optional msdosfs
 fs/msdosfs/msdosfs_vfsops.c	optional msdosfs
 fs/msdosfs/msdosfs_vnops.c	optional msdosfs
 fs/nandfs/bmap.c		optional nandfs
 fs/nandfs/nandfs_alloc.c	optional nandfs
 fs/nandfs/nandfs_bmap.c		optional nandfs
 fs/nandfs/nandfs_buffer.c	optional nandfs
 fs/nandfs/nandfs_cleaner.c	optional nandfs
 fs/nandfs/nandfs_cpfile.c	optional nandfs
 fs/nandfs/nandfs_dat.c		optional nandfs
 fs/nandfs/nandfs_dir.c		optional nandfs
 fs/nandfs/nandfs_ifile.c	optional nandfs
 fs/nandfs/nandfs_segment.c	optional nandfs
 fs/nandfs/nandfs_subr.c		optional nandfs
 fs/nandfs/nandfs_sufile.c	optional nandfs
 fs/nandfs/nandfs_vfsops.c	optional nandfs
 fs/nandfs/nandfs_vnops.c	optional nandfs
 fs/nfs/nfs_commonkrpc.c		optional nfscl | nfsd
 fs/nfs/nfs_commonsubs.c		optional nfscl | nfsd
 fs/nfs/nfs_commonport.c		optional nfscl | nfsd
 fs/nfs/nfs_commonacl.c		optional nfscl | nfsd
 fs/nfsclient/nfs_clcomsubs.c	optional nfscl
 fs/nfsclient/nfs_clsubs.c	optional nfscl
 fs/nfsclient/nfs_clstate.c	optional nfscl
 fs/nfsclient/nfs_clkrpc.c	optional nfscl
 fs/nfsclient/nfs_clrpcops.c	optional nfscl
 fs/nfsclient/nfs_clvnops.c	optional nfscl
 fs/nfsclient/nfs_clnode.c	optional nfscl
 fs/nfsclient/nfs_clvfsops.c	optional nfscl
 fs/nfsclient/nfs_clport.c	optional nfscl
 fs/nfsclient/nfs_clbio.c	optional nfscl
 fs/nfsclient/nfs_clnfsiod.c	optional nfscl
 fs/nfsserver/nfs_fha_new.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdsocket.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdsubs.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdstate.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdkrpc.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdserv.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdport.c	optional nfsd inet
 fs/nfsserver/nfs_nfsdcache.c	optional nfsd inet
 fs/nullfs/null_subr.c		optional nullfs
 fs/nullfs/null_vfsops.c		optional nullfs
 fs/nullfs/null_vnops.c		optional nullfs
 fs/procfs/procfs.c		optional procfs
 fs/procfs/procfs_ctl.c		optional procfs
 fs/procfs/procfs_dbregs.c	optional procfs
 fs/procfs/procfs_fpregs.c	optional procfs
 fs/procfs/procfs_ioctl.c	optional procfs
 fs/procfs/procfs_map.c		optional procfs
 fs/procfs/procfs_mem.c		optional procfs
 fs/procfs/procfs_note.c		optional procfs
 fs/procfs/procfs_osrel.c	optional procfs
 fs/procfs/procfs_regs.c		optional procfs
 fs/procfs/procfs_rlimit.c	optional procfs
 fs/procfs/procfs_status.c	optional procfs
 fs/procfs/procfs_type.c		optional procfs
 fs/pseudofs/pseudofs.c		optional pseudofs
 fs/pseudofs/pseudofs_fileno.c	optional pseudofs
 fs/pseudofs/pseudofs_vncache.c	optional pseudofs
 fs/pseudofs/pseudofs_vnops.c	optional pseudofs
 fs/udf/osta.c			optional udf
 fs/udf/udf_iconv.c		optional udf_iconv
 fs/udf/udf_vfsops.c		optional udf
 fs/udf/udf_vnops.c		optional udf
 fs/unionfs/union_subr.c		optional unionfs
 fs/unionfs/union_vfsops.c	optional unionfs
 fs/unionfs/union_vnops.c	optional unionfs
 fs/tmpfs/tmpfs_vnops.c		optional tmpfs
 fs/tmpfs/tmpfs_fifoops.c 	optional tmpfs
 fs/tmpfs/tmpfs_vfsops.c 	optional tmpfs
 fs/tmpfs/tmpfs_subr.c 		optional tmpfs
 gdb/gdb_cons.c			optional gdb
 gdb/gdb_main.c			optional gdb
 gdb/gdb_packet.c		optional gdb
 geom/bde/g_bde.c		optional geom_bde
 geom/bde/g_bde_crypt.c		optional geom_bde
 geom/bde/g_bde_lock.c		optional geom_bde
 geom/bde/g_bde_work.c		optional geom_bde
 geom/cache/g_cache.c		optional geom_cache
 geom/concat/g_concat.c		optional geom_concat
 geom/eli/g_eli.c		optional geom_eli
 geom/eli/g_eli_crypto.c		optional geom_eli
 geom/eli/g_eli_ctl.c		optional geom_eli
 geom/eli/g_eli_integrity.c	optional geom_eli
 geom/eli/g_eli_key.c		optional geom_eli
 geom/eli/g_eli_key_cache.c	optional geom_eli
 geom/eli/g_eli_privacy.c	optional geom_eli
 geom/eli/pkcs5v2.c		optional geom_eli
 geom/gate/g_gate.c		optional geom_gate
 geom/geom_aes.c			optional geom_aes
 geom/geom_bsd.c			optional geom_bsd
 geom/geom_bsd_enc.c		optional geom_bsd
 geom/geom_ccd.c			optional ccd | geom_ccd
 geom/geom_ctl.c			standard
 geom/geom_dev.c			standard
 geom/geom_disk.c		standard
 geom/geom_dump.c		standard
 geom/geom_event.c		standard
 geom/geom_fox.c			optional geom_fox
 geom/geom_flashmap.c		optional fdt cfi | fdt nand
 geom/geom_io.c			standard
 geom/geom_kern.c		standard
 geom/geom_map.c			optional geom_map
 geom/geom_mbr.c			optional geom_mbr
 geom/geom_mbr_enc.c		optional geom_mbr
 geom/geom_pc98.c		optional geom_pc98
 geom/geom_pc98_enc.c		optional geom_pc98
 geom/geom_redboot.c		optional geom_redboot
 geom/geom_slice.c		standard
 geom/geom_subr.c		standard
 geom/geom_sunlabel.c		optional geom_sunlabel
 geom/geom_sunlabel_enc.c	optional geom_sunlabel
 geom/geom_vfs.c			standard
 geom/geom_vol_ffs.c		optional geom_vol
 geom/journal/g_journal.c	optional geom_journal
 geom/journal/g_journal_ufs.c	optional geom_journal
 geom/label/g_label.c		optional geom_label
 geom/label/g_label_ext2fs.c	optional geom_label
 geom/label/g_label_iso9660.c	optional geom_label
 geom/label/g_label_msdosfs.c	optional geom_label
 geom/label/g_label_ntfs.c	optional geom_label
 geom/label/g_label_reiserfs.c	optional geom_label
 geom/label/g_label_ufs.c	optional geom_label
 geom/label/g_label_gpt.c	optional geom_label
 geom/label/g_label_disk_ident.c	optional geom_label
 geom/linux_lvm/g_linux_lvm.c	optional geom_linux_lvm
 geom/mirror/g_mirror.c		optional geom_mirror
 geom/mirror/g_mirror_ctl.c	optional geom_mirror
 geom/mountver/g_mountver.c	optional geom_mountver
 geom/multipath/g_multipath.c	optional geom_multipath
 geom/nop/g_nop.c		optional geom_nop
 geom/part/g_part.c		standard
 geom/part/g_part_if.m		standard
 geom/part/g_part_apm.c		optional geom_part_apm
 geom/part/g_part_bsd.c		optional geom_part_bsd
 geom/part/g_part_ebr.c		optional geom_part_ebr
 geom/part/g_part_gpt.c		optional geom_part_gpt
 geom/part/g_part_ldm.c		optional geom_part_ldm
 geom/part/g_part_mbr.c		optional geom_part_mbr
 geom/part/g_part_pc98.c		optional geom_part_pc98
 geom/part/g_part_vtoc8.c	optional geom_part_vtoc8
 geom/raid/g_raid.c		optional geom_raid
 geom/raid/g_raid_ctl.c		optional geom_raid
 geom/raid/g_raid_md_if.m	optional geom_raid
 geom/raid/g_raid_tr_if.m	optional geom_raid
 geom/raid/md_ddf.c		optional geom_raid
 geom/raid/md_intel.c		optional geom_raid
 geom/raid/md_jmicron.c		optional geom_raid
 geom/raid/md_nvidia.c		optional geom_raid
 geom/raid/md_promise.c		optional geom_raid
 geom/raid/md_sii.c		optional geom_raid
 geom/raid/tr_concat.c		optional geom_raid
 geom/raid/tr_raid0.c		optional geom_raid
 geom/raid/tr_raid1.c		optional geom_raid
 geom/raid/tr_raid1e.c		optional geom_raid
 geom/raid/tr_raid5.c		optional geom_raid
 geom/raid3/g_raid3.c		optional geom_raid3
 geom/raid3/g_raid3_ctl.c	optional geom_raid3
 geom/shsec/g_shsec.c		optional geom_shsec
 geom/stripe/g_stripe.c		optional geom_stripe
 geom/uncompress/g_uncompress.c	optional geom_uncompress
 contrib/xz-embedded/freebsd/xz_malloc.c	\
 	optional xz_embedded | geom_uncompress \
 	compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/"
 contrib/xz-embedded/linux/lib/xz/xz_crc32.c \
 	optional xz_embedded | geom_uncompress \
 	compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/"
 contrib/xz-embedded/linux/lib/xz/xz_dec_bcj.c \
 	optional xz_embedded | geom_uncompress \
 	compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/"
 contrib/xz-embedded/linux/lib/xz/xz_dec_lzma2.c \
 	optional xz_embedded | geom_uncompress \
 	compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/"
 contrib/xz-embedded/linux/lib/xz/xz_dec_stream.c \
 	optional xz_embedded | geom_uncompress \
 	compile-with "${NORMAL_C} -I$S/contrib/xz-embedded/freebsd/ -I$S/contrib/xz-embedded/linux/lib/xz/ -I$S/contrib/xz-embedded/linux/include/linux/"
 geom/uzip/g_uzip.c		optional geom_uzip
 geom/virstor/binstream.c	optional geom_virstor
 geom/virstor/g_virstor.c	optional geom_virstor
 geom/virstor/g_virstor_md.c	optional geom_virstor
 geom/zero/g_zero.c		optional geom_zero
 fs/ext2fs/ext2_alloc.c		optional ext2fs
 fs/ext2fs/ext2_balloc.c		optional ext2fs
 fs/ext2fs/ext2_bmap.c		optional ext2fs
 fs/ext2fs/ext2_inode.c		optional ext2fs
 fs/ext2fs/ext2_inode_cnv.c	optional ext2fs
 fs/ext2fs/ext2_lookup.c		optional ext2fs
 fs/ext2fs/ext2_subr.c		optional ext2fs
 fs/ext2fs/ext2_vfsops.c		optional ext2fs
 fs/ext2fs/ext2_vnops.c		optional ext2fs
 gnu/fs/reiserfs/reiserfs_hashes.c	optional reiserfs \
 	warning "kernel contains GPL contaminated ReiserFS filesystem"
 gnu/fs/reiserfs/reiserfs_inode.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_item_ops.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_namei.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_prints.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_stree.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_vfsops.c	optional reiserfs
 gnu/fs/reiserfs/reiserfs_vnops.c	optional reiserfs
 #
 isa/isa_if.m			standard
 isa/isa_common.c		optional isa
 isa/isahint.c			optional isa
 isa/pnp.c			optional isa isapnp
 isa/pnpparse.c			optional isa isapnp
 fs/cd9660/cd9660_bmap.c	optional cd9660
 fs/cd9660/cd9660_lookup.c	optional cd9660
 fs/cd9660/cd9660_node.c	optional cd9660
 fs/cd9660/cd9660_rrip.c	optional cd9660
 fs/cd9660/cd9660_util.c	optional cd9660
 fs/cd9660/cd9660_vfsops.c	optional cd9660
 fs/cd9660/cd9660_vnops.c	optional cd9660
 fs/cd9660/cd9660_iconv.c	optional cd9660_iconv
 kern/bus_if.m			standard
 kern/clock_if.m			standard
 kern/cpufreq_if.m		standard
 kern/device_if.m		standard
 kern/imgact_elf.c		standard
 kern/imgact_elf32.c		optional compat_freebsd32
 kern/imgact_shell.c		standard
 kern/inflate.c			optional gzip
 kern/init_main.c		standard
 kern/init_sysent.c		standard
 kern/ksched.c			optional _kposix_priority_scheduling
 kern/kern_acct.c		standard
 kern/kern_alq.c			optional alq
 kern/kern_clock.c		standard
 kern/kern_condvar.c		standard
 kern/kern_conf.c		standard
 kern/kern_cons.c		standard
 kern/kern_cpu.c			standard
 kern/kern_cpuset.c		standard
 kern/kern_context.c		standard
 kern/kern_descrip.c		standard
 kern/kern_dtrace.c		optional kdtrace_hooks
 kern/kern_environment.c		standard
 kern/kern_et.c			standard
 kern/kern_event.c		standard
 kern/kern_exec.c		standard
 kern/kern_exit.c		standard
 kern/kern_fail.c		standard
 kern/kern_ffclock.c		standard
 kern/kern_fork.c		standard
 kern/kern_gzio.c		optional gzio
 kern/kern_hhook.c		standard
 kern/kern_idle.c		standard
 kern/kern_intr.c		standard
 kern/kern_jail.c		standard
 kern/kern_khelp.c		standard
 kern/kern_kthread.c		standard
 kern/kern_ktr.c			optional ktr
 kern/kern_ktrace.c		standard
 kern/kern_linker.c		standard
 kern/kern_lock.c		standard
 kern/kern_lockf.c		standard
 kern/kern_lockstat.c		optional kdtrace_hooks
 kern/kern_loginclass.c		standard
 kern/kern_malloc.c		standard
 kern/kern_mbuf.c		standard
 kern/kern_mib.c			standard
 kern/kern_module.c		standard
 kern/kern_mtxpool.c		standard
 kern/kern_mutex.c		standard
 kern/kern_ntptime.c		standard
 kern/kern_osd.c			standard
 kern/kern_physio.c		standard
 kern/kern_pmc.c			standard
 kern/kern_poll.c		optional device_polling
 kern/kern_priv.c		standard
 kern/kern_proc.c		standard
 kern/kern_prot.c		standard
 kern/kern_racct.c		standard
 kern/kern_rangelock.c		standard
 kern/kern_rctl.c		standard
 kern/kern_resource.c		standard
 kern/kern_rmlock.c		standard
 kern/kern_rwlock.c		standard
 kern/kern_sdt.c			optional kdtrace_hooks
 kern/kern_sema.c		standard
 kern/kern_sharedpage.c		standard
 kern/kern_shutdown.c		standard
 kern/kern_sig.c			standard
 kern/kern_switch.c		standard
 kern/kern_sx.c			standard
 kern/kern_synch.c		standard
 kern/kern_syscalls.c		standard
 kern/kern_sysctl.c		standard
 kern/kern_tc.c			standard
 kern/kern_thr.c			standard
 kern/kern_thread.c		standard
 kern/kern_time.c		standard
 kern/kern_timeout.c		standard
 kern/kern_umtx.c		standard
 kern/kern_uuid.c		standard
 kern/kern_xxx.c			standard
 kern/link_elf.c			standard
 kern/linker_if.m		standard
 kern/md5c.c			standard
 kern/p1003_1b.c			standard
 kern/posix4_mib.c		standard
 kern/sched_4bsd.c		optional sched_4bsd
 kern/sched_ule.c		optional sched_ule
 kern/serdev_if.m		standard
 kern/stack_protector.c		standard \
 	compile-with "${NORMAL_C:N-fstack-protector*}"
 kern/subr_acl_nfs4.c		optional ufs_acl | zfs
 kern/subr_acl_posix1e.c		optional ufs_acl
 kern/subr_autoconf.c		standard
 kern/subr_blist.c		standard
 kern/subr_bus.c			standard
 kern/subr_bus_dma.c		standard
 kern/subr_bufring.c		standard
 kern/subr_clock.c		standard
 kern/subr_counter.c		standard
 kern/subr_devstat.c		standard
 kern/subr_disk.c		standard
 kern/subr_eventhandler.c	standard
 kern/subr_fattime.c		standard
 kern/subr_firmware.c		optional firmware
 kern/subr_hash.c		standard
 kern/subr_hints.c		standard
 kern/subr_kdb.c			standard
 kern/subr_kobj.c		standard
 kern/subr_lock.c		standard
 kern/subr_log.c			standard
 kern/subr_mbpool.c		optional libmbpool
 kern/subr_mchain.c		optional libmchain
 kern/subr_module.c		standard
 kern/subr_msgbuf.c		standard
 kern/subr_param.c		standard
 kern/subr_pcpu.c		standard
 kern/subr_power.c		standard
 kern/subr_prf.c			standard
 kern/subr_prof.c		standard
 kern/subr_rman.c		standard
 kern/subr_rtc.c			standard
 kern/subr_sbuf.c		standard
 kern/subr_scanf.c		standard
 kern/subr_sglist.c		standard
 kern/subr_sleepqueue.c		standard
 kern/subr_smp.c			standard
 kern/subr_stack.c		optional ddb | stack | ktr
 kern/subr_taskqueue.c		standard
 kern/subr_trap.c		standard
 kern/subr_turnstile.c		standard
 kern/subr_uio.c			standard
 kern/subr_unit.c		standard
 kern/subr_witness.c		optional witness
 kern/sys_capability.c		standard
 kern/sys_generic.c		standard
 kern/sys_pipe.c			standard
 kern/sys_procdesc.c		standard
 kern/sys_process.c		standard
 kern/sys_socket.c		standard
 kern/syscalls.c			standard
 kern/sysv_ipc.c			standard
 kern/sysv_msg.c			optional sysvmsg
 kern/sysv_sem.c			optional sysvsem
 kern/sysv_shm.c			optional sysvshm
 kern/tty.c			standard
 kern/tty_compat.c		optional compat_43tty
 kern/tty_info.c			standard
 kern/tty_inq.c			standard
 kern/tty_outq.c			standard
 kern/tty_pts.c			standard
 kern/tty_tty.c			standard
 kern/tty_ttydisc.c		standard
 kern/uipc_accf.c		optional inet
 kern/uipc_cow.c			optional socket_send_cow
 kern/uipc_debug.c		optional ddb
 kern/uipc_domain.c		standard
 kern/uipc_mbuf.c		standard
 kern/uipc_mbuf2.c		standard
 kern/uipc_mqueue.c		optional p1003_1b_mqueue
 kern/uipc_sem.c			optional p1003_1b_semaphores
 kern/uipc_shm.c			standard
 kern/uipc_sockbuf.c		standard
 kern/uipc_socket.c		standard
 kern/uipc_syscalls.c		standard
 kern/uipc_usrreq.c		standard
 kern/vfs_acl.c			standard
 kern/vfs_aio.c			optional vfs_aio
 kern/vfs_bio.c			standard
 kern/vfs_cache.c		standard
 kern/vfs_cluster.c		standard
 kern/vfs_default.c		standard
 kern/vfs_export.c		standard
 kern/vfs_extattr.c		standard
 kern/vfs_hash.c			standard
 kern/vfs_init.c			standard
 kern/vfs_lookup.c		standard
 kern/vfs_mount.c		standard
 kern/vfs_mountroot.c		standard
 kern/vfs_subr.c			standard
 kern/vfs_syscalls.c		standard
 kern/vfs_vnops.c		standard
 #
 # Kernel GSS-API
 #
 gssd.h				optional kgssapi			\
 	dependency		"$S/kgssapi/gssd.x"			\
 	compile-with		"RPCGEN_CPP='${CPP}' rpcgen -hM $S/kgssapi/gssd.x | grep -v pthread.h > gssd.h" \
 	no-obj no-implicit-rule before-depend local			\
 	clean			"gssd.h"
 gssd_xdr.c			optional kgssapi			\
 	dependency		"$S/kgssapi/gssd.x gssd.h"		\
 	compile-with		"RPCGEN_CPP='${CPP}' rpcgen -c $S/kgssapi/gssd.x -o gssd_xdr.c" \
 	no-implicit-rule before-depend local				\
 	clean			"gssd_xdr.c"
 gssd_clnt.c			optional kgssapi			\
 	dependency		"$S/kgssapi/gssd.x gssd.h"		\
 	compile-with		"RPCGEN_CPP='${CPP}' rpcgen -lM $S/kgssapi/gssd.x | grep -v string.h > gssd_clnt.c" \
 	no-implicit-rule before-depend local				\
 	clean			"gssd_clnt.c"
 kgssapi/gss_accept_sec_context.c optional kgssapi
 kgssapi/gss_add_oid_set_member.c optional kgssapi
 kgssapi/gss_acquire_cred.c	optional kgssapi
 kgssapi/gss_canonicalize_name.c	optional kgssapi
 kgssapi/gss_create_empty_oid_set.c optional kgssapi
 kgssapi/gss_delete_sec_context.c optional kgssapi
 kgssapi/gss_display_status.c	optional kgssapi
 kgssapi/gss_export_name.c	optional kgssapi
 kgssapi/gss_get_mic.c		optional kgssapi
 kgssapi/gss_init_sec_context.c	optional kgssapi
 kgssapi/gss_impl.c		optional kgssapi
 kgssapi/gss_import_name.c	optional kgssapi
 kgssapi/gss_names.c		optional kgssapi
 kgssapi/gss_pname_to_uid.c	optional kgssapi
 kgssapi/gss_release_buffer.c	optional kgssapi
 kgssapi/gss_release_cred.c	optional kgssapi
 kgssapi/gss_release_name.c	optional kgssapi
 kgssapi/gss_release_oid_set.c	optional kgssapi
 kgssapi/gss_set_cred_option.c	optional kgssapi
 kgssapi/gss_test_oid_set_member.c optional kgssapi
 kgssapi/gss_unwrap.c		optional kgssapi
 kgssapi/gss_verify_mic.c	optional kgssapi
 kgssapi/gss_wrap.c		optional kgssapi
 kgssapi/gss_wrap_size_limit.c	optional kgssapi
 kgssapi/gssd_prot.c		optional kgssapi
 kgssapi/krb5/krb5_mech.c	optional kgssapi
 kgssapi/krb5/kcrypto.c		optional kgssapi
 kgssapi/krb5/kcrypto_aes.c	optional kgssapi
 kgssapi/krb5/kcrypto_arcfour.c	optional kgssapi
 kgssapi/krb5/kcrypto_des.c	optional kgssapi
 kgssapi/krb5/kcrypto_des3.c	optional kgssapi
 kgssapi/kgss_if.m		optional kgssapi
 kgssapi/gsstest.c		optional kgssapi_debug
 # These files in libkern/ are those needed by all architectures.  Some
 # of the files in libkern/ are only needed on some architectures, e.g.,
 # libkern/divdi3.c is needed by i386 but not alpha.  Also, some of these
 # routines may be optimized for a particular platform.  In either case,
 # the file should be moved to conf/files. from here.
 #
 libkern/arc4random.c		standard
 libkern/bcd.c			standard
 libkern/bsearch.c		standard
 libkern/crc32.c			standard
 libkern/fnmatch.c		standard
 libkern/iconv.c			optional libiconv
 libkern/iconv_converter_if.m	optional libiconv
 libkern/iconv_ucs.c		optional libiconv
 libkern/iconv_xlat.c		optional libiconv
 libkern/iconv_xlat16.c		optional libiconv
 libkern/inet_aton.c		standard
 libkern/inet_ntoa.c		standard
 libkern/inet_ntop.c		standard
 libkern/inet_pton.c		standard
 libkern/jenkins_hash.c		standard
 libkern/mcount.c		optional profiling-routine
 libkern/memcchr.c		standard
 libkern/memcmp.c		standard
 libkern/qsort.c			standard
 libkern/qsort_r.c		standard
 libkern/random.c		standard
 libkern/scanc.c			standard
 libkern/strcasecmp.c		standard
 libkern/strcat.c		standard
 libkern/strchr.c		standard
 libkern/strcmp.c		standard
 libkern/strcpy.c		standard
 libkern/strcspn.c		standard
 libkern/strdup.c		standard
 libkern/strlcat.c		standard
 libkern/strlcpy.c		standard
 libkern/strlen.c		standard
 libkern/strncmp.c		standard
 libkern/strncpy.c		standard
 libkern/strnlen.c		standard
 libkern/strrchr.c		standard
 libkern/strsep.c		standard
 libkern/strspn.c		standard
 libkern/strstr.c		standard
 libkern/strtol.c		standard
 libkern/strtoq.c		standard
 libkern/strtoul.c		standard
 libkern/strtouq.c		standard
 libkern/strvalid.c		standard
 net/bpf.c			standard
 net/bpf_buffer.c		optional bpf
 net/bpf_jitter.c		optional bpf_jitter
 net/bpf_filter.c		optional bpf | netgraph_bpf
 net/bpf_zerocopy.c		optional bpf
 net/bridgestp.c			optional bridge | if_bridge
 net/flowtable.c			optional flowtable inet | flowtable inet6
 net/ieee8023ad_lacp.c		optional lagg
 net/if.c			standard
 net/if_arcsubr.c		optional arcnet
 net/if_atmsubr.c		optional atm
 net/if_bridge.c			optional bridge inet | if_bridge inet
 net/if_clone.c			standard
 net/if_dead.c			standard
 net/if_debug.c			optional ddb
 net/if_disc.c			optional disc
 net/if_edsc.c			optional edsc
 net/if_ef.c			optional ef
 net/if_enc.c			optional enc ipsec inet | enc ipsec inet6
 net/if_epair.c			optional epair
 net/if_ethersubr.c		optional ether
 net/if_faith.c			optional faith
 net/if_fddisubr.c		optional fddi
 net/if_fwsubr.c			optional fwip
 net/if_gif.c			optional gif | netgraph_gif
 net/if_gre.c			optional gre inet
 net/if_iso88025subr.c		optional token
 net/if_lagg.c			optional lagg
 net/if_loop.c			optional loop
 net/if_llatbl.c			standard
 net/if_media.c			standard
 net/if_mib.c			standard
 net/if_spppfr.c			optional sppp | netgraph_sppp
 net/if_spppsubr.c		optional sppp | netgraph_sppp
 net/if_stf.c			optional stf inet inet6
 net/if_tun.c			optional tun
 net/if_tap.c			optional tap
 net/if_vlan.c			optional vlan
 net/mppcc.c			optional netgraph_mppc_compression
 net/mppcd.c			optional netgraph_mppc_compression
 net/netisr.c			standard
 net/pfil.c			optional ether | inet
 net/radix.c			standard
 net/radix_mpath.c		standard
 net/raw_cb.c			standard
 net/raw_usrreq.c		standard
 net/route.c			standard
 net/rtsock.c			standard
 net/slcompress.c		optional netgraph_vjc | sppp | \
 					 netgraph_sppp
 net/vnet.c			optional vimage
 net/zlib.c			optional crypto | geom_uzip | ipsec | \
 					 mxge | netgraph_deflate | \
 					 ddb_ctf | gzio | geom_uncompress
 net80211/ieee80211.c		optional wlan
 net80211/ieee80211_acl.c	optional wlan wlan_acl
 net80211/ieee80211_action.c	optional wlan
 net80211/ieee80211_ageq.c	optional wlan
 net80211/ieee80211_adhoc.c	optional wlan
 net80211/ieee80211_ageq.c	optional wlan
 net80211/ieee80211_amrr.c	optional wlan | wlan_amrr
 net80211/ieee80211_crypto.c	optional wlan
 net80211/ieee80211_crypto_ccmp.c optional wlan wlan_ccmp
 net80211/ieee80211_crypto_none.c optional wlan
 net80211/ieee80211_crypto_tkip.c optional wlan wlan_tkip
 net80211/ieee80211_crypto_wep.c	optional wlan wlan_wep
 net80211/ieee80211_ddb.c	optional wlan ddb
 net80211/ieee80211_dfs.c	optional wlan
 net80211/ieee80211_freebsd.c	optional wlan
 net80211/ieee80211_hostap.c	optional wlan
 net80211/ieee80211_ht.c		optional wlan
 net80211/ieee80211_hwmp.c	optional wlan ieee80211_support_mesh
 net80211/ieee80211_input.c	optional wlan
 net80211/ieee80211_ioctl.c	optional wlan
 net80211/ieee80211_mesh.c	optional wlan ieee80211_support_mesh
 net80211/ieee80211_monitor.c	optional wlan
 net80211/ieee80211_node.c	optional wlan
 net80211/ieee80211_output.c	optional wlan
 net80211/ieee80211_phy.c	optional wlan
 net80211/ieee80211_power.c	optional wlan
 net80211/ieee80211_proto.c	optional wlan
 net80211/ieee80211_radiotap.c	optional wlan
 net80211/ieee80211_ratectl.c	optional wlan
 net80211/ieee80211_ratectl_none.c optional wlan
 net80211/ieee80211_regdomain.c	optional wlan
 net80211/ieee80211_rssadapt.c	optional wlan wlan_rssadapt
 net80211/ieee80211_scan.c	optional wlan
 net80211/ieee80211_scan_sta.c	optional wlan
 net80211/ieee80211_sta.c	optional wlan
 net80211/ieee80211_superg.c	optional wlan ieee80211_support_superg
 net80211/ieee80211_tdma.c	optional wlan ieee80211_support_tdma
 net80211/ieee80211_wds.c	optional wlan
 net80211/ieee80211_xauth.c	optional wlan wlan_xauth
 net80211/ieee80211_alq.c	optional wlan ieee80211_alq
 netatalk/aarp.c			optional netatalk
 netatalk/at_control.c		optional netatalk
 netatalk/at_proto.c		optional netatalk
 netatalk/at_rmx.c		optional netatalk
 netatalk/ddp_input.c		optional netatalk
 netatalk/ddp_output.c		optional netatalk
 netatalk/ddp_pcb.c		optional netatalk
 netatalk/ddp_usrreq.c		optional netatalk
 netgraph/atm/ccatm/ng_ccatm.c	optional ngatm_ccatm \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/atm/ng_atm.c		optional ngatm_atm
 netgraph/atm/ngatmbase.c	optional ngatm_atmbase \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/atm/sscfu/ng_sscfu.c	optional ngatm_sscfu \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/atm/uni/ng_uni.c	optional ngatm_uni \
 	compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth
 netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c optional netgraph_bluetooth_bt3c
 netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4
 netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt usb
 netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c optional netgraph_bluetooth_ubtbcmfw usb
 netgraph/bluetooth/hci/ng_hci_cmds.c optional netgraph_bluetooth_hci
 netgraph/bluetooth/hci/ng_hci_evnt.c optional netgraph_bluetooth_hci
 netgraph/bluetooth/hci/ng_hci_main.c optional netgraph_bluetooth_hci
 netgraph/bluetooth/hci/ng_hci_misc.c optional netgraph_bluetooth_hci
 netgraph/bluetooth/hci/ng_hci_ulpi.c optional netgraph_bluetooth_hci
 netgraph/bluetooth/l2cap/ng_l2cap_cmds.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/l2cap/ng_l2cap_evnt.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/l2cap/ng_l2cap_llpi.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/l2cap/ng_l2cap_main.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/l2cap/ng_l2cap_misc.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/l2cap/ng_l2cap_ulpi.c optional netgraph_bluetooth_l2cap
 netgraph/bluetooth/socket/ng_btsocket.c optional netgraph_bluetooth_socket
 netgraph/bluetooth/socket/ng_btsocket_hci_raw.c	optional netgraph_bluetooth_socket
 netgraph/bluetooth/socket/ng_btsocket_l2cap.c optional netgraph_bluetooth_socket
 netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c optional netgraph_bluetooth_socket
 netgraph/bluetooth/socket/ng_btsocket_rfcomm.c optional netgraph_bluetooth_socket
 netgraph/bluetooth/socket/ng_btsocket_sco.c optional netgraph_bluetooth_socket
 netgraph/netflow/netflow.c	optional netgraph_netflow
 netgraph/netflow/netflow_v9.c	optional netgraph_netflow
 netgraph/netflow/ng_netflow.c	optional netgraph_netflow
 netgraph/ng_UI.c		optional netgraph_UI
 netgraph/ng_async.c		optional netgraph_async
 netgraph/ng_atmllc.c		optional netgraph_atmllc
 netgraph/ng_base.c		optional netgraph
 netgraph/ng_bpf.c		optional netgraph_bpf
 netgraph/ng_bridge.c		optional netgraph_bridge
 netgraph/ng_car.c		optional netgraph_car
 netgraph/ng_cisco.c		optional netgraph_cisco
 netgraph/ng_deflate.c		optional netgraph_deflate
 netgraph/ng_device.c		optional netgraph_device
 netgraph/ng_echo.c		optional netgraph_echo
 netgraph/ng_eiface.c		optional netgraph_eiface
 netgraph/ng_ether.c		optional netgraph_ether
 netgraph/ng_ether_echo.c	optional netgraph_ether_echo
 netgraph/ng_fec.c		optional netgraph_fec
 netgraph/ng_frame_relay.c	optional netgraph_frame_relay
 netgraph/ng_gif.c		optional netgraph_gif
 netgraph/ng_gif_demux.c		optional netgraph_gif_demux
 netgraph/ng_hole.c		optional netgraph_hole
 netgraph/ng_iface.c		optional netgraph_iface
 netgraph/ng_ip_input.c		optional netgraph_ip_input
 netgraph/ng_ipfw.c		optional netgraph_ipfw inet ipfirewall
 netgraph/ng_ksocket.c		optional netgraph_ksocket
 netgraph/ng_l2tp.c		optional netgraph_l2tp
 netgraph/ng_lmi.c		optional netgraph_lmi
 netgraph/ng_mppc.c		optional netgraph_mppc_compression | \
 					 netgraph_mppc_encryption
 netgraph/ng_nat.c		optional netgraph_nat inet libalias
 netgraph/ng_one2many.c		optional netgraph_one2many
 netgraph/ng_parse.c		optional netgraph
 netgraph/ng_patch.c		optional netgraph_patch
 netgraph/ng_pipe.c		optional netgraph_pipe
 netgraph/ng_ppp.c		optional netgraph_ppp
 netgraph/ng_pppoe.c		optional netgraph_pppoe
 netgraph/ng_pptpgre.c		optional netgraph_pptpgre
 netgraph/ng_pred1.c		optional netgraph_pred1
 netgraph/ng_rfc1490.c		optional netgraph_rfc1490
 netgraph/ng_socket.c		optional netgraph_socket
 netgraph/ng_split.c		optional netgraph_split
 netgraph/ng_sppp.c		optional netgraph_sppp
 netgraph/ng_tag.c		optional netgraph_tag
 netgraph/ng_tcpmss.c		optional netgraph_tcpmss
 netgraph/ng_tee.c		optional netgraph_tee
 netgraph/ng_tty.c		optional netgraph_tty
 netgraph/ng_vjc.c		optional netgraph_vjc
 netgraph/ng_vlan.c		optional netgraph_vlan
 netinet/accf_data.c		optional accept_filter_data inet
 netinet/accf_dns.c		optional accept_filter_dns inet
 netinet/accf_http.c		optional accept_filter_http inet
 netinet/if_atm.c		optional atm
 netinet/if_ether.c		optional inet ether
 netinet/igmp.c			optional inet
 netinet/in.c			optional inet
 netinet/in_debug.c		optional inet ddb
 netinet/ip_carp.c		optional inet carp | inet6 carp
 netinet/in_gif.c		optional gif inet | netgraph_gif inet
 netinet/ip_gre.c		optional gre inet
 netinet/ip_id.c			optional inet
 netinet/in_mcast.c		optional inet
 netinet/in_pcb.c		optional inet | inet6
 netinet/in_pcbgroup.c		optional inet pcbgroup | inet6 pcbgroup
 netinet/in_proto.c		optional inet | inet6
 netinet/in_rmx.c		optional inet
 netinet/ip_divert.c		optional inet ipdivert ipfirewall
 netinet/ip_ecn.c		optional inet | inet6
 netinet/ip_encap.c		optional inet | inet6
 netinet/ip_fastfwd.c		optional inet
 netinet/ip_icmp.c		optional inet | inet6
 netinet/ip_input.c		optional inet
 netinet/ip_ipsec.c		optional inet ipsec
 netinet/ip_mroute.c		optional mrouting inet
 netinet/ip_options.c		optional inet
 netinet/ip_output.c		optional inet
 netinet/raw_ip.c		optional inet | inet6
 netinet/cc/cc.c			optional inet | inet6
 netinet/cc/cc_newreno.c		optional inet | inet6
 netinet/sctp_asconf.c		optional inet sctp | inet6 sctp
 netinet/sctp_auth.c		optional inet sctp | inet6 sctp
 netinet/sctp_bsd_addr.c		optional inet sctp | inet6 sctp
 netinet/sctp_cc_functions.c	optional inet sctp | inet6 sctp
 netinet/sctp_crc32.c		optional inet sctp | inet6 sctp
 netinet/sctp_indata.c		optional inet sctp | inet6 sctp
 netinet/sctp_input.c		optional inet sctp | inet6 sctp
 netinet/sctp_output.c		optional inet sctp | inet6 sctp
 netinet/sctp_pcb.c		optional inet sctp | inet6 sctp
 netinet/sctp_peeloff.c		optional inet sctp | inet6 sctp
 netinet/sctp_ss_functions.c	optional inet sctp | inet6 sctp
 netinet/sctp_sysctl.c		optional inet sctp | inet6 sctp
 netinet/sctp_timer.c		optional inet sctp | inet6 sctp
 netinet/sctp_usrreq.c		optional inet sctp | inet6 sctp
 netinet/sctputil.c		optional inet sctp | inet6 sctp
 netinet/tcp_debug.c		optional tcpdebug
 netinet/tcp_hostcache.c		optional inet | inet6
 netinet/tcp_input.c		optional inet | inet6
 netinet/tcp_lro.c		optional inet | inet6
 netinet/tcp_output.c		optional inet | inet6
 netinet/tcp_offload.c		optional tcp_offload inet | tcp_offload inet6
 netinet/tcp_reass.c		optional inet | inet6
 netinet/tcp_sack.c		optional inet | inet6
 netinet/tcp_subr.c		optional inet | inet6
 netinet/tcp_syncache.c		optional inet | inet6
 netinet/tcp_timer.c		optional inet | inet6
 netinet/tcp_timewait.c		optional inet | inet6
 netinet/tcp_usrreq.c		optional inet | inet6
 netinet/udp_usrreq.c		optional inet | inet6
 netinet/libalias/alias.c	optional libalias inet | netgraph_nat inet
 netinet/libalias/alias_db.c	optional libalias inet | netgraph_nat inet
 netinet/libalias/alias_mod.c	optional libalias | netgraph_nat
 netinet/libalias/alias_proxy.c	optional libalias inet | netgraph_nat inet
 netinet/libalias/alias_util.c	optional libalias inet | netgraph_nat inet
 netinet/libalias/alias_sctp.c	optional libalias inet | netgraph_nat inet
 netinet6/dest6.c		optional inet6
 netinet6/frag6.c		optional inet6
 netinet6/icmp6.c		optional inet6
 netinet6/in6.c			optional inet6
 netinet6/in6_cksum.c		optional inet6
 netinet6/in6_gif.c		optional gif inet6 | netgraph_gif inet6
 netinet6/in6_ifattach.c		optional inet6
 netinet6/in6_mcast.c		optional inet6
 netinet6/in6_pcb.c		optional inet6
 netinet6/in6_pcbgroup.c		optional inet6 pcbgroup
 netinet6/in6_proto.c		optional inet6
 netinet6/in6_rmx.c		optional inet6
 netinet6/in6_src.c		optional inet6
 netinet6/ip6_forward.c		optional inet6
 netinet6/ip6_id.c		optional inet6
 netinet6/ip6_input.c		optional inet6
 netinet6/ip6_mroute.c		optional mrouting inet6
 netinet6/ip6_output.c		optional inet6
 netinet6/ip6_ipsec.c		optional inet6 ipsec
 netinet6/mld6.c			optional inet6
 netinet6/nd6.c			optional inet6
 netinet6/nd6_nbr.c		optional inet6
 netinet6/nd6_rtr.c		optional inet6
 netinet6/raw_ip6.c		optional inet6
 netinet6/route6.c		optional inet6
 netinet6/scope6.c		optional inet6
 netinet6/sctp6_usrreq.c		optional inet6 sctp
 netinet6/udp6_usrreq.c		optional inet6
 netipsec/ipsec.c		optional ipsec inet | ipsec inet6
 netipsec/ipsec_input.c		optional ipsec inet | ipsec inet6
 netipsec/ipsec_mbuf.c		optional ipsec inet | ipsec inet6
 netipsec/ipsec_output.c		optional ipsec inet | ipsec inet6
 netipsec/key.c			optional ipsec inet | ipsec inet6
 netipsec/key_debug.c		optional ipsec inet | ipsec inet6
 netipsec/keysock.c		optional ipsec inet | ipsec inet6
 netipsec/xform_ah.c		optional ipsec inet | ipsec inet6
 netipsec/xform_esp.c		optional ipsec inet | ipsec inet6
 netipsec/xform_ipcomp.c		optional ipsec inet | ipsec inet6
 netipsec/xform_ipip.c		optional ipsec inet | ipsec inet6
 netipsec/xform_tcp.c		optional ipsec inet tcp_signature | \
 					 ipsec inet6 tcp_signature
 netipx/ipx.c			optional ipx
 netipx/ipx_cksum.c		optional ipx
 netipx/ipx_input.c		optional ipx
 netipx/ipx_outputfl.c		optional ipx
 netipx/ipx_pcb.c		optional ipx
 netipx/ipx_proto.c		optional ipx
 netipx/ipx_usrreq.c		optional ipx
 netipx/spx_debug.c		optional ipx
 netipx/spx_reass.c		optional ipx
 netipx/spx_usrreq.c		optional ipx
 netnatm/natm.c			optional natm
 netnatm/natm_pcb.c		optional natm
 netnatm/natm_proto.c		optional natm
 netpfil/ipfw/dn_heap.c		optional inet dummynet
 netpfil/ipfw/dn_sched_fifo.c	optional inet dummynet
 netpfil/ipfw/dn_sched_prio.c	optional inet dummynet
 netpfil/ipfw/dn_sched_qfq.c	optional inet dummynet
 netpfil/ipfw/dn_sched_rr.c	optional inet dummynet
 netpfil/ipfw/dn_sched_wf2q.c	optional inet dummynet
 netpfil/ipfw/ip_dummynet.c	optional inet dummynet
 netpfil/ipfw/ip_dn_io.c		optional inet dummynet
 netpfil/ipfw/ip_dn_glue.c	optional inet dummynet
 netpfil/ipfw/ip_fw2.c		optional inet ipfirewall
 netpfil/ipfw/ip_fw_dynamic.c	optional inet ipfirewall
 netpfil/ipfw/ip_fw_log.c	optional inet ipfirewall
 netpfil/ipfw/ip_fw_pfil.c	optional inet ipfirewall
 netpfil/ipfw/ip_fw_sockopt.c	optional inet ipfirewall
 netpfil/ipfw/ip_fw_table.c	optional inet ipfirewall
 netpfil/ipfw/ip_fw_nat.c	optional inet ipfirewall_nat
 netpfil/pf/if_pflog.c		optional pflog pf inet
 netpfil/pf/if_pfsync.c		optional pfsync pf inet
 netpfil/pf/pf.c			optional pf inet
 netpfil/pf/pf_if.c		optional pf inet
 netpfil/pf/pf_ioctl.c		optional pf inet
 netpfil/pf/pf_lb.c		optional pf inet
 netpfil/pf/pf_norm.c		optional pf inet
 netpfil/pf/pf_osfp.c		optional pf inet
 netpfil/pf/pf_ruleset.c		optional pf inet
 netpfil/pf/pf_table.c		optional pf inet
 netpfil/pf/in4_cksum.c		optional pf inet
 nfs/bootp_subr.c		optional bootp nfsclient | bootp nfscl
 nfs/krpc_subr.c			optional bootp nfsclient | bootp nfscl
 nfs/nfs_common.c		optional nfsclient | nfsserver
 nfs/nfs_diskless.c		optional nfsclient nfs_root | nfscl nfs_root
 nfs/nfs_fha.c			optional nfsserver | nfsd
 nfs/nfs_lock.c			optional nfsclient | nfscl | nfslockd | nfsd
 nfsclient/nfs_bio.c		optional nfsclient
 nfsclient/nfs_node.c		optional nfsclient
 nfsclient/nfs_krpc.c		optional nfsclient
 nfsclient/nfs_subs.c		optional nfsclient
 nfsclient/nfs_nfsiod.c		optional nfsclient
 nfsclient/nfs_vfsops.c		optional nfsclient
 nfsclient/nfs_vnops.c		optional nfsclient
 nfsserver/nfs_fha_old.c		optional nfsserver
 nfsserver/nfs_serv.c		optional nfsserver
 nfsserver/nfs_srvkrpc.c		optional nfsserver
 nfsserver/nfs_srvsubs.c		optional nfsserver
 nfs/nfs_nfssvc.c		optional nfsserver | nfscl | nfsd
 nlm/nlm_advlock.c		optional nfslockd | nfsd
 nlm/nlm_prot_clnt.c		optional nfslockd | nfsd
 nlm/nlm_prot_impl.c		optional nfslockd | nfsd
 nlm/nlm_prot_server.c		optional nfslockd | nfsd
 nlm/nlm_prot_svc.c		optional nfslockd | nfsd
 nlm/nlm_prot_xdr.c		optional nfslockd | nfsd
 nlm/sm_inter_xdr.c		optional nfslockd | nfsd
 
 # OpenFabrics Enterprise Distribution (Infiniband)
 ofed/include/linux/linux_compat.c		optional ofed		\
 	no-depend compile-with "${OFED_C}"
 ofed/include/linux/linux_idr.c			optional ofed		\
 	no-depend compile-with "${OFED_C}"
 ofed/include/linux/linux_radix.c		optional ofed		\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/core/addr.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/agent.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/cache.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 # XXX Mad.c must be ordered before cm.c for sysinit sets to occur in
 # the correct order.
 ofed/drivers/infiniband/core/mad.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/cm.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/cma.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/device.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/fmr_pool.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/iwcm.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/local_sa.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/mad_rmpp.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/multicast.c	optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/notice.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/packer.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/sa_query.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/smi.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/sysfs.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/ucm.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/ucma.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/ud_header.c	optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/umem.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/user_mad.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/uverbs_cmd.c	optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/uverbs_main.c	optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/uverbs_marshall.c	optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 ofed/drivers/infiniband/core/verbs.c		optional ofed		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
 
 ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	optional ipoib		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 #ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c	optional ipoib		\
 #	no-depend							\
 #	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c	optional ipoib		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	optional ipoib		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	optional ipoib	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c	optional ipoib		\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 #ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c	optional ipoib		\
 #	no-depend							\
 #	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
 
 ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c	optional sdp inet	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
 ofed/drivers/infiniband/ulp/sdp/sdp_main.c	optional sdp inet 	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
 ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	optional sdp inet 	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
 ofed/drivers/infiniband/ulp/sdp/sdp_cma.c	optional sdp inet 	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
 ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	optional sdp inet 	\
 	no-depend							\
 	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
 
 ofed/drivers/infiniband/hw/mlx4/ah.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/cq.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/doorbell.c	optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/mad.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/main.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/mr.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/qp.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/srq.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 ofed/drivers/infiniband/hw/mlx4/wc.c		optional mlx4ib		\
 	no-depend obj-prefix "mlx4ib_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
 
 ofed/drivers/net/mlx4/alloc.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/catas.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/cmd.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/cq.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/eq.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/fw.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/icm.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/intf.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/main.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/mcg.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/mr.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/pd.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/port.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/profile.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/qp.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/reset.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/sense.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/srq.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/xrcd.c			optional mlx4ib | mlxen	\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 
 ofed/drivers/net/mlx4/en_cq.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_frag.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_main.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_netdev.c		optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_port.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_resources.c		optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_rx.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 ofed/drivers/net/mlx4/en_tx.c			optional mlxen		\
 	no-depend obj-prefix "mlx4_"					\
 	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
 
 ofed/drivers/infiniband/hw/mthca/mthca_allocator.c	optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_av.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_catas.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_cmd.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_cq.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_eq.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_mad.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_main.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_mcg.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_memfree.c	optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_mr.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_pd.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_profile.c	optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_provider.c	optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_qp.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_reset.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_srq.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 ofed/drivers/infiniband/hw/mthca/mthca_uar.c		optional mthca	\
 	no-depend compile-with "${OFED_C}"
 
 # crypto support
 opencrypto/cast.c		optional crypto | ipsec
 opencrypto/criov.c		optional crypto
 opencrypto/crypto.c		optional crypto
 opencrypto/cryptodev.c		optional cryptodev
 opencrypto/cryptodev_if.m	optional crypto
 opencrypto/cryptosoft.c		optional crypto
 opencrypto/deflate.c		optional crypto
 opencrypto/rmd160.c		optional crypto | ipsec
 opencrypto/skipjack.c		optional crypto
 opencrypto/xform.c		optional crypto
 pci/alpm.c			optional alpm pci
 pci/amdpm.c			optional amdpm pci | nfpm pci
 pci/amdsmb.c			optional amdsmb pci
 pci/if_rl.c			optional rl pci
 pci/intpm.c			optional intpm pci
 pci/ncr.c			optional ncr pci
 pci/nfsmb.c			optional nfsmb pci
 pci/viapm.c			optional viapm pci
 rpc/auth_none.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/auth_unix.c			optional krpc | nfslockd | nfsclient | nfscl | nfsd
 rpc/authunix_prot.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/clnt_dg.c			optional krpc | nfslockd | nfsclient | nfscl | nfsd
 rpc/clnt_rc.c			optional krpc | nfslockd | nfsclient | nfscl | nfsd
 rpc/clnt_vc.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/getnetconfig.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/replay.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpc_callmsg.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpc_generic.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpc_prot.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpcb_clnt.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/rpcb_prot.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/svc.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/svc_auth.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/svc_auth_unix.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 rpc/svc_dg.c			optional krpc | nfslockd | nfsserver | nfscl | nfsd
 rpc/svc_generic.c		optional krpc | nfslockd | nfsserver | nfscl | nfsd
 rpc/svc_vc.c			optional krpc | nfslockd | nfsserver | nfscl | nfsd
 rpc/rpcsec_gss/rpcsec_gss.c	optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi
 rpc/rpcsec_gss/rpcsec_gss_conf.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi
 rpc/rpcsec_gss/rpcsec_gss_misc.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi
 rpc/rpcsec_gss/rpcsec_gss_prot.c optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi
 rpc/rpcsec_gss/svc_rpcsec_gss.c	optional krpc kgssapi | nfslockd kgssapi | nfscl kgssapi | nfsd kgssapi
 security/audit/audit.c		optional audit
 security/audit/audit_arg.c	optional audit
 security/audit/audit_bsm.c	optional audit
 security/audit/audit_bsm_klib.c	optional audit
 security/audit/audit_pipe.c	optional audit
 security/audit/audit_syscalls.c	standard
 security/audit/audit_trigger.c	optional audit
 security/audit/audit_worker.c	optional audit
 security/audit/bsm_domain.c	optional audit
 security/audit/bsm_errno.c	optional audit
 security/audit/bsm_fcntl.c	optional audit
 security/audit/bsm_socket_type.c	optional audit
 security/audit/bsm_token.c	optional audit
 security/mac/mac_atalk.c	optional mac netatalk
 security/mac/mac_audit.c	optional mac audit
 security/mac/mac_cred.c		optional mac
 security/mac/mac_framework.c	optional mac
 security/mac/mac_inet.c		optional mac inet | mac inet6
 security/mac/mac_inet6.c	optional mac inet6
 security/mac/mac_label.c	optional mac
 security/mac/mac_net.c		optional mac
 security/mac/mac_pipe.c		optional mac
 security/mac/mac_posix_sem.c	optional mac
 security/mac/mac_posix_shm.c	optional mac
 security/mac/mac_priv.c		optional mac
 security/mac/mac_process.c	optional mac
 security/mac/mac_socket.c	optional mac
 security/mac/mac_syscalls.c	standard
 security/mac/mac_system.c	optional mac
 security/mac/mac_sysv_msg.c	optional mac
 security/mac/mac_sysv_sem.c	optional mac
 security/mac/mac_sysv_shm.c	optional mac
 security/mac/mac_vfs.c		optional mac
 security/mac_biba/mac_biba.c	optional mac_biba
 security/mac_bsdextended/mac_bsdextended.c	optional mac_bsdextended
 security/mac_bsdextended/ugidfw_system.c	optional mac_bsdextended
 security/mac_bsdextended/ugidfw_vnode.c		optional mac_bsdextended
 security/mac_ifoff/mac_ifoff.c	optional mac_ifoff
 security/mac_lomac/mac_lomac.c	optional mac_lomac
 security/mac_mls/mac_mls.c	optional mac_mls
 security/mac_none/mac_none.c	optional mac_none
 security/mac_partition/mac_partition.c optional mac_partition
 security/mac_portacl/mac_portacl.c optional mac_portacl
 security/mac_seeotheruids/mac_seeotheruids.c optional mac_seeotheruids
 security/mac_stub/mac_stub.c	optional mac_stub
 security/mac_test/mac_test.c	optional mac_test
 teken/teken.c			optional sc
 ufs/ffs/ffs_alloc.c		optional ffs
 ufs/ffs/ffs_balloc.c		optional ffs
 ufs/ffs/ffs_inode.c		optional ffs
 ufs/ffs/ffs_snapshot.c		optional ffs
 ufs/ffs/ffs_softdep.c		optional ffs
 ufs/ffs/ffs_subr.c		optional ffs
 ufs/ffs/ffs_tables.c		optional ffs
 ufs/ffs/ffs_vfsops.c		optional ffs
 ufs/ffs/ffs_vnops.c		optional ffs
 ufs/ffs/ffs_rawread.c		optional directio
 ufs/ffs/ffs_suspend.c		optional ffs
 ufs/ufs/ufs_acl.c		optional ffs
 ufs/ufs/ufs_bmap.c		optional ffs
 ufs/ufs/ufs_dirhash.c		optional ffs
 ufs/ufs/ufs_extattr.c		optional ffs
 ufs/ufs/ufs_gjournal.c		optional ffs UFS_GJOURNAL
 ufs/ufs/ufs_inode.c		optional ffs
 ufs/ufs/ufs_lookup.c		optional ffs
 ufs/ufs/ufs_quota.c		optional ffs
 ufs/ufs/ufs_vfsops.c		optional ffs
 ufs/ufs/ufs_vnops.c		optional ffs
 vm/default_pager.c		standard
 vm/device_pager.c		standard
 vm/phys_pager.c			standard
 vm/redzone.c			optional DEBUG_REDZONE
 vm/sg_pager.c			standard
 vm/swap_pager.c			standard
 vm/uma_core.c			standard
 vm/uma_dbg.c			standard
 vm/memguard.c			optional DEBUG_MEMGUARD
 vm/vm_fault.c			standard
 vm/vm_glue.c			standard
 vm/vm_init.c			standard
 vm/vm_kern.c			standard
 vm/vm_map.c			standard
 vm/vm_meter.c			standard
 vm/vm_mmap.c			standard
 vm/vm_object.c			standard
 vm/vm_page.c			standard
 vm/vm_pageout.c			standard
 vm/vm_pager.c			standard
 vm/vm_phys.c			standard
 vm/vm_radix.c			standard
 vm/vm_reserv.c			standard
 vm/vm_unix.c			standard
 vm/vm_zeroidle.c		standard
 vm/vnode_pager.c		standard
 xen/gnttab.c			optional xen | xenhvm
 xen/features.c			optional xen | xenhvm
 xen/evtchn/evtchn.c		optional xen
 xen/evtchn/evtchn_dev.c		optional xen | xenhvm
 xen/xenbus/xenbus_if.m		optional xen | xenhvm
 xen/xenbus/xenbus.c		optional xen | xenhvm
 xen/xenbus/xenbusb_if.m		optional xen | xenhvm
 xen/xenbus/xenbusb.c		optional xen | xenhvm
 xen/xenbus/xenbusb_front.c	optional xen | xenhvm
 xen/xenbus/xenbusb_back.c	optional xen | xenhvm
 xen/xenstore/xenstore.c		optional xen | xenhvm
 xen/xenstore/xenstore_dev.c	optional xen | xenhvm
 xdr/xdr.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 xdr/xdr_array.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 xdr/xdr_mbuf.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 xdr/xdr_mem.c			optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 xdr/xdr_reference.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
 xdr/xdr_sizeof.c		optional krpc | nfslockd | nfsclient | nfsserver | nfscl | nfsd
Index: user/attilio/vmcontention/sys/conf/options
===================================================================
--- user/attilio/vmcontention/sys/conf/options	(revision 249698)
+++ user/attilio/vmcontention/sys/conf/options	(revision 249699)
@@ -1,895 +1,896 @@
 # $FreeBSD$
 #
 #        On the handling of kernel options
 #
 # All kernel options should be listed in NOTES, with suitable
 # descriptions.  Negative options (options that make some code not
 # compile) should be commented out; LINT (generated from NOTES) should
 # compile as much code as possible.  Try to structure option-using
 # code so that a single option only switch code on, or only switch
 # code off, to make it possible to have a full compile-test.  If
 # necessary, you can check for COMPILING_LINT to get maximum code
 # coverage.
 #
 # All new options shall also be listed in either "conf/options" or
 # "conf/options.".  Options that affect a single source-file
 # .[c|s] should be directed into "opt_.h", while options
 # that affect multiple files should either go in "opt_global.h" if
 # this is a kernel-wide option (used just about everywhere), or in
 # "opt_.h" if it affects only some files.
 # Note that the effect of listing only an option without a
 # header-file-name in conf/options (and cousins) is that the last
 # convention is followed.
 #
 # This handling scheme is not yet fully implemented.
 #
 #
 # Format of this file:
 # Option name	filename
 #
 # If filename is missing, the default is
 # opt_.h
 
 AAC_DEBUG		opt_aac.h
 AHC_ALLOW_MEMIO		opt_aic7xxx.h
 AHC_TMODE_ENABLE	opt_aic7xxx.h
 AHC_DUMP_EEPROM		opt_aic7xxx.h
 AHC_DEBUG		opt_aic7xxx.h
 AHC_DEBUG_OPTS		opt_aic7xxx.h
 AHC_REG_PRETTY_PRINT	opt_aic7xxx.h
 AHD_DEBUG		opt_aic79xx.h
 AHD_DEBUG_OPTS		opt_aic79xx.h
 AHD_TMODE_ENABLE	opt_aic79xx.h	
 AHD_REG_PRETTY_PRINT	opt_aic79xx.h
 ADW_ALLOW_MEMIO		opt_adw.h
 
 TWA_DEBUG		opt_twa.h
 TWA_FLASH_FIRMWARE	opt_twa.h
 
 # Debugging options.
 ALT_BREAK_TO_DEBUGGER	opt_kdb.h
 BREAK_TO_DEBUGGER	opt_kdb.h
 DDB
 DDB_BUFR_SIZE	opt_ddb.h
 DDB_CAPTURE_DEFAULTBUFSIZE	opt_ddb.h
 DDB_CAPTURE_MAXBUFSIZE	opt_ddb.h
 DDB_CTF		opt_ddb.h
 DDB_NUMSYM	opt_ddb.h
 GDB
 KDB		opt_global.h
 KDB_TRACE	opt_kdb.h
 KDB_UNATTENDED	opt_kdb.h
 KLD_DEBUG	opt_kld.h
 SYSCTL_DEBUG	opt_sysctl.h
 TEXTDUMP_PREFERRED	opt_ddb.h
 TEXTDUMP_VERBOSE	opt_ddb.h
 
 # Miscellaneous options.
 ADAPTIVE_LOCKMGRS
 ALQ
 AUDIT		opt_global.h
 BOOTHOWTO	opt_global.h
 BOOTVERBOSE	opt_global.h
 CALLOUT_PROFILING
 CAPABILITIES	opt_capsicum.h
 CAPABILITY_MODE	opt_capsicum.h
 COMPAT_43	opt_compat.h
 COMPAT_43TTY	opt_compat.h
 COMPAT_FREEBSD4	opt_compat.h
 COMPAT_FREEBSD5	opt_compat.h
 COMPAT_FREEBSD6	opt_compat.h
 COMPAT_FREEBSD7	opt_compat.h
 COMPILING_LINT	opt_global.h
 COMPRESS_USER_CORES opt_core.h
 CY_PCI_FASTINTR
 DEADLKRES	opt_watchdog.h
 DIRECTIO
 FFCLOCK
 FULL_PREEMPTION	opt_sched.h
 IPI_PREEMPTION	opt_sched.h
 GEOM_AES	opt_geom.h
 GEOM_BDE	opt_geom.h
 GEOM_BSD	opt_geom.h
 GEOM_CACHE	opt_geom.h
 GEOM_CONCAT	opt_geom.h
 GEOM_ELI	opt_geom.h
 GEOM_FOX	opt_geom.h
 GEOM_GATE	opt_geom.h
 GEOM_JOURNAL	opt_geom.h
 GEOM_LABEL	opt_geom.h
 GEOM_LINUX_LVM	opt_geom.h
 GEOM_MBR	opt_geom.h
 GEOM_MIRROR	opt_geom.h
 GEOM_MULTIPATH	opt_geom.h
 GEOM_NOP	opt_geom.h
 GEOM_PART_APM	opt_geom.h
 GEOM_PART_BSD	opt_geom.h
 GEOM_PART_EBR	opt_geom.h
 GEOM_PART_EBR_COMPAT	opt_geom.h
 GEOM_PART_GPT	opt_geom.h
 GEOM_PART_LDM	opt_geom.h
 GEOM_PART_MBR	opt_geom.h
 GEOM_PART_PC98	opt_geom.h
 GEOM_PART_VTOC8	opt_geom.h
 GEOM_PC98	opt_geom.h
 GEOM_RAID	opt_geom.h
 GEOM_RAID3	opt_geom.h
 GEOM_SHSEC	opt_geom.h
 GEOM_STRIPE	opt_geom.h
 GEOM_SUNLABEL	opt_geom.h
 GEOM_UNCOMPRESS	opt_geom.h
 GEOM_UZIP	opt_geom.h
 GEOM_VIRSTOR	opt_geom.h
 GEOM_VOL	opt_geom.h
 GEOM_ZERO	opt_geom.h
 KDTRACE_HOOKS	opt_kdtrace.h
 KSTACK_MAX_PAGES
 KSTACK_PAGES
 KTRACE
 KTRACE_REQUEST_POOL	opt_ktrace.h
 LIBICONV
 MAC		opt_global.h
 MAC_BIBA	opt_dontuse.h
 MAC_BSDEXTENDED	opt_dontuse.h
 MAC_IFOFF	opt_dontuse.h
 MAC_LOMAC	opt_dontuse.h
 MAC_MLS		opt_dontuse.h
 MAC_NONE	opt_dontuse.h
 MAC_PARTITION	opt_dontuse.h
 MAC_PORTACL	opt_dontuse.h
 MAC_SEEOTHERUIDS	opt_dontuse.h
 MAC_STATIC	opt_mac.h
 MAC_STUB	opt_dontuse.h
 MAC_TEST	opt_dontuse.h
 MD_ROOT		opt_md.h
 MD_ROOT_FSTYPE	opt_md.h
 MD_ROOT_SIZE	opt_md.h
 MFI_DEBUG	opt_mfi.h
 MFI_DECODE_LOG	opt_mfi.h
 MPROF_BUFFERS	opt_mprof.h
 MPROF_HASH_SIZE	opt_mprof.h
 NEW_PCIB	opt_global.h
 NO_ADAPTIVE_MUTEXES	opt_adaptive_mutexes.h
 NO_ADAPTIVE_RWLOCKS
 NO_ADAPTIVE_SX
 NO_SYSCTL_DESCR	opt_global.h
 NSWBUF_MIN	opt_swap.h
 MBUF_PACKET_ZONE_DISABLE	opt_global.h
 PANIC_REBOOT_WAIT_TIME	opt_panic.h
 PPC_DEBUG	opt_ppc.h
 PPC_PROBE_CHIPSET	opt_ppc.h
 PPS_SYNC	opt_ntp.h
 PREEMPTION	opt_sched.h
 PROCDESC	opt_procdesc.h
 QUOTA
 SCHED_4BSD	opt_sched.h
 SCHED_STATS	opt_sched.h
 SCHED_ULE	opt_sched.h
 SLEEPQUEUE_PROFILING
 SLHCI_DEBUG	opt_slhci.h
 SPX_HACK
 STACK		opt_stack.h
 SUIDDIR
 MSGMNB		opt_sysvipc.h
 MSGMNI		opt_sysvipc.h
 MSGSEG		opt_sysvipc.h
 MSGSSZ		opt_sysvipc.h
 MSGTQL		opt_sysvipc.h
 SEMMNI		opt_sysvipc.h
 SEMMNS		opt_sysvipc.h
 SEMMNU		opt_sysvipc.h
 SEMMSL		opt_sysvipc.h
 SEMOPM		opt_sysvipc.h
 SEMUME		opt_sysvipc.h
 SHMALL		opt_sysvipc.h
 SHMMAX		opt_sysvipc.h
 SHMMAXPGS	opt_sysvipc.h
 SHMMIN		opt_sysvipc.h
 SHMMNI		opt_sysvipc.h
 SHMSEG		opt_sysvipc.h
 SYSVMSG		opt_sysvipc.h
 SYSVSEM		opt_sysvipc.h
 SYSVSHM		opt_sysvipc.h
 SW_WATCHDOG	opt_watchdog.h
 TURNSTILE_PROFILING
 UMTX_PROFILING
 VFS_AIO
 VERBOSE_SYSINIT	opt_global.h
 WLCACHE		opt_wavelan.h
 WLDEBUG		opt_wavelan.h
 
 # POSIX kernel options
 P1003_1B_MQUEUE			opt_posix.h
 P1003_1B_SEMAPHORES		opt_posix.h
 _KPOSIX_PRIORITY_SCHEDULING	opt_posix.h
 
 # Do we want the config file compiled into the kernel?
 INCLUDE_CONFIG_FILE	opt_config.h
 
 # Options for static filesystems.  These should only be used at config
 # time, since the corresponding lkms cannot work if there are any static
 # dependencies.  Unusability is enforced by hiding the defines for the
 # options in a never-included header.
 CD9660		opt_dontuse.h
 EXT2FS		opt_dontuse.h
 FDESCFS		opt_dontuse.h
 FFS		opt_dontuse.h
 FUSE		opt_dontuse.h
 MSDOSFS		opt_dontuse.h
 NANDFS		opt_dontuse.h
 NULLFS		opt_dontuse.h
 PROCFS		opt_dontuse.h
 PSEUDOFS	opt_dontuse.h
 REISERFS	opt_dontuse.h
 TMPFS		opt_dontuse.h
 UDF		opt_dontuse.h
 UNIONFS		opt_dontuse.h
 
 # Pseudofs debugging
 PSEUDOFS_TRACE	opt_pseudofs.h
 
 # In-kernel GSS-API
 KGSSAPI		opt_kgssapi.h
 KGSSAPI_DEBUG	opt_kgssapi.h
 
 # These static filesystems have one slightly bogus static dependency in
 # sys/i386/i386/autoconf.c.  If any of these filesystems are
 # statically compiled into the kernel, code for mounting them as root
 # filesystems will be enabled - but look below.
 NFSCLIENT	opt_nfs.h
 NFSSERVER	opt_nfs.h
 
 # Use these options to compile the experimental nfs client and/or
 # server that supports NFSv4 into a kernel.
 # NFSCL - client
 # NFSD - server
 NFSCL		opt_nfs.h
 NFSD		opt_nfs.h
 
 # filesystems and libiconv bridge
 CD9660_ICONV	opt_dontuse.h
 MSDOSFS_ICONV	opt_dontuse.h
 UDF_ICONV	opt_dontuse.h
 
 # If you are following the conditions in the copyright,
 # you can enable soft-updates which will speed up a lot of thigs
 # and make the system safer from crashes at the same time.
 # otherwise a STUB module will be compiled in.
 SOFTUPDATES	opt_ffs.h
 
 # On small, embedded systems, it can be useful to turn off support for
 # snapshots.  It saves about 30-40k for a feature that would be lightly
 # used, if it is used at all.
 NO_FFS_SNAPSHOT	opt_ffs.h
 
 # Enabling this option turns on support for Access Control Lists in UFS,
 # which can be used to support high security configurations.  Depends on
 # UFS_EXTATTR.
 UFS_ACL		opt_ufs.h
 
 # Enabling this option turns on support for extended attributes in UFS-based
 # filesystems, which can be used to support high security configurations
 # as well as new filesystem features.
 UFS_EXTATTR	opt_ufs.h
 UFS_EXTATTR_AUTOSTART	opt_ufs.h
 
 # Enable fast hash lookups for large directories on UFS-based filesystems.
 UFS_DIRHASH	opt_ufs.h
 
 # Enable gjournal-based UFS journal.
 UFS_GJOURNAL	opt_ufs.h
 
 # The below sentence is not in English, and neither is this one.
 # We plan to remove the static dependences above, with a
 # _ROOT option to control if it usable as root.  This list
 # allows these options to be present in config files already (though
 # they won't make any difference yet).
 NFS_ROOT	opt_nfsroot.h
 
 # Options used only in subr_param.c.
 HZ		opt_param.h
 MAXFILES	opt_param.h
 NBUF		opt_param.h
 NSFBUFS		opt_param.h
 VM_BCACHE_SIZE_MAX	opt_param.h
 VM_SWZONE_SIZE_MAX	opt_param.h
 MAXUSERS
 DFLDSIZ		opt_param.h
 MAXDSIZ		opt_param.h
 MAXSSIZ		opt_param.h
 
 # Generic SCSI options.
 CAM_MAX_HIGHPOWER	opt_cam.h
 CAMDEBUG		opt_cam.h
 CAM_DEBUG_COMPILE	opt_cam.h
 CAM_DEBUG_DELAY		opt_cam.h
 CAM_DEBUG_BUS		opt_cam.h
 CAM_DEBUG_TARGET	opt_cam.h
 CAM_DEBUG_LUN		opt_cam.h
 CAM_DEBUG_FLAGS		opt_cam.h
+CAM_BOOT_DELAY		opt_cam.h
 SCSI_DELAY		opt_scsi.h
 SCSI_NO_SENSE_STRINGS	opt_scsi.h
 SCSI_NO_OP_STRINGS	opt_scsi.h
 
 # Options used only in cam/ata/ata_da.c
 ADA_TEST_FAILURE	opt_ada.h
 ATA_STATIC_ID		opt_ada.h
 
 # Options used only in cam/scsi/scsi_cd.c
 CHANGER_MIN_BUSY_SECONDS	opt_cd.h
 CHANGER_MAX_BUSY_SECONDS	opt_cd.h
 
 # Options used only in cam/scsi/scsi_sa.c.
 SA_IO_TIMEOUT		opt_sa.h
 SA_SPACE_TIMEOUT	opt_sa.h
 SA_REWIND_TIMEOUT	opt_sa.h
 SA_ERASE_TIMEOUT	opt_sa.h
 SA_1FM_AT_EOD		opt_sa.h
 
 # Options used only in cam/scsi/scsi_pt.c
 SCSI_PT_DEFAULT_TIMEOUT	opt_pt.h
 
 # Options used only in cam/scsi/scsi_ses.c
 SES_ENABLE_PASSTHROUGH	opt_ses.h
 
 # Options used in dev/sym/ (Symbios SCSI driver).
 SYM_SETUP_LP_PROBE_MAP	opt_sym.h	#-Low Priority Probe Map (bits)
 					# Allows the ncr to take precedence
 					# 1 (1<<0) -> 810a, 860
 					# 2 (1<<1) -> 825a, 875, 885, 895
 					# 4 (1<<2) -> 895a, 896, 1510d 
 SYM_SETUP_SCSI_DIFF	opt_sym.h	#-HVD support for 825a, 875, 885
 					# disabled:0 (default), enabled:1
 SYM_SETUP_PCI_PARITY	opt_sym.h	#-PCI parity checking
 					# disabled:0, enabled:1 (default)
 SYM_SETUP_MAX_LUN	opt_sym.h	#-Number of LUNs supported
 					# default:8, range:[1..64]
 
 # Options used only in pci/ncr.c
 SCSI_NCR_DEBUG		opt_ncr.h
 SCSI_NCR_MAX_SYNC	opt_ncr.h
 SCSI_NCR_MAX_WIDE	opt_ncr.h
 SCSI_NCR_MYADDR		opt_ncr.h
 
 # Options used only in dev/isp/*
 ISP_TARGET_MODE		opt_isp.h
 ISP_FW_CRASH_DUMP	opt_isp.h
 ISP_DEFAULT_ROLES	opt_isp.h
 ISP_INTERNAL_TARGET	opt_isp.h
 
 # Options used only in dev/iscsi
 ISCSI_INITIATOR_DEBUG	opt_iscsi_initiator.h
 
 # Net stuff.
 ACCEPT_FILTER_DATA
 ACCEPT_FILTER_DNS
 ACCEPT_FILTER_HTTP
 ALTQ			opt_global.h
 ALTQ_CBQ		opt_altq.h
 ALTQ_CDNR		opt_altq.h
 ALTQ_DEBUG		opt_altq.h
 ALTQ_HFSC		opt_altq.h
 ALTQ_NOPCC		opt_altq.h
 ALTQ_PRIQ		opt_altq.h
 ALTQ_RED		opt_altq.h
 ALTQ_RIO		opt_altq.h
 BOOTP			opt_bootp.h
 BOOTP_BLOCKSIZE		opt_bootp.h
 BOOTP_COMPAT		opt_bootp.h
 BOOTP_NFSROOT		opt_bootp.h
 BOOTP_NFSV3		opt_bootp.h
 BOOTP_WIRED_TO		opt_bootp.h
 DEVICE_POLLING
 DEV_ENC			opt_enc.h
 DEV_PF			opt_pf.h
 DEV_PFLOG		opt_pf.h
 DEV_PFSYNC		opt_pf.h
 DEV_VLAN		opt_vlan.h
 DUMMYNET		opt_ipdn.h
 ETHER_8022		opt_ef.h
 ETHER_8023		opt_ef.h
 ETHER_II		opt_ef.h
 ETHER_SNAP		opt_ef.h
 INET			opt_inet.h
 INET6			opt_inet6.h
 IPDIVERT
 IPFILTER		opt_ipfilter.h
 IPFILTER_DEFAULT_BLOCK	opt_ipfilter.h
 IPFILTER_LOG		opt_ipfilter.h
 IPFILTER_LOOKUP		opt_ipfilter.h
 IPFIREWALL		opt_ipfw.h
 IPFIREWALL_DEFAULT_TO_ACCEPT	opt_ipfw.h
 IPFIREWALL_NAT		opt_ipfw.h
 IPFIREWALL_VERBOSE	opt_ipfw.h
 IPFIREWALL_VERBOSE_LIMIT	opt_ipfw.h
 IPSEC			opt_ipsec.h
 IPSEC_DEBUG		opt_ipsec.h
 IPSEC_FILTERTUNNEL	opt_ipsec.h
 IPSEC_NAT_T		opt_ipsec.h
 IPSTEALTH
 IPX
 KRPC
 LIBALIAS
 LIBMBPOOL
 LIBMCHAIN
 MBUF_PROFILING
 MBUF_STRESS_TEST
 MROUTING		opt_mrouting.h
 NETATALK		opt_atalk.h
 NFSLOCKD
 PCBGROUP		opt_pcbgroup.h
 PF_DEFAULT_TO_DROP	opt_pf.h
 RADIX_MPATH		opt_mpath.h
 ROUTETABLES		opt_route.h
 SLIP_IFF_OPTS		opt_slip.h
 TCPDEBUG
 TCP_OFFLOAD		opt_inet.h # Enable code to dispatch TCP offloading
 TCP_SIGNATURE		opt_inet.h
 VLAN_ARRAY		opt_vlan.h
 XBONEHACK
 FLOWTABLE		opt_route.h
 
 #
 # SCTP
 #
 SCTP			opt_sctp.h
 SCTP_DEBUG		opt_sctp.h # Enable debug printfs
 SCTP_WITH_NO_CSUM	opt_sctp.h # Use this at your peril
 SCTP_LOCK_LOGGING	opt_sctp.h # Log to KTR lock activity
 SCTP_MBUF_LOGGING	opt_sctp.h # Log to KTR general mbuf aloc/free
 SCTP_MBCNT_LOGGING	opt_sctp.h # Log to KTR mbcnt activity
 SCTP_PACKET_LOGGING	opt_sctp.h # Log to a packet buffer last N packets
 SCTP_LTRACE_CHUNKS	opt_sctp.h # Log to KTR chunks processed
 SCTP_LTRACE_ERRORS	opt_sctp.h # Log to KTR error returns.
 SCTP_USE_PERCPU_STAT    opt_sctp.h # Use per cpu stats.
 SCTP_MCORE_INPUT        opt_sctp.h # Have multiple input threads for input mbufs
 #
 #
 #
 
 # Netgraph(4). Use option NETGRAPH to enable the base netgraph code.
 # Each netgraph node type can be either be compiled into the kernel
 # or loaded dynamically. To get the former, include the corresponding
 # option below. Each type has its own man page, e.g. ng_async(4).
 NETGRAPH
 NETGRAPH_DEBUG		opt_netgraph.h
 NETGRAPH_ASYNC		opt_netgraph.h
 NETGRAPH_ATMLLC		opt_netgraph.h
 NETGRAPH_ATM_ATMPIF	opt_netgraph.h
 NETGRAPH_BLUETOOTH	opt_netgraph.h
 NETGRAPH_BLUETOOTH_BT3C	opt_netgraph.h
 NETGRAPH_BLUETOOTH_H4	opt_netgraph.h
 NETGRAPH_BLUETOOTH_HCI	opt_netgraph.h
 NETGRAPH_BLUETOOTH_L2CAP	opt_netgraph.h
 NETGRAPH_BLUETOOTH_SOCKET	opt_netgraph.h
 NETGRAPH_BLUETOOTH_UBT	opt_netgraph.h
 NETGRAPH_BLUETOOTH_UBTBCMFW	opt_netgraph.h
 NETGRAPH_BPF		opt_netgraph.h
 NETGRAPH_BRIDGE		opt_netgraph.h
 NETGRAPH_CAR		opt_netgraph.h
 NETGRAPH_CISCO		opt_netgraph.h
 NETGRAPH_DEFLATE	opt_netgraph.h
 NETGRAPH_DEVICE		opt_netgraph.h
 NETGRAPH_ECHO		opt_netgraph.h
 NETGRAPH_EIFACE		opt_netgraph.h
 NETGRAPH_ETHER		opt_netgraph.h
 NETGRAPH_ETHER_ECHO	opt_netgraph.h
 NETGRAPH_FEC		opt_netgraph.h
 NETGRAPH_FRAME_RELAY	opt_netgraph.h
 NETGRAPH_GIF		opt_netgraph.h
 NETGRAPH_GIF_DEMUX	opt_netgraph.h
 NETGRAPH_HOLE		opt_netgraph.h
 NETGRAPH_IFACE		opt_netgraph.h
 NETGRAPH_IP_INPUT	opt_netgraph.h
 NETGRAPH_IPFW		opt_netgraph.h
 NETGRAPH_KSOCKET	opt_netgraph.h
 NETGRAPH_L2TP		opt_netgraph.h
 NETGRAPH_LMI		opt_netgraph.h
 # MPPC compression requires proprietary files (not included)
 NETGRAPH_MPPC_COMPRESSION	opt_netgraph.h
 NETGRAPH_MPPC_ENCRYPTION	opt_netgraph.h
 NETGRAPH_NAT		opt_netgraph.h
 NETGRAPH_NETFLOW	opt_netgraph.h
 NETGRAPH_ONE2MANY	opt_netgraph.h
 NETGRAPH_PATCH		opt_netgraph.h
 NETGRAPH_PIPE		opt_netgraph.h
 NETGRAPH_PPP		opt_netgraph.h
 NETGRAPH_PPPOE		opt_netgraph.h
 NETGRAPH_PPTPGRE	opt_netgraph.h
 NETGRAPH_PRED1		opt_netgraph.h
 NETGRAPH_RFC1490	opt_netgraph.h
 NETGRAPH_SOCKET		opt_netgraph.h
 NETGRAPH_SPLIT		opt_netgraph.h
 NETGRAPH_SPPP		opt_netgraph.h
 NETGRAPH_TAG		opt_netgraph.h
 NETGRAPH_TCPMSS		opt_netgraph.h
 NETGRAPH_TEE		opt_netgraph.h
 NETGRAPH_TTY		opt_netgraph.h
 NETGRAPH_UI		opt_netgraph.h
 NETGRAPH_VJC		opt_netgraph.h
 NETGRAPH_VLAN		opt_netgraph.h
 
 # NgATM options
 NGATM_ATM		opt_netgraph.h
 NGATM_ATMBASE		opt_netgraph.h
 NGATM_SSCOP		opt_netgraph.h
 NGATM_SSCFU		opt_netgraph.h
 NGATM_UNI		opt_netgraph.h
 NGATM_CCATM		opt_netgraph.h
 
 # DRM options
 DRM_DEBUG		opt_drm.h
 
 SOCKET_SEND_COW		opt_zero.h
 SOCKET_RECV_PFLIP	opt_zero.h
 TI_SF_BUF_JUMBO		opt_ti.h
 TI_JUMBO_HDRSPLIT	opt_ti.h
 
 # XXX Conflict: # of devices vs network protocol (Native ATM).
 # This makes "atm.h" unusable.
 NATM
 
 # DPT driver debug flags
 DPT_MEASURE_PERFORMANCE	opt_dpt.h
 DPT_RESET_HBA		opt_dpt.h
 
 # Misc debug flags.  Most of these should probably be replaced with
 # 'DEBUG', and then let people recompile just the interesting modules
 # with 'make CC="cc -DDEBUG"'.
 CLUSTERDEBUG		opt_debug_cluster.h
 DEBUG_1284		opt_ppb_1284.h
 VP0_DEBUG		opt_vpo.h
 LPT_DEBUG		opt_lpt.h
 PLIP_DEBUG		opt_plip.h
 LOCKF_DEBUG		opt_debug_lockf.h
 NETATALKDEBUG		opt_atalk.h
 SI_DEBUG		opt_debug_si.h
 
 # Fb options
 FB_DEBUG		opt_fb.h
 FB_INSTALL_CDEV		opt_fb.h
 
 # ppbus related options
 PERIPH_1284		opt_ppb_1284.h
 DONTPROBE_1284		opt_ppb_1284.h
 
 # smbus related options
 ENABLE_ALART		opt_intpm.h
 
 # These cause changes all over the kernel
 BLKDEV_IOSIZE		opt_global.h
 BURN_BRIDGES		opt_global.h
 DEBUG			opt_global.h
 DEBUG_LOCKS		opt_global.h
 DEBUG_VFS_LOCKS		opt_global.h
 DFLTPHYS		opt_global.h
 DIAGNOSTIC		opt_global.h
 INVARIANT_SUPPORT	opt_global.h
 INVARIANTS		opt_global.h
 MAXCPU			opt_global.h
 MAXPHYS			opt_global.h
 MCLSHIFT		opt_global.h
 MUTEX_DEBUG		opt_global.h
 MUTEX_NOINLINE		opt_global.h
 LOCK_PROFILING		opt_global.h
 LOCK_PROFILING_FAST	opt_global.h
 MSIZE			opt_global.h
 REGRESSION		opt_global.h
 RWLOCK_NOINLINE		opt_global.h
 SX_NOINLINE		opt_global.h
 VFS_BIO_DEBUG		opt_global.h
 
 # These are VM related options
 VM_KMEM_SIZE		opt_vm.h
 VM_KMEM_SIZE_SCALE	opt_vm.h
 VM_KMEM_SIZE_MAX	opt_vm.h
 VM_NDOMAIN		opt_vm.h
 VM_NRESERVLEVEL		opt_vm.h
 VM_LEVEL_0_ORDER	opt_vm.h
 NO_SWAPPING		opt_vm.h
 MALLOC_MAKE_FAILURES	opt_vm.h
 MALLOC_PROFILE		opt_vm.h
 MALLOC_DEBUG_MAXZONES	opt_vm.h
 
 # The MemGuard replacement allocator used for tamper-after-free detection
 DEBUG_MEMGUARD		opt_vm.h
 
 # The RedZone malloc(9) protection
 DEBUG_REDZONE		opt_vm.h
 
 # Standard SMP options
 SMP			opt_global.h
 
 # Size of the kernel message buffer
 MSGBUF_SIZE		opt_msgbuf.h
 
 # NFS options
 NFS_MINATTRTIMO		opt_nfs.h
 NFS_MAXATTRTIMO		opt_nfs.h
 NFS_MINDIRATTRTIMO	opt_nfs.h
 NFS_MAXDIRATTRTIMO	opt_nfs.h
 NFS_GATHERDELAY		opt_nfs.h
 NFS_WDELAYHASHSIZ	opt_nfs.h
 NFS_DEBUG		opt_nfs.h
 
 # For the Bt848/Bt848A/Bt849/Bt878/Bt879 driver
 OVERRIDE_CARD			opt_bktr.h
 OVERRIDE_TUNER			opt_bktr.h
 OVERRIDE_DBX			opt_bktr.h
 OVERRIDE_MSP			opt_bktr.h
 BROOKTREE_SYSTEM_DEFAULT	opt_bktr.h
 BROOKTREE_ALLOC_PAGES		opt_bktr.h
 BKTR_OVERRIDE_CARD		opt_bktr.h
 BKTR_OVERRIDE_TUNER		opt_bktr.h
 BKTR_OVERRIDE_DBX		opt_bktr.h
 BKTR_OVERRIDE_MSP		opt_bktr.h
 BKTR_SYSTEM_DEFAULT		opt_bktr.h
 BKTR_ALLOC_PAGES		opt_bktr.h
 BKTR_USE_PLL			opt_bktr.h	
 BKTR_GPIO_ACCESS		opt_bktr.h
 BKTR_NO_MSP_RESET		opt_bktr.h
 BKTR_430_FX_MODE		opt_bktr.h
 BKTR_SIS_VIA_MODE		opt_bktr.h
 BKTR_USE_FREEBSD_SMBUS		opt_bktr.h
 BKTR_NEW_MSP34XX_DRIVER		opt_bktr.h
 
 # Options to support PPS
 UART_PPS_ON_CTS		opt_uart.h
 
 # options for bus/device framework
 BUS_DEBUG		opt_bus.h
 
 # options for USB support
 USB_DEBUG		opt_usb.h
 USB_HOST_ALIGN		opt_usb.h
 USB_REQ_DEBUG		opt_usb.h
 USB_VERBOSE		opt_usb.h
 USB_EHCI_BIG_ENDIAN_DESC	opt_usb.h
 U3G_DEBUG		opt_u3g.h
 UKBD_DFLT_KEYMAP	opt_ukbd.h
 UPLCOM_INTR_INTERVAL	opt_uplcom.h
 UVSCOM_DEFAULT_OPKTSIZE	opt_uvscom.h
 UVSCOM_INTR_INTERVAL	opt_uvscom.h
 
 # Embedded system options
 INIT_PATH
 
 ROOTDEVNAME
 
 FDC_DEBUG		opt_fdc.h
 PCFCLOCK_VERBOSE	opt_pcfclock.h
 PCFCLOCK_MAX_RETRIES	opt_pcfclock.h
 
 KTR			opt_global.h
 KTR_ALQ			opt_ktr.h
 KTR_MASK		opt_ktr.h
 KTR_CPUMASK		opt_ktr.h
 KTR_COMPILE		opt_global.h
 KTR_BOOT_ENTRIES	opt_global.h
 KTR_ENTRIES		opt_global.h
 KTR_VERBOSE		opt_ktr.h
 WITNESS			opt_global.h
 WITNESS_KDB		opt_witness.h
 WITNESS_SKIPSPIN	opt_witness.h
 
 # options for ACPI support
 ACPI_DEBUG		opt_acpi.h
 ACPI_MAX_TASKS		opt_acpi.h
 ACPI_MAX_THREADS	opt_acpi.h
 
 # ISA support
 DEV_ISA			opt_isa.h
 ISAPNP			opt_isa.h
 
 # various 'device presence' options.
 DEV_BPF			opt_bpf.h
 DEV_NETMAP		opt_global.h
 DEV_MCA			opt_mca.h
 DEV_CARP		opt_carp.h
 DEV_SPLASH		opt_splash.h
 
 # EISA support
 DEV_EISA		opt_eisa.h
 EISA_SLOTS		opt_eisa.h
 
 # ed driver
 ED_HPP			opt_ed.h
 ED_3C503		opt_ed.h
 ED_SIC			opt_ed.h
 
 # bce driver
 BCE_DEBUG		opt_bce.h
 BCE_NVRAM_WRITE_SUPPORT	opt_bce.h
 
 # bxe driver
 BXE_DEBUG		opt_bxe.h
 BXE_NVRAM_WRITE_SUPPORT	opt_bxe.h
 
 SOCKBUF_DEBUG		opt_global.h
 
 
 # options for ubsec driver
 UBSEC_DEBUG		opt_ubsec.h
 UBSEC_RNDTEST		opt_ubsec.h
 UBSEC_NO_RNG		opt_ubsec.h
 
 # options for hifn driver
 HIFN_DEBUG		opt_hifn.h
 HIFN_RNDTEST		opt_hifn.h
 
 # options for safenet driver
 SAFE_DEBUG		opt_safe.h
 SAFE_NO_RNG		opt_safe.h
 SAFE_RNDTEST		opt_safe.h
 
 # syscons options
 MAXCONS			opt_syscons.h
 SC_ALT_MOUSE_IMAGE	opt_syscons.h
 SC_CUT_SPACES2TABS	opt_syscons.h
 SC_CUT_SEPCHARS		opt_syscons.h
 SC_DEBUG_LEVEL		opt_syscons.h
 SC_DFLT_FONT		opt_syscons.h
 SC_DISABLE_KDBKEY	opt_syscons.h
 SC_DISABLE_REBOOT	opt_syscons.h
 SC_HISTORY_SIZE		opt_syscons.h
 SC_KERNEL_CONS_ATTR	opt_syscons.h
 SC_KERNEL_CONS_REV_ATTR	opt_syscons.h
 SC_MOUSE_CHAR		opt_syscons.h
 SC_NO_CUTPASTE		opt_syscons.h
 SC_NO_FONT_LOADING	opt_syscons.h
 SC_NO_HISTORY		opt_syscons.h
 SC_NO_MODE_CHANGE	opt_syscons.h
 SC_NO_SUSPEND_VTYSWITCH	opt_syscons.h
 SC_NO_SYSMOUSE		opt_syscons.h
 SC_NORM_ATTR		opt_syscons.h
 SC_NORM_REV_ATTR	opt_syscons.h
 SC_PIXEL_MODE		opt_syscons.h
 SC_RENDER_DEBUG		opt_syscons.h
 SC_TWOBUTTON_MOUSE	opt_syscons.h
 
 # teken terminal emulator options
 TEKEN_CONS25		opt_teken.h
 TEKEN_UTF8		opt_teken.h
 
 # options for printf
 PRINTF_BUFR_SIZE	opt_printf.h
 
 # kbd options
 KBD_DISABLE_KEYMAP_LOAD	opt_kbd.h
 KBD_INSTALL_CDEV	opt_kbd.h
 KBD_MAXRETRY		opt_kbd.h
 KBD_MAXWAIT		opt_kbd.h
 KBD_RESETDELAY		opt_kbd.h
 KBDIO_DEBUG		opt_kbd.h
 
 # options for the Atheros driver
 ATH_DEBUG		opt_ath.h
 ATH_TXBUF		opt_ath.h
 ATH_RXBUF		opt_ath.h
 ATH_DIAGAPI		opt_ath.h
 ATH_TX99_DIAG		opt_ath.h
 ATH_ENABLE_11N		opt_ath.h
 ATH_ENABLE_DFS		opt_ath.h
 ATH_EEPROM_FIRMWARE	opt_ath.h
 ATH_ENABLE_RADIOTAP_VENDOR_EXT	opt_ath.h
 ATH_DEBUG_ALQ		opt_ath.h
 ATH_KTR_INTR_DEBUG	opt_ath.h
 
 # options for the Atheros hal
 AH_SUPPORT_AR5416	opt_ah.h
 # XXX For now, this breaks non-AR9130 chipsets, so only use it
 # XXX when actually targetting AR9130.
 AH_SUPPORT_AR9130	opt_ah.h
 
 AH_DEBUG		opt_ah.h
 AH_ASSERT		opt_ah.h
 AH_DEBUG_ALQ		opt_ah.h
 AH_REGOPS_FUNC		opt_ah.h
 AH_WRITE_REGDOMAIN	opt_ah.h
 AH_DEBUG_COUNTRY	opt_ah.h
 AH_WRITE_EEPROM		opt_ah.h
 AH_PRIVATE_DIAG		opt_ah.h
 AH_NEED_DESC_SWAP	opt_ah.h
 AH_USE_INIPDGAIN	opt_ah.h
 AH_MAXCHAN		opt_ah.h
 AH_RXCFG_SDMAMW_4BYTES	opt_ah.h
 AH_INTERRUPT_DEBUGGING	opt_ah.h
 # AR5416 and later interrupt mitigation
 # XXX do not use this for AR9130
 AH_AR5416_INTERRUPT_MITIGATION	opt_ah.h
 
 # options for the Broadcom BCM43xx driver (bwi)
 BWI_DEBUG		opt_bwi.h
 BWI_DEBUG_VERBOSE	opt_bwi.h
 
 # options for the Marvell 8335 wireless driver
 MALO_DEBUG		opt_malo.h
 MALO_TXBUF		opt_malo.h
 MALO_RXBUF		opt_malo.h
 
 # options for the Marvell wireless driver
 MWL_DEBUG		opt_mwl.h
 MWL_TXBUF		opt_mwl.h
 MWL_RXBUF		opt_mwl.h
 MWL_DIAGAPI		opt_mwl.h
 MWL_AGGR_SIZE		opt_mwl.h
 MWL_TX_NODROP		opt_mwl.h
 
 # dcons options 
 DCONS_BUF_SIZE		opt_dcons.h
 DCONS_POLL_HZ		opt_dcons.h
 DCONS_FORCE_CONSOLE	opt_dcons.h
 DCONS_FORCE_GDB		opt_dcons.h
 
 # HWPMC options
 HWPMC_HOOKS
 HWPMC_MIPS_BACKTRACE 	opt_hwpmc_hooks.h
 
 # XBOX options for FreeBSD/i386, but some files are MI
 XBOX			opt_xbox.h
 
 ZFS			opt_dontuse.h
 
 # Interrupt filtering
 INTR_FILTER
 
 # 802.11 support layer
 IEEE80211_DEBUG		opt_wlan.h
 IEEE80211_DEBUG_REFCNT	opt_wlan.h
 IEEE80211_AMPDU_AGE	opt_wlan.h
 IEEE80211_SUPPORT_MESH	opt_wlan.h
 IEEE80211_SUPPORT_SUPERG	opt_wlan.h
 IEEE80211_SUPPORT_TDMA	opt_wlan.h
 IEEE80211_ALQ		opt_wlan.h
 IEEE80211_DFS_DEBUG	opt_wlan.h
 
 # 802.11 TDMA support
 TDMA_SLOTLEN_DEFAULT	opt_tdma.h
 TDMA_SLOTCNT_DEFAULT	opt_tdma.h
 TDMA_BINTVAL_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11B_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11G_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11A_DEFAULT	opt_tdma.h
 TDMA_TXRATE_TURBO_DEFAULT	opt_tdma.h
 TDMA_TXRATE_HALF_DEFAULT	opt_tdma.h
 TDMA_TXRATE_QUARTER_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11NA_DEFAULT	opt_tdma.h
 TDMA_TXRATE_11NG_DEFAULT	opt_tdma.h
 
 # Network stack virtualization options
 VIMAGE			opt_global.h
 VNET_DEBUG		opt_global.h
 
 # Common Flash Interface (CFI) options
 CFI_SUPPORT_STRATAFLASH	opt_cfi.h
 CFI_ARMEDANDDANGEROUS	opt_cfi.h
 
 # Sound options
 SND_DEBUG		opt_snd.h
 SND_DIAGNOSTIC		opt_snd.h
 SND_FEEDER_MULTIFORMAT	opt_snd.h
 SND_FEEDER_FULL_MULTIFORMAT	opt_snd.h
 SND_FEEDER_RATE_HP	opt_snd.h
 SND_PCM_64		opt_snd.h
 SND_OLDSTEREO		opt_snd.h
 
 X86BIOS
 
 # Flattened device tree options
 FDT		opt_platform.h
 FDT_DTB_STATIC	opt_platform.h
 
 # OFED Infiniband stack
 OFED		opt_ofed.h
 OFED_DEBUG_INIT	opt_ofed.h
 SDP		opt_ofed.h
 SDP_DEBUG	opt_ofed.h
 IPOIB		opt_ofed.h
 IPOIB_DEBUG	opt_ofed.h
 IPOIB_CM	opt_ofed.h
 
 # Resource Accounting
 RACCT		opt_global.h
 
 # Resource Limits
 RCTL		opt_global.h
Index: user/attilio/vmcontention/sys/conf
===================================================================
--- user/attilio/vmcontention/sys/conf	(revision 249698)
+++ user/attilio/vmcontention/sys/conf	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/conf
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head/sys/conf:r249647-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/changes.txt
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/changes.txt	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/changes.txt	(revision 249699)
@@ -1,13470 +1,13557 @@
 ----------------------------------------
+18 April 2013. Summary of changes for version 20130418:
+
+This release is available at https://acpica.org/downloads
+
+
+1) ACPICA kernel-resident subsystem:
+
+Fixed a possible buffer overrun during some rare but specific field unit 
+read operations. This overrun can only happen if the DSDT version is 1 -- 
+meaning that all AML integers are 32 bits -- and the field length is 
+between 33 and 55 bits long. During the read, an internal buffer object is 
+created for the field unit because the field is larger than an integer (32 
+bits). However, in this case, the buffer will be incorrectly written 
+beyond the end because the buffer length is less than the internal minimum 
+of 64 bits (8 bytes) long. The buffer will be either 5, 6, or 7 bytes 
+long, but a full 8 bytes will be written.
+
+Updated the Embedded Controller "orphan" _REG method support. This refers 
+to _REG methods under the EC device that have no corresponding operation 
+region. This is allowed by the ACPI specification. This update removes a 
+dependency on the existence an ECDT table. It will execute an orphan _REG 
+method as long as the operation region handler for the EC is installed at 
+the EC device node and not the namespace root. Rui Zhang (original 
+update), Bob Moore (update/integrate).
+
+Implemented run-time argument typechecking for all predefined ACPI names 
+(_STA, _BIF, etc.) This change performs object typechecking on all 
+incoming arguments for all predefined names executed via 
+AcpiEvaluateObject. This ensures that ACPI-related device drivers are 
+passing correct object types as well as the correct number of arguments 
+(therefore identifying any issues immediately). Also, the ASL/namespace 
+definition of the predefined name is checked against the ACPI 
+specification for the proper argument count. Adds one new file, 
+nsarguments.c
+
+Changed an exception code for the ASL UnLoad() operator. Changed the 
+exception code for the case where the input DdbHandle is invalid, from 
+AE_BAD_PARAMETER to the more appropriate AE_AML_OPERAND_TYPE.
+
+Unix/Linux makefiles: Removed the use of the -O2 optimization flag in the 
+global makefile. The use of this flag causes compiler errors on earlier 
+versions of GCC, so it has been removed for compatibility.
+
+Miscellaneous cleanup:
+1) Removed some unused/obsolete macros
+2) Fixed a possible memory leak in the _OSI support
+3) Removed an unused variable in the predefined name support
+4) Windows OSL: remove obsolete reference to a memory list field
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
+debug version of the code includes the debug output trace mechanism and 
+has a much larger code and data size.
+
+  Current Release:
+    Non-Debug Version:  95.2K Code, 26.4K Data, 121.6K Total
+    Debug Version:     183.0K Code, 76.0K Data, 259.0K Total
+  Previous Release:
+    Non-Debug Version:  95.6K Code, 26.8K Data, 122.4K Total
+    Debug Version:     183.5K Code, 76.6K Data, 260.1K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+AcpiExec: Added installation of a handler for the SystemCMOS address 
+space. This prevents control method abort if a method accesses this space.
+
+AcpiExec: Added support for multiple EC devices, and now install EC 
+operation region handler(s) at the actual EC device instead of the 
+namespace root. This reflects the typical behavior of host operating 
+systems.
+
+AcpiExec: Updated to ensure that all operation region handlers are 
+installed before the _REG methods are executed. This prevents a _REG 
+method from aborting if it accesses an address space has no handler. 
+AcpiExec installs a handler for every possible address space.
+
+Debugger: Enhanced the "handlers" command to display non-root handlers. 
+This change enhances the handlers command to display handlers associated 
+with individual devices throughout the namespace, in addition to the 
+currently supported display of handlers associated with the root namespace 
+node.
+
+ASL Test Suite: Several test suite errors have been identified and 
+resolved, reducing the total error count during execution. Chao Guan.
+
+----------------------------------------
 28 March 2013. Summary of changes for version 20130328:
 
 1) ACPICA kernel-resident subsystem:
 
 Fixed several possible race conditions with the internal object reference 
 counting mechanism. Some of the external ACPICA interfaces update object 
 reference counts without holding the interpreter or namespace lock. This 
 change adds a spinlock to protect reference count updates on the internal 
 ACPICA objects. Reported by and with assistance from Andriy Gapon 
 (avg@FreeBSD.org).
 
 FADT support: Removed an extraneous warning for very large GPE register 
 sets. This change removes a size mismatch warning if the legacy length 
 field for a GPE register set is larger than the 64-bit GAS structure can 
 accommodate. GPE register sets can be larger than the 255-bit width 
 limitation of the GAS structure. Linn Crosetto (linn@hp.com).
 
 _OSI Support: handle any errors from AcpiOsAcquireMutex. Check for error 
 return from this interface. Handles a possible timeout case if 
 ACPI_WAIT_FOREVER is modified by the host to be a value less than 
 "forever". Jung-uk Kim.
 
 Predefined name support: Add allowed/required argument type information to 
 the master predefined info table. This change adds the infrastructure to 
 enable typechecking on incoming arguments for all predefined 
 methods/objects. It does not actually contain the code that will fully 
 utilize this information, this is still under development. Also condenses 
 some duplicate code for the predefined names into a new module, 
 utilities/utpredef.c
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  95.0K Code, 25.9K Data, 120.9K Total
     Debug Version:     182.9K Code, 75.6K Data, 258.5K Total
   Current Release:
     Non-Debug Version:  95.2K Code, 26.4K Data, 121.6K Total
     Debug Version:     183.0K Code, 76.0K Data, 259.0K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented a new option to simplify the development of ACPI-related 
 BIOS code. Adds support for a new "offset table" output file. The -so 
 option will create a C table containing the AML table offsets of various 
 named objects in the namespace so that BIOS code can modify them easily at 
 boot time. This can simplify BIOS runtime code by eliminating expensive 
 searches for "magic values", enhancing boot times and adding greater 
 reliability. With assistance from Lee Hamel.
 
 iASL: Allow additional predefined names to return zero-length packages. 
 Now, all predefined names that are defined by the ACPI specification to 
 return a "variable-length package of packages" are allowed to return a 
 zero length top-level package. This allows the BIOS to tell the host that 
 the requested feature is not supported, and supports existing BIOS/ASL 
 code and practices.
 
 iASL: Changed the "result not used" warning to an error. This is the case 
 where an ASL operator is effectively a NOOP because the result of the 
 operation is not stored anywhere. For example:
     Add (4, Local0)
 There is no target (missing 3rd argument), nor is the function return 
 value used. This is potentially a very serious problem -- since the code 
 was probably intended to do something, but for whatever reason, the value 
 was not stored. Therefore, this issue has been upgraded from a warning to 
 an error.
 
 AcpiHelp: Added allowable/required argument types to the predefined names 
 info display. This feature utilizes the recent update to the predefined 
 names table (above).
 
 ----------------------------------------
 14 February 2013. Summary of changes for version 20130214:
 
 1) ACPICA Kernel-resident Subsystem:
 
 Fixed a possible regression on some hosts: Reinstated the safe return 
 macros (return_ACPI_STATUS, etc.) that ensure that the argument is 
 evaluated only once. Although these macros are not needed for the ACPICA 
 code itself, they are often used by ACPI-related host device drivers where 
 the safe feature may be necessary.
 
 Fixed several issues related to the ACPI 5.0 reduced hardware support 
 (SOC): Now ensure that if the platform declares itself as hardware-reduced 
 via the FADT, the following functions become NOOPs (and always return 
 AE_OK) because ACPI is always enabled by definition on these machines:
   AcpiEnable
   AcpiDisable
   AcpiHwGetMode
   AcpiHwSetMode
 
 Dynamic Object Repair: Implemented additional runtime repairs for 
 predefined name return values. Both of these repairs can simplify code in 
 the related device drivers that invoke these methods:
 1) For the _STR and _MLS names, automatically repair/convert an ASCII 
 string to a Unicode buffer. 
 2) For the _CRS, _PRS, and _DMA names, return a resource descriptor with a 
 lone end tag descriptor in the following cases: A Return(0) was executed, 
 a null buffer was returned, or no object at all was returned (non-slack 
 mode only). Adds a new file, nsconvert.c
 ACPICA BZ 998. Bob Moore, Lv Zheng.
 
 Resource Manager: Added additional code to prevent possible infinite loops 
 while traversing corrupted or ill-formed resource template buffers. Check 
 for zero-length resource descriptors in all code that loops through 
 resource templates (the length field is used to index through the 
 template). This change also hardens the external AcpiWalkResources and 
 AcpiWalkResourceBuffer interfaces.
 
 Local Cache Manager: Enhanced the main data structure to eliminate an 
 unnecessary mechanism to access the next object in the list. Actually 
 provides a small performance enhancement for hosts that use the local 
 ACPICA cache manager. Jung-uk Kim.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  94.5K Code, 25.4K Data, 119.9K Total
     Debug Version:     182.3K Code, 75.0K Data, 257.3K Total
   Current Release:
     Non-Debug Version:  95.0K Code, 25.9K Data, 120.9K Total
     Debug Version:     182.9K Code, 75.6K Data, 258.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL/Disassembler: Fixed several issues with the definition of the ACPI 
 5.0 RASF table (RAS Feature Table). This change incorporates late changes 
 that were made to the ACPI 5.0 specification.
 
 iASL/Disassembler: Added full support for the following new ACPI tables:
   1) The MTMR table (MID Timer Table)
   2) The VRTC table (Virtual Real Time Clock Table).
 Includes header file, disassembler, table compiler, and template support 
 for both tables.
 
 iASL: Implemented compile-time validation of package objects returned by 
 predefined names. This new feature validates static package objects 
 returned by the various predefined names defined to return packages. Both 
 object types and package lengths are validated, for both parent packages 
 and sub-packages, if any. The code is similar in structure and behavior to 
 the runtime repair mechanism within the AML interpreter and uses the 
 existing predefined name information table. Adds a new file, aslprepkg.c. 
 ACPICA BZ 938.
 
 iASL: Implemented auto-detection of binary ACPI tables for disassembly. 
 This feature detects a binary file with a valid ACPI table header and 
 invokes the disassembler automatically. Eliminates the need to 
 specifically invoke the disassembler with the -d option. ACPICA BZ 862.
 
 iASL/Disassembler: Added several warnings for the case where there are 
 unresolved control methods during the disassembly. This can potentially 
 cause errors when the output file is compiled, because the disassembler 
 assumes zero method arguments in these cases (it cannot determine the 
 actual number of arguments without resolution/definition of the method).
 
 Debugger: Added support to display all resources with a single command. 
 Invocation of the resources command with no arguments will now display all 
 resources within the current namespace.
 
 AcpiHelp: Added descriptive text for each ACPICA exception code displayed 
 via the -e option.
 
 ----------------------------------------
 17 January 2013. Summary of changes for version 20130117:
 
 1) ACPICA Kernel-resident Subsystem:
 
 Updated the AcpiGetSleepTypeData interface: Allow the \_Sx methods to 
 return either 1 or 2 integers. Although the ACPI spec defines the \_Sx 
 objects to return a package containing one integer, most BIOS code returns 
 two integers and the previous code reflects that. However, we also need to 
 support BIOS code that actually implements to the ACPI spec, and this 
 change reflects this.
 
 Fixed two issues with the ACPI_DEBUG_PRINT macros:
 1) Added the ACPI_DO_WHILE macro to the main DEBUG_PRINT helper macro for 
 C compilers that require this support.
 2) Renamed the internal ACPI_DEBUG macro to ACPI_DO_DEBUG_PRINT since 
 ACPI_DEBUG is already used by many of the various hosts.
 
 Updated all ACPICA copyrights and signons to 2013. Added the 2013 
 copyright to all module headers and signons, including the standard Linux 
 header. This affects virtually every file in the ACPICA core subsystem, 
 iASL compiler, all ACPICA utilities, and the test suites.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  94.5K Code, 25.5K Data, 120.0K Total
     Debug Version:     182.2K Code, 74.9K Data, 257.1K Total
   Current Release:
     Non-Debug Version:  94.5K Code, 25.4K Data, 119.9K Total
     Debug Version:     182.3K Code, 75.0K Data, 257.3K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Generic Unix OSL: Use a buffer to eliminate multiple vfprintf()s and 
 prevent a possible fault on some hosts. Some C libraries modify the arg 
 pointer parameter to vfprintf making it difficult to call it twice in the 
 AcpiOsVprintf function. Use a local buffer to workaround this issue. This 
 does not affect the Windows OSL since the Win C library does not modify 
 the arg pointer. Chao Guan, Bob Moore.
 
 iASL: Fixed a possible infinite loop when the maximum error count is 
 reached. If an output file other than the .AML file is specified (such as 
 a listing file), and the maximum number of errors is reached, do not 
 attempt to flush data to the output file(s) as the compiler is aborting. 
 This can cause an infinite loop as the max error count code essentially 
 keeps calling itself.
 
 iASL/Disassembler: Added an option (-in) to ignore NOOP opcodes/operators. 
 Implemented for both the compiler and the disassembler. Often, the NOOP 
 opcode is used as padding for packages that are changed dynamically by the 
 BIOS. When disassembled and recompiled, these NOOPs will cause syntax 
 errors. This option causes the disassembler to ignore all NOOP opcodes 
 (0xA3), and it also causes the compiler to ignore all ASL source code NOOP 
 statements as well.
 
 Debugger: Enhanced the Sleep command to execute all sleep states. This 
 change allows Sleep to be invoked with no arguments and causes the 
 debugger to execute all of the sleep states, 0-5, automatically.
 
 ----------------------------------------
 20 December 2012. Summary of changes for version 20121220:
 
 1) ACPICA Kernel-resident Subsystem:
 
 Implemented a new interface, AcpiWalkResourceBuffer. This interface is an 
 alternate entry point for AcpiWalkResources and improves the usability of 
 the resource manager by accepting as input a buffer containing the output 
 of either a _CRS, _PRS, or _AEI method. The key functionality is that the 
 input buffer is not deleted by this interface so that it can be used by 
 the host later. See the ACPICA reference for details.
 
 Interpreter: Add a warning if a 64-bit constant appears in a 32-bit table 
 (DSDT version < 2). The constant will be truncated and this warning 
 reflects that behavior.
 
 Resource Manager: Add support for the new ACPI 5.0 wake bit in the IRQ, 
 ExtendedInterrupt, and GpioInt descriptors. This change adds support to 
 both get and set the new wake bit in these descriptors, separately from 
 the existing share bit. Reported by Aaron Lu.
 
 Interpreter: Fix Store() when an implicit conversion is not possible. For 
 example, in the cases such as a store of a string to an existing package 
 object, implement the store as a CopyObject(). This is a small departure 
 from the ACPI specification which states that the control method should be 
 aborted in this case. However, the ASLTS suite depends on this behavior.
 
 Performance improvement for the various FUNCTION_TRACE and DEBUG_PRINT 
 macros: check if debug output is currently enabled as soon as possible to 
 minimize performance impact if debug is in fact not enabled.
 
 Source code restructuring: Cleanup to improve modularity. The following 
 new files have been added: dbconvert.c, evhandler.c, nsprepkg.c, 
 psopinfo.c, psobject.c, rsdumpinfo.c, utstring.c, and utownerid.c. 
 Associated makefiles and project files have been updated.
 
 Changed an exception code for LoadTable operator. For the case where one 
 of the input strings is too long, change the returned exception code from 
 AE_BAD_PARAMETER to AE_AML_STRING_LIMIT.
 
 Fixed a possible memory leak in dispatcher error path. On error, delete 
 the mutex object created during method mutex creation. Reported by 
 tim.gardner@canonical.com.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  94.3K Code, 25.3K Data, 119.6K Total
     Debug Version:     175.5K Code, 74.5K Data, 250.0K Total
   Current Release:
     Non-Debug Version:  94.5K Code, 25.5K Data, 120.0K Total
     Debug Version:     182.2K Code, 74.9K Data, 257.1K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Disallow a method call as argument to the ObjectType ASL operator. 
 This change tracks an errata to the ACPI 5.0 document. The AML grammar 
 will not allow the interpreter to differentiate between a method and a 
 method invocation when these are used as an argument to the ObjectType 
 operator. The ACPI specification change is to disallow a method invocation 
 (UserTerm) for the ObjectType operator.
 
 Finish support for the TPM2 and CSRT tables in the headers, table 
 compiler, and disassembler.
 
 Unix user-space OSL: Fix a problem with WaitSemaphore where the timeout 
 always expires immediately if the semaphore is not available. The original 
 code was using a relative-time timeout, but sem_timedwait requires the use 
 of an absolute time.
 
 iASL: Added a remark if the Timer() operator is used within a 32-bit 
 table. This operator returns a 64-bit time value that will be truncated 
 within a 32-bit table.
 
 iASL Source code restructuring: Cleanup to improve modularity. The 
 following new files have been added: aslhex.c, aslxref.c, aslnamesp.c, 
 aslmethod.c, and aslfileio.c. Associated makefiles and project files have 
 been updated.
 
 
 ----------------------------------------
 14 November 2012. Summary of changes for version 20121114:
 
 1) ACPICA Kernel-resident Subsystem:
 
 Implemented a performance enhancement for ACPI/AML Package objects. This 
 change greatly increases the performance of Package objects within the 
 interpreter. It changes the processing of reference counts for packages by 
 optimizing for the most common case where the package sub-objects are 
 either Integers, Strings, or Buffers. Increases the overall performance of 
 the ASLTS test suite by 1.5X (Increases the Slack Mode performance by 2X.) 
 Chao Guan. ACPICA BZ 943.
 
 Implemented and deployed common macros to extract flag bits from resource 
 descriptors. Improves readability and maintainability of the code. Fixes a 
 problem with the UART serial bus descriptor for the number of data bits 
 flags (was incorrectly 2 bits, should be 3).
 
 Enhanced the ACPI_GETx and ACPI_SETx macros. Improved the implementation 
 of the macros and changed the SETx macros to the style of (destination, 
 source). Also added ACPI_CASTx companion macros. Lv Zheng.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.9K Code, 25.2K Data, 119.1K Total
     Debug Version:     175.5K Code, 74.5K Data, 250.0K Total
   Current Release:
     Non-Debug Version:  94.3K Code, 25.3K Data, 119.6K Total
     Debug Version:     175.5K Code, 74.5K Data, 250.0K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Added the new ACPI 5.0 interrupt sharing flags. This change 
 adds the ShareAndWake and ExclusiveAndWake flags which were added to the 
 Irq, Interrupt, and Gpio resource descriptors in ACPI 5.0. ACPICA BZ 986.
 
 Disassembler: Fixed a problem with external declaration generation. Fixes 
 a problem where an incorrect pathname could be generated for an external 
 declaration if the original reference to the object includes leading 
 carats (^). ACPICA BZ 984.
 
 Debugger: Completed a major update for the Disassemble command. 
 This command was out-of-date and did not properly disassemble control 
 methods that had any reasonable complexity. This fix brings the command up 
 to the same level as the rest of the disassembler. Adds one new file, 
 dmdeferred.c, which is existing code that is now common with the main 
 disassembler and the debugger disassemble command. ACPICA MZ 978.
 
 iASL: Moved the parser entry prototype to avoid a duplicate declaration. 
 Newer versions of Bison emit this prototype, so moved the prototype out of 
 the iASL header to where it is actually used in order to avoid a duplicate 
 declaration.
 
 iASL/Tools: Standardized use of the stream I/O functions:
   1) Ensure check for I/O error after every fopen/fread/fwrite
   2) Ensure proper order of size/count arguments for fread/fwrite
   3) Use test of (Actual != Requested) after all fwrite, and most fread
   4) Standardize I/O error messages
 Improves reliability and maintainability of the code. Bob Moore, Lv Zheng. 
 ACPICA BZ 981.
 
 Disassembler: Prevent duplicate External() statements. During generation 
 of external statements, detect similar pathnames that are actually 
 duplicates such as these:
   External (\ABCD)
   External (ABCD)
 Remove all leading '\' characters from pathnames during the external 
 statement generation so that duplicates will be detected and tossed. 
 ACPICA BZ 985.
 
 Tools: Replace low-level I/O with stream I/O functions. Replace 
 open/read/write/close with the stream I/O equivalents 
 fopen/fread/fwrite/fclose for portability and performance. Lv Zheng, Bob 
 Moore.
 
 AcpiBin: Fix for the dump-to-hex function. Now correctly output the table 
 name header so that AcpiXtract recognizes the output file/table.
 
 iASL: Remove obsolete -2 option flag. Originally intended to force the 
 compiler/disassembler into an ACPI 2.0 mode, this was never implemented 
 and the entire concept is now obsolete.
 
 ----------------------------------------
 18 October 2012. Summary of changes for version 20121018:
 
 
 1) ACPICA Kernel-resident Subsystem:
 
 Updated support for the ACPI 5.0 MPST table. Fixes some problems 
 introduced by late changes to the table as it was added to the ACPI 5.0 
 specification. Includes header, disassembler, and data table compiler 
 support as well as a new version of the MPST template.
 
 AcpiGetObjectInfo: Enhanced the device object support to include the ACPI 
 5.0 _SUB method. Now calls _SUB in addition to the other PNP-related ID 
 methods: _HID, _CID, and _UID.
 
 Changed ACPI_DEVICE_ID to ACPI_PNP_DEVICE_ID. Also changed 
 ACPI_DEVICE_ID_LIST to ACPI_PNP_DEVICE_ID_LIST. These changes prevent 
 name collisions on hosts that reserve the *_DEVICE_ID (or *DeviceId) 
 names for their various drivers. Affects the AcpiGetObjectInfo external 
 interface, and other internal interfaces as well.
 
 Added and deployed a new macro for ACPI_NAME management: ACPI_MOVE_NAME. 
 This macro resolves to a simple 32-bit move of the 4-character ACPI_NAME 
 on machines that support non-aligned transfers. Optimizes for this case 
 rather than using a strncpy. With assistance from Zheng Lv.
 
 Resource Manager: Small fix for buffer size calculation. Fixed a one byte 
 error in the output buffer calculation. Feng Tang. ACPICA BZ 849.
 
 Added a new debug print message for AML mutex objects that are force-
 released. At control method termination, any currently acquired mutex 
 objects are force-released. Adds a new debug-only message for each one 
 that is released.
 
 Audited/updated all ACPICA return macros and the function debug depth 
 counter: 1) Ensure that all functions that use the various TRACE macros 
 also use the appropriate ACPICA return macros. 2) Ensure that all normal 
 return statements surround the return expression (value) with parens to 
 ensure consistency across the ACPICA code base. Guan Chao, Tang Feng, 
 Zheng Lv, Bob Moore. ACPICA Bugzilla 972.
 
 Global source code changes/maintenance: All extra lines at the start and 
 end of each source file have been removed for consistency. Also, within 
 comments, all new sentences start with a single space instead of a double 
 space, again for consistency across the code base.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.7K Code, 25.3K Data, 119.0K Total
     Debug Version:     175.0K Code, 74.4K Data, 249.4K Total
   Current Release:
     Non-Debug Version:  93.9K Code, 25.2K Data, 119.1K Total
     Debug Version:     175.5K Code, 74.5K Data, 250.0K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 AcpiExec: Improved the algorithm used for memory leak/corruption 
 detection. Added some intelligence to the code that maintains the global 
 list of allocated memory. The list is now ordered by allocated memory 
 address, significantly improving performance. When running AcpiExec on 
 the ASLTS test suite, speed improvements of 3X to 5X are seen, depending 
 on the platform and/or the environment. Note, this performance 
 enhancement affects the AcpiExec utility only, not the kernel-resident 
 ACPICA code.
 
 Enhanced error reporting for invalid AML opcodes and bad ACPI_NAMEs. For 
 the disassembler, dump the 48 bytes surrounding the invalid opcode. Fix 
 incorrect table offset reported for invalid opcodes. Report the original 
 32-bit value for bad ACPI_NAMEs (as well as the repaired name.)
 
 Disassembler: Enhanced the -vt option to emit the binary table data in 
 hex format to assist with debugging.
 
 Fixed a potential filename buffer overflow in osunixdir.c. Increased the 
 size of file structure. Colin Ian King.
 
 ----------------------------------------
 13 September 2012. Summary of changes for version 20120913:
 
 
 1) ACPICA Kernel-resident Subsystem:
 
 ACPI 5.0: Added two new notify types for the Hardware Error Notification 
 Structure within the Hardware Error Source Table (HEST) table -- CMCI(5) 
 and 
 MCE(6).
  
 Table Manager: Merged/removed duplicate code in the root table resize 
 functions. One function is external, the other is internal. Lv Zheng, 
 ACPICA 
 BZ 846.
 
 Makefiles: Completely removed the obsolete "Linux" makefiles under 
 acpica/generate/linux. These makefiles are obsolete and have been replaced 
 by 
 the generic unix makefiles under acpica/generate/unix.
 
 Makefiles: Ensure that binary files always copied properly. Minor rule 
 change 
 to ensure that the final binary output files are always copied up to the 
 appropriate binary directory (bin32 or bin64.)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.8K Code, 25.3K Data, 119.1K Total
     Debug Version:     175.7K Code, 74.8K Data, 250.5K Total
   Current Release:
     Non-Debug Version:  93.7K Code, 25.3K Data, 119.0K Total
     Debug Version:     175.0K Code, 74.4K Data, 249.4K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Fixed a possible fault during the disassembly of resource 
 descriptors when a second parse is required because of the invocation of 
 external control methods within the table. With assistance from 
 adq@lidskialf.net. ACPICA BZ 976.
 
 iASL: Fixed a namepath optimization problem. An error can occur if the 
 parse 
 node that contains the namepath to be optimized does not have a parent 
 node 
 that is a named object. This change fixes the problem.
 
 iASL: Fixed a regression where the AML file is not deleted on errors. The 
 AML 
 output file should be deleted if there are any errors during the compiler. 
 The 
 only exception is if the -f (force output) option is used. ACPICA BZ 974.
 
 iASL: Added a feature to automatically increase internal line buffer 
 sizes. 
 Via realloc(), automatically increase the internal line buffer sizes as 
 necessary to support very long source code lines. The current version of 
 the 
 preprocessor requires a buffer long enough to contain full source code 
 lines. 
 This change increases the line buffer(s) if the input lines go beyond the 
 current buffer size. This eliminates errors that occurred when a source 
 code 
 line was longer than the buffer.
 
 iASL: Fixed a problem with constant folding in method declarations. The 
 SyncLevel term is a ByteConstExpr, and incorrect code would be generated 
 if a 
 Type3 opcode was used.
 
 Debugger: Improved command help support. For incorrect argument count, 
 display 
 full help for the command. For help command itself, allow an argument to 
 specify a command.
 
 Test Suites: Several bug fixes for the ASLTS suite reduces the number of 
 errors during execution of the suite. Guan Chao.
 
 ----------------------------------------
 16 August 2012. Summary of changes for version 20120816:
 
 
 1) ACPICA Kernel-resident Subsystem:
 
 Removed all use of the deprecated _GTS and _BFS predefined methods. The 
 _GTS 
 (Going To Sleep) and _BFS (Back From Sleep) methods are essentially 
 deprecated and will probably be removed from the ACPI specification. 
 Windows 
 does not invoke them, and reportedly never will. The final nail in the 
 coffin 
 is that the ACPI specification states that these methods must be run with 
 interrupts off, which is not going to happen in a kernel interpreter. 
 Note: 
 Linux has removed all use of the methods also. It was discovered that 
 invoking these functions caused failures on some machines, probably 
 because 
 they were never tested since Windows does not call them. Affects two 
 external 
 interfaces, AcpiEnterSleepState and AcpiLeaveSleepStatePrep. Tang Feng. 
 ACPICA BZ 969.
 
 Implemented support for complex bit-packed buffers returned from the _PLD 
 (Physical Location of Device) predefined method. Adds a new external 
 interface, AcpiDecodePldBuffer that parses the buffer into a more usable C 
 structure. Note: C Bitfields cannot be used for this type of predefined 
 structure since the memory layout of individual bitfields is not defined 
 by 
 the C language. In addition, there are endian concerns where a compiler 
 will 
 change the bitfield ordering based on the machine type. The new ACPICA 
 interface eliminates these issues, and should be called after _PLD is 
 executed. ACPICA BZ 954.
 
 Implemented a change to allow a scope change to root (via "Scope (\)") 
 during 
 execution of module-level ASL code (code that is executed at table load 
 time.) Lin Ming.
 
 Added the Windows8/Server2012 string for the _OSI method. This change adds 
 a 
 new _OSI string, "Windows 2012" for both Windows 8 and Windows Server 
 2012.
 
 Added header support for the new ACPI tables DBG2 (Debug Port Table Type 
 2) 
 and CSRT (Core System Resource Table).
 
 Added struct header support for the _FDE, _GRT, _GTM, and _SRT predefined 
 names. This simplifies access to the buffers returned by these predefined 
 names. Adds a new file, include/acbuffer.h. ACPICA BZ 956.
 
 GPE support: Removed an extraneous parameter from the various low-level 
 internal GPE functions. Tang Feng.
 
 Removed the linux makefiles from the unix packages. The generate/linux 
 makefiles are obsolete and have been removed from the unix tarball release 
 packages. The replacement makefiles are under generate/unix, and there is 
 a 
 top-level makefile under the main acpica directory. ACPICA BZ 967, 912.
 
 Updates for Unix makefiles:
 1) Add -D_FORTIFY_SOURCE=2 for gcc generation. Arjan van de Ven.
 2) Update linker flags (move to end of command line) for AcpiExec utility. 
 Guan Chao.
 
 Split ACPICA initialization functions to new file, utxfinit.c. Split from 
 utxface.c to improve modularity and reduce file size.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.5K Code, 25.3K Data, 118.8K Total
     Debug Version:     173.7K Code, 74.0K Data, 247.7K Total
   Current Release:
     Non-Debug Version:  93.8K Code, 25.3K Data, 119.1K Total
     Debug Version:     175.7K Code, 74.8K Data, 250.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a problem with constant folding for fixed-length constant 
 expressions. The constant-folding code was not being invoked for constant 
 expressions that allow the use of type 3/4/5 opcodes to generate constants 
 for expressions such as ByteConstExpr, WordConstExpr, etc. This could 
 result 
 in the generation of invalid AML bytecode. ACPICA BZ 970.
 
 iASL: Fixed a generation issue on newer versions of Bison. Newer versions 
 apparently automatically emit some of the necessary externals. This change 
 handles these versions in order to eliminate generation warnings.
 
 Disassembler: Added support to decode the DBG2 and CSRT ACPI tables.
 
 Disassembler: Add support to decode _PLD buffers. The decoded buffer 
 appears 
 within comments in the output file.
 
 Debugger: Fixed a regression with the "Threads" command where 
 AE_BAD_PARAMETER was always returned.
 
 ----------------------------------------
 11 July 2012. Summary of changes for version 20120711:
 
 1) ACPICA Kernel-resident Subsystem:
 
 Fixed a possible fault in the return package object repair code. Fixes a 
 problem that can occur when a lone package object is wrapped with an outer 
 package object in order to force conformance to the ACPI specification. 
 Can 
 affect these predefined names: _ALR, _MLS, _PSS, _TRT, _TSS, _PRT, _HPX, 
 _DLM, 
 _CSD, _PSD, _TSD.
 
 Removed code to disable/enable bus master arbitration (ARB_DIS bit in the 
 PM2_CNT register) in the ACPICA sleep/wake interfaces. Management of the 
 ARB_DIS bit must be implemented in the host-dependent C3 processor power 
 state 
 support. Note, ARB_DIS is obsolete and only applies to older chipsets, 
 both 
 Intel and other vendors. (for Intel: ICH4-M and earlier)
 
 This change removes the code to disable/enable bus master arbitration 
 during 
 suspend/resume. Use of the ARB_DIS bit in the optional PM2_CNT register 
 causes 
 resume problems on some machines. The change has been in use for over 
 seven 
 years within Linux.
 
 Implemented two new external interfaces to support host-directed dynamic 
 ACPI 
 table load and unload. They are intended to simplify the host 
 implementation 
 of hot-plug support:
   AcpiLoadTable: Load an SSDT from a buffer into the namespace.
   AcpiUnloadParentTable: Unload an SSDT via a named object owned by the 
 table.
 See the ACPICA reference for additional details. Adds one new file, 
 components/tables/tbxfload.c
 
 Implemented and deployed two new interfaces for errors and warnings that 
 are 
 known to be caused by BIOS/firmware issues:
   AcpiBiosError: Prints "ACPI Firmware Error" message.
   AcpiBiosWarning: Prints "ACPI Firmware Warning" message.
 Deployed these new interfaces in the ACPICA Table Manager code for ACPI 
 table 
 and FADT errors. Additional deployment to be completed as appropriate in 
 the 
 future. The associated conditional macros are ACPI_BIOS_ERROR and 
 ACPI_BIOS_WARNING. See the ACPICA reference for additional details. ACPICA 
 BZ 
 843.
 
 Implicit notify support: ensure that no memory allocation occurs within a 
 critical region. This fix moves a memory allocation outside of the time 
 that a 
 spinlock is held. Fixes issues on systems that do not allow this behavior. 
 Jung-uk Kim.
 
 Split exception code utilities and tables into a new file, 
 utilities/utexcep.c
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.1K Code, 25.1K Data, 118.2K Total
     Debug Version:     172.9K Code, 73.6K Data, 246.5K Total
   Current Release:
     Non-Debug Version:  93.5K Code, 25.3K Data, 118.8K Total
     Debug Version:     173.7K Code, 74.0K Data, 247.7K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a parser problem for hosts where EOF is defined as -1 instead 
 of 
 0. Jung-uk Kim.
 
 Debugger: Enhanced the "tables" command to emit additional information 
 about 
 the current set of ACPI tables, including the owner ID and flags decode.
 
 Debugger: Reimplemented the "unload" command to use the new 
 AcpiUnloadParentTable external interface. This command was disable 
 previously 
 due to need for an unload interface.
 
 AcpiHelp: Added a new option to decode ACPICA exception codes. The -e 
 option 
 will decode 16-bit hex status codes (ACPI_STATUS) to name strings.
 
 ----------------------------------------
 20 June 2012. Summary of changes for version 20120620:
 
 
 1) ACPICA Kernel-resident Subsystem:
 
 Implemented support to expand the "implicit notify" feature to allow 
 multiple 
 devices to be notified by a single GPE. This feature automatically 
 generates a 
 runtime device notification in the absence of a BIOS-provided GPE control 
 method (_Lxx/_Exx) or a host-installed handler for the GPE. Implicit 
 notify is 
 provided by ACPICA for Windows compatibility, and is a workaround for BIOS 
 AML 
 code errors. See the description of the AcpiSetupGpeForWake interface in 
 the 
 APCICA reference. Bob Moore, Rafael Wysocki. ACPICA BZ 918.
 
 Changed some comments and internal function names to simplify and ensure 
 correctness of the Linux code translation. No functional changes.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.0K Code, 25.1K Data, 118.1K Total
     Debug Version:     172.7K Code, 73.6K Data, 246.3K Total
   Current Release:
     Non-Debug Version:  93.1K Code, 25.1K Data, 118.2K Total
     Debug Version:     172.9K Code, 73.6K Data, 246.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Added support to emit short, commented descriptions for the 
 ACPI 
 predefined names in order to improve the readability of the disassembled 
 output. ACPICA BZ 959. Changes include:
   1) Emit descriptions for all standard predefined names (_INI, _STA, 
 _PRW, 
 etc.)
   2) Emit generic descriptions for the special names (_Exx, _Qxx, etc.)
   3) Emit descriptions for the resource descriptor names (_MIN, _LEN, 
 etc.)
 
 AcpiSrc: Fixed several long-standing Linux code translation issues. 
 Argument 
 descriptions in function headers are now translated properly to lower case 
 and 
 underscores. ACPICA BZ 961. Also fixes translation problems such as these: 
 (old -> new)
   i_aSL -> iASL
   00-7_f -> 00-7F
   16_k -> 16K
   local_fADT -> local_FADT
   execute_oSI -> execute_OSI
 
 iASL: Fixed a problem where null bytes were inadvertently emitted into 
 some 
 listing files.
 
 iASL: Added the existing debug options to the standard help screen. There 
 are 
 no longer two different help screens. ACPICA BZ 957.
 
 AcpiHelp: Fixed some typos in the various predefined name descriptions. 
 Also 
 expand some of the descriptions where appropriate.
 
 iASL: Fixed the -ot option (display compile times/statistics). Was not 
 working 
 properly for standard output; only worked for the debug file case.
 
 ----------------------------------------
 18 May 2012. Summary of changes for version 20120518:
 
 
 1) ACPICA Core Subsystem:
 
 Added a new OSL interface, AcpiOsWaitEventsComplete. This interface is 
 defined 
 to block until asynchronous events such as notifies and GPEs have 
 completed. 
 Within ACPICA, it is only called before a notify or GPE handler is 
 removed/uninstalled. It also may be useful for the host OS within related 
 drivers such as the Embedded Controller driver. See the ACPICA reference 
 for 
 additional information. ACPICA BZ 868.
 
 ACPI Tables: Added a new error message for a possible overflow failure 
 during 
 the conversion of FADT 32-bit legacy register addresses to internal common 
 64-
 bit GAS structure representation. The GAS has a one-byte "bit length" 
 field, 
 thus limiting the register length to 255 bits. ACPICA BZ 953.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  92.9K Code, 25.0K Data, 117.9K Total
     Debug Version:     172.6K Code, 73.4K Data, 246.0K Total
   Current Release:
     Non-Debug Version:  93.0K Code, 25.1K Data, 118.1K Total
     Debug Version:     172.7K Code, 73.6K Data, 246.3K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Added the ACPI 5.0 "PCC" keyword for use in the Register() ASL 
 macro. 
 This keyword was added late in the ACPI 5.0 release cycle and was not 
 implemented until now.
 
 Disassembler: Added support for Operation Region externals. Adds missing 
 support for operation regions that are defined in another table, and 
 referenced locally via a Field or BankField ASL operator. Now generates 
 the 
 correct External statement.
 
 Disassembler: Several additional fixes for the External() statement 
 generation 
 related to some ASL operators. Also, order the External() statements 
 alphabetically in the disassembler output. Fixes the External() generation 
 for 
 the Create* field, Alias, and Scope operators:
  1) Create* buffer field operators - fix type mismatch warning on 
 disassembly
  2) Alias - implement missing External support
  3) Scope - fix to make sure all necessary externals are emitted.
 
 iASL: Improved pathname support. For include files, merge the prefix 
 pathname 
 with the file pathname and eliminate unnecessary components. Convert 
 backslashes in all pathnames to forward slashes, for readability. Include 
 file 
 pathname changes affect both #include and Include() type operators.
 
 iASL/DTC/Preprocessor: Gracefully handle early EOF. Handle an EOF at the 
 end 
 of a valid line by inserting a newline and then returning the EOF during 
 the 
 next call to GetNextLine. Prevents the line from being ignored due to EOF 
 condition.
 
 iASL: Implemented some changes to enhance the IDE support (-vi option.) 
 Error 
 and Warning messages are now correctly recognized for both the source code 
 browser and the global error and warning counts.
 
 ----------------------------------------
 20 April 2012. Summary of changes for version 20120420:
 
 
 1) ACPICA Core Subsystem:
 
 Implemented support for multiple notify handlers. This change adds support 
 to 
 allow multiple system and device notify handlers on Device, Thermal Zone, 
 and 
 Processor objects. This can simplify the host OS notification 
 implementation. 
 Also re-worked and restructured the entire notify support code to simplify 
 handler installation, handler removal, notify event queuing, and notify 
 dispatch to handler(s). Note: there can still only be two global notify 
 handlers - one for system notifies and one for device notifies. There are 
 no 
 changes to the existing handler install/remove interfaces. Lin Ming, Bob 
 Moore, Rafael Wysocki.
 
 Fixed a regression in the package repair code where the object reference 
 count was calculated incorrectly. Regression was introduced in the commit 
 "Support to add Package wrappers".
 
 Fixed a couple possible memory leaks in the AML parser, in the error 
 recovery 
 path. Jesper Juhl, Lin Ming.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  92.9K Code, 25.0K Data, 117.9K Total
     Debug Version:     172.5K Code, 73.2K Data, 245.7K Total
   Current Release:
     Non-Debug Version:  92.9K Code, 25.0K Data, 117.9K Total
     Debug Version:     172.6K Code, 73.4K Data, 246.0K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a problem with the resource descriptor support where the 
 length 
 of the StartDependentFn and StartDependentFnNoPrio descriptors were not 
 included in cumulative descriptor offset, resulting in incorrect values 
 for 
 resource tags within resource descriptors appearing after a 
 StartDependent* 
 descriptor. Reported by Petr Vandrovec. ACPICA BZ 949.
 
 iASL and Preprocessor: Implemented full support for the #line directive to 
 correctly track original source file line numbers through the .i 
 preprocessor 
 output file - for error and warning messages.
 
 iASL: Expand the allowable byte constants for address space IDs. 
 Previously, 
 the allowable range was 0x80-0xFF (user-defined spaces), now the range is 
 0x0A-0xFF to allow for custom and new IDs without changing the compiler.
 
 iASL: Add option to treat all warnings as errors (-we). ACPICA BZ 948.
 
 iASL: Add option to completely disable the preprocessor (-Pn).
 
 iASL: Now emit all error/warning messages to standard error (stderr) by 
 default (instead of the previous stdout).
 
 ASL Test Suite (ASLTS): Reduce iASL warnings due to use of Switch(). 
 Update 
 for resource descriptor offset fix above. Update/cleanup error output 
 routines. Enable and send iASL errors/warnings to an error logfile 
 (error.txt). Send all other iASL output to a logfile (compiler.txt). Fixed 
 several extraneous "unrecognized operator" messages.
 
 ----------------------------------------
 20 March 2012. Summary of changes for version 20120320:
 
 
 1) ACPICA Core Subsystem:
 
 Enhanced the sleep/wake interfaces to optionally execute the _GTS method 
 (Going To Sleep) and the _BFS method (Back From Sleep). Windows apparently 
 does not execute these methods, and therefore these methods are often 
 untested. It has been seen on some systems where the execution of these 
 methods causes errors and also prevents the machine from entering S5. It 
 is 
 therefore suggested that host operating systems do not execute these 
 methods 
 by default. In the future, perhaps these methods can be optionally 
 executed 
 based on the age of the system and/or what is the newest version of 
 Windows 
 that the BIOS asks for via _OSI. Changed interfaces: AcpiEnterSleepState 
 and 
 AcpileaveSleepStatePrep. See the ACPICA reference and Linux BZ 13041. Lin 
 Ming.
 
 Fixed a problem where the length of the local/common FADT was set too 
 early. 
 The local FADT table length cannot be set to the common length until the 
 original length has been examined. There is code that checks the table 
 length 
 and sets various fields appropriately. This can affect older machines with 
 early FADT versions. For example, this can cause inadvertent writes to the 
 CST_CNT register. Julian Anastasov.
 
 Fixed a mapping issue related to a physical table override. Use the 
 deferred 
 mapping mechanism for tables loaded via the physical override OSL 
 interface. 
 This allows for early mapping before the virtual memory manager is 
 available. 
 Thomas Renninger, Bob Moore.
 
 Enhanced the automatic return-object repair code: Repair a common problem 
 with 
 predefined methods that are defined to return a variable-length Package of 
 sub-objects. If there is only one sub-object, some BIOS ASL code 
 mistakenly 
 simply returns the single object instead of a Package with one sub-object. 
 This new support will repair this error by wrapping a Package object 
 around 
 the original object, creating the correct and expected Package with one 
 sub-
 object. Names that can be repaired in this manner include: _ALR, _CSD, 
 _HPX, 
 _MLS, _PLD, _PRT, _PSS, _TRT, _TSS, _BCL, _DOD, _FIX, and _Sx. ACPICA BZ 
 939.
 
 Changed the exception code returned for invalid ACPI paths passed as 
 parameters to external interfaces such as AcpiEvaluateObject. Was 
 AE_BAD_PARAMETER, now is the more sensible AE_BAD_PATHNAME.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  93.0K Code, 25.0K Data, 118.0K Total
     Debug Version:     172.5K Code, 73.2K Data, 245.7K Total
   Current Release:
     Non-Debug Version:  92.9K Code, 25.0K Data, 117.9K Total
     Debug Version:     172.5K Code, 73.2K Data, 245.7K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Added the infrastructure and initial implementation of a integrated 
 C-
 like preprocessor. This will simplify BIOS development process by 
 eliminating 
 the need for a separate preprocessing step during builds. On Windows, it 
 also 
 eliminates the need to install a separate C compiler. ACPICA BZ 761. Some 
 features including full #define() macro support are still under 
 development. 
 These preprocessor directives are supported:
     #define
     #elif
     #else
     #endif
     #error
     #if
     #ifdef
     #ifndef
     #include
     #pragma message
     #undef
     #warning
 In addition, these new command line options are supported:
     -D  Define symbol for preprocessor use
     -li         Create preprocessed output file (*.i)
     -P          Preprocess only and create preprocessor output file (*.i)
 
 Table Compiler: Fixed a problem where the equals operator within an 
 expression 
 did not work properly.
 
 Updated iASL to use the current versions of Bison/Flex. Updated the 
 Windows 
 project file to invoke these tools from the standard location. ACPICA BZ 
 904. 
 Versions supported:
     Flex for Windows:  V2.5.4
     Bison for Windows: V2.4.1
 
 ----------------------------------------
 15 February 2012. Summary of changes for version 20120215:
 
 
 1) ACPICA Core Subsystem:
 
 There have been some major changes to the sleep/wake support code, as 
 described below (a - e).
 
 a) The AcpiLeaveSleepState has been split into two interfaces, similar to 
 AcpiEnterSleepStatePrep and AcpiEnterSleepState. The new interface is 
 AcpiLeaveSleepStatePrep. This allows the host to perform actions between 
 the 
 time the _BFS method is called and the _WAK method is called. NOTE: all 
 hosts 
 must update their wake/resume code or else sleep/wake will not work 
 properly. 
 Rafael Wysocki.
 
 b) In AcpiLeaveSleepState, now enable all runtime GPEs before calling the 
 _WAK 
 method. Some machines require that the GPEs are enabled before the _WAK 
 method 
 is executed. Thomas Renninger.
 
 c) In AcpiLeaveSleepState, now always clear the WAK_STS (wake status) bit. 
 Some BIOS code assumes that WAK_STS will be cleared on resume and use it 
 to 
 determine whether the system is rebooting or resuming. Matthew Garrett.
 
 d) Move the invocations of _GTS (Going To Sleep) and _BFS (Back From 
 Sleep) to 
 match the ACPI specification requirement. Rafael Wysocki.
 
 e) Implemented full support for the ACPI 5.0 SleepStatus and SleepControl 
 registers within the V5 FADT. This support adds two new files: 
 hardware/hwesleep.c implements the support for the new registers. Moved 
 all 
 sleep/wake external interfaces to hardware/hwxfsleep.c.
 
 
 Added a new OSL interface for ACPI table overrides, 
 AcpiOsPhysicalTableOverride. This interface allows the host to override a 
 table via a physical address, instead of the logical address required by 
 AcpiOsTableOverride. This simplifies the host implementation. Initial 
 implementation by Thomas Renninger. The ACPICA implementation creates a 
 single 
 shared function for table overrides that attempts both a logical and a 
 physical override.
 
 Expanded the OSL memory read/write interfaces to 64-bit data 
 (AcpiOsReadMemory, AcpiOsWriteMemory.) This enables full 64-bit memory 
 transfer support for GAS register structures passed to AcpiRead and 
 AcpiWrite.
 
 Implemented the ACPI_REDUCED_HARDWARE option to allow the creation of a 
 custom 
 build of ACPICA that supports only the ACPI 5.0 reduced hardware (SoC) 
 model. 
 See the ACPICA reference for details. ACPICA BZ 942. This option removes 
 about 
 10% of the code and 5% of the static data, and the following hardware ACPI 
 features become unavailable:
     PM Event and Control registers
     SCI interrupt (and handler)
     Fixed Events
     General Purpose Events (GPEs)
     Global Lock
     ACPI PM timer
     FACS table (Waking vectors and Global Lock)
 
 Updated the unix tarball directory structure to match the ACPICA git 
 source 
 tree. This ensures that the generic unix makefiles work properly (in 
 generate/unix).  Also updated the Linux makefiles to match. ACPICA BZ 867.
 
 Updated the return value of the _REV predefined method to integer value 5 
 to 
 reflect ACPI 5.0 support.
 
 Moved the external ACPI PM timer interface prototypes to the public 
 acpixf.h 
 file where they belong.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  92.8K Code, 24.9K Data, 117.7K Total
     Debug Version:     171.7K Code, 72.9K Data, 244.5K Total
   Current Release:
     Non-Debug Version:  93.0K Code, 25.0K Data, 118.0K Total
     Debug Version:     172.5K Code, 73.2K Data, 245.7K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Fixed a problem with the new ACPI 5.0 serial resource 
 descriptors (I2C, SPI, UART) where the resource produce/consumer bit was 
 incorrectly displayed.
 
 AcpiHelp: Add display of ACPI/PNP device IDs that are defined in the ACPI 
 specification.
 
 ----------------------------------------
 11 January 2012. Summary of changes for version 20120111:
 
 
 1) ACPICA Core Subsystem:
 
 Implemented a new mechanism to allow host device drivers to check for 
 address 
 range conflicts with ACPI Operation Regions. Both SystemMemory and 
 SystemIO 
 address spaces are supported. A new external interface, 
 AcpiCheckAddressRange, 
 allows drivers to check an address range against the ACPI namespace. See 
 the 
 ACPICA reference for additional details. Adds one new file, 
 utilities/utaddress.c. Lin Ming, Bob Moore.
 
 Fixed several issues with the ACPI 5.0 FADT support: Add the sleep Control 
 and 
 Status registers, update the ACPI 5.0 flags, and update internal data 
 structures to handle an FADT larger than 256 bytes. The size of the ACPI 
 5.0 
 FADT is 268 bytes.
 
 Updated all ACPICA copyrights and signons to 2012. Added the 2012 
 copyright to 
 all module headers and signons, including the standard Linux header. This 
 affects virtually every file in the ACPICA core subsystem, iASL compiler, 
 and 
 all ACPICA utilities.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release:
     Non-Debug Version:  92.3K Code, 24.9K Data, 117.2K Total
     Debug Version:     170.8K Code, 72.6K Data, 243.4K Total
   Current Release:
     Non-Debug Version:  92.8K Code, 24.9K Data, 117.7K Total
     Debug Version:     171.7K Code, 72.9K Data, 244.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: fixed a problem with the automatic resource tag generation 
 support. Fixes a problem where the resource tags are inadvertently not 
 constructed if the table being disassembled contains external references 
 to 
 control methods. Moved the actual construction of the tags to after the 
 final 
 namespace is constructed (after 2nd parse is invoked due to external 
 control 
 method references.) ACPICA BZ 941.
 
 Table Compiler: Make all "generic" operators caseless. These are the 
 operators 
 like UINT8, String, etc. Making these caseless improves ease-of-use. 
 ACPICA BZ 
 934.
 
 ----------------------------------------
 23 November 2011. Summary of changes for version 20111123:
 
 0) ACPI 5.0 Support:
 
 This release contains full support for the ACPI 5.0 specification, as 
 summarized below.
 
 Reduced Hardware Support:
 -------------------------
 
 This support allows for ACPI systems without the usual ACPI hardware. This 
 support is enabled by a flag in the revision 5 FADT. If it is set, ACPICA 
 will 
 not attempt to initialize or use any of the usual ACPI hardware. Note, 
 when 
 this flag is set, all of the following ACPI hardware is assumed to be not 
 present and is not initialized or accessed:
 
     General Purpose Events (GPEs)
     Fixed Events (PM1a/PM1b and PM Control)
     Power Management Timer and Console Buttons (power/sleep)
     Real-time Clock Alarm
     Global Lock
     System Control Interrupt (SCI)
     The FACS is assumed to be non-existent
 
 ACPI Tables:
 ------------
 
 All new tables and updates to existing tables are fully supported in the 
 ACPICA headers (for use by device drivers), the disassembler, and the iASL 
 Data Table Compiler. ACPI 5.0 defines these new tables:
 
     BGRT        /* Boot Graphics Resource Table */
     DRTM        /* Dynamic Root of Trust for Measurement table */
     FPDT        /* Firmware Performance Data Table */
     GTDT        /* Generic Timer Description Table */
     MPST        /* Memory Power State Table */
     PCCT        /* Platform Communications Channel Table */
     PMTT        /* Platform Memory Topology Table */
     RASF        /* RAS Feature table */
 
 Operation Regions/SpaceIDs:
 ---------------------------
 
 All new operation regions are fully supported by the iASL compiler, the 
 disassembler, and the ACPICA runtime code (for dispatch to region 
 handlers.) 
 The new operation region Space IDs are:
 
     GeneralPurposeIo
     GenericSerialBus
 
 Resource Descriptors:
 ---------------------
 
 All new ASL resource descriptors are fully supported by the iASL compiler, 
 the 
 ASL/AML disassembler, and the ACPICA runtime Resource Manager code 
 (including 
 all new predefined resource tags). New descriptors are:
 
     FixedDma
     GpioIo
     GpioInt
     I2cSerialBus
     SpiSerialBus
     UartSerialBus
 
 ASL/AML Operators, New and Modified:
 ------------------------------------
 
 One new operator is added, the Connection operator, which is used to 
 associate 
 a GeneralPurposeIo or GenericSerialBus resource descriptor with individual 
 field objects within an operation region. Several new protocols are 
 associated 
 with the AccessAs operator. All are fully supported by the iASL compiler, 
 disassembler, and runtime ACPICA AML interpreter:
 
     Connection                      // Declare Field Connection attributes
     AccessAs: AttribBytes (n)           // Read/Write N-Bytes Protocol
     AccessAs: AttribRawBytes (n)        // Raw Read/Write N-Bytes Protocol
     AccessAs: AttribRawProcessBytes (n) // Raw Process Call Protocol
     RawDataBuffer                       // Data type for Vendor Data 
 fields
 
 Predefined ASL/AML Objects:
 ---------------------------
 
 All new predefined objects/control-methods are supported by the iASL 
 compiler 
 and the ACPICA runtime validation/repair (arguments and return values.) 
 New 
 predefined names include the following:
 
 Standard Predefined Names (Objects or Control Methods):
     _AEI, _CLS, _CPC, _CWS, _DEP,
     _DLM, _EVT, _GCP, _CRT, _GWS,
     _HRV, _PRE, _PSE, _SRT, _SUB.
 
 Resource Tags (Names used to access individual fields within resource 
 descriptors):
     _DBT, _DPL, _DRS, _END, _FLC,
     _IOR, _LIN, _MOD, _PAR, _PHA,
     _PIN, _PPI, _POL, _RXL, _SLV,
     _SPE, _STB, _TXL, _VEN.
 
 ACPICA External Interfaces:
 ---------------------------
 
 Several new interfaces have been defined for use by ACPI-related device 
 drivers and other host OS services:
 
 AcpiAcquireMutex and AcpiReleaseMutex: These interfaces allow the host OS 
 to 
 acquire and release AML mutexes that are defined in the DSDT/SSDT tables 
 provided by the BIOS. They are intended to be used in conjunction with the 
 ACPI 5.0 _DLM (Device Lock Method) in order to provide transaction-level 
 mutual exclusion with the AML code/interpreter.
 
 AcpiGetEventResources: Returns the (formatted) resource descriptors as 
 defined 
 by the ACPI 5.0 _AEI object (ACPI Event Information).  This object 
 provides 
 resource descriptors associated with hardware-reduced platform events, 
 similar 
 to the AcpiGetCurrentResources interface.
 
 Operation Region Handlers: For General Purpose IO and Generic Serial Bus 
 operation regions, information about the Connection() object and any 
 optional 
 length information is passed to the region handler within the Context 
 parameter.
 
 AcpiBufferToResource: This interface converts a raw AML buffer containing 
 a 
 resource template or resource descriptor to the ACPI_RESOURCE internal 
 format 
 suitable for use by device drivers. Can be used by an operation region 
 handler 
 to convert the Connection() buffer object into a ACPI_RESOURCE.
 
 Miscellaneous/Tools/TestSuites: 
 -------------------------------
 
 Support for extended _HID names (Four alpha characters instead of three).
 Support for ACPI 5.0 features in the AcpiExec and AcpiHelp utilities.
 Support for ACPI 5.0 features in the ASLTS test suite.
 Fully updated documentation (ACPICA and iASL reference documents.)
 
 ACPI Table Definition Language:
 -------------------------------
 
 Support for this language was implemented and released as a subsystem of 
 the 
 iASL compiler in 2010. (See the iASL compiler User Guide.)
 
 
 Non-ACPI 5.0 changes for this release:
 --------------------------------------
 
 1) ACPICA Core Subsystem:
 
 Fix a problem with operation region declarations where a failure can occur 
 if 
 the region name and an argument that evaluates to an object (such as the 
 region address) are in different namespace scopes. Lin Ming, ACPICA BZ 
 937.
 
 Do not abort an ACPI table load if an invalid space ID is found within. 
 This 
 will be caught later if the offending method is executed. ACPICA BZ 925.
 
 Fixed an issue with the FFixedHW space ID where the ID was not always 
 recognized properly (Both ACPICA and iASL). ACPICA BZ 926.
 
 Fixed a problem with the 32-bit generation of the unix-specific OSL 
 (osunixxf.c). Lin Ming, ACPICA BZ 936.
 
 Several changes made to enable generation with the GCC 4.6 compiler. 
 ACPICA BZ 
 935.
 
 New error messages: Unsupported I/O requests (not 8/16/32 bit), and 
 Index/Bank 
 field registers out-of-range.
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented the __PATH__ operator, which returns the full pathname 
 of 
 the current source file.
 
 AcpiHelp: Automatically display expanded keyword information for all ASL 
 operators.
 
 Debugger: Add "Template" command to disassemble/dump resource template 
 buffers.
 
 Added a new master script to generate and execute the ASLTS test suite. 
 Automatically handles 32- and 64-bit generation. See tests/aslts.sh
 
 iASL: Fix problem with listing generation during processing of the 
 Switch() 
 operator where AML listing was disabled until the entire Switch block was 
 completed.
 
 iASL: Improve support for semicolon statement terminators. Fix "invalid 
 character" message for some cases when the semicolon is used. Semicolons 
 are 
 now allowed after every  grammar element. ACPICA BZ 927.
 
 iASL: Fixed some possible aliasing warnings during generation. ACPICA BZ 
 923.
 
 Disassembler: Fix problem with disassembly of the DataTableRegion operator 
 where an inadvertent "Unhandled deferred opcode" message could be 
 generated.
 
 3) Example Code and Data Size
 
 These are the sizes for the OS-independent acpica.lib produced by the 
 Microsoft Visual C++ 9.0 32-bit compiler. The debug version of the code 
 includes the debug output trace mechanism and has a much larger code and 
 data 
 size.
 
   Previous Release:
     Non-Debug Version:  90.2K Code, 23.9K Data, 114.1K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
   Current Release:
     Non-Debug Version:  92.3K Code, 24.9K Data, 117.2K Total
     Debug Version:     170.8K Code, 72.6K Data, 243.4K Total
 
 ----------------------------------------
 22 September 2011. Summary of changes for version 20110922:
 
 0) ACPI 5.0 News:
 
 Support for ACPI 5.0 in ACPICA has been underway for several months and 
 will 
 be released at the same time that ACPI 5.0 is officially released.
 
 The ACPI 5.0 specification is on track for release in the next few months.
  
 1) ACPICA Core Subsystem:
 
 Fixed a problem where the maximum sleep time for the Sleep() operator was 
 intended to be limited to two seconds, but was inadvertently limited to 20 
 seconds instead.
 
 Linux and Unix makefiles: Added header file dependencies to ensure correct 
 generation of ACPICA core code and utilities. Also simplified the 
 makefiles 
 considerably through the use of the vpath variable to specify search 
 paths. 
 ACPICA BZ 924.
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented support to check the access length for all fields 
 created to 
 access named Resource Descriptor fields. For example, if a resource field 
 is 
 defined to be two bits, a warning is issued if a CreateXxxxField() is used 
 with an incorrect bit length. This is implemented for all current resource 
 descriptor names. ACPICA BZ 930.
   
 Disassembler: Fixed a byte ordering problem with the output of 24-bit and 
 56-
 bit integers.
 
 iASL: Fixed a couple of issues associated with variable-length package 
 objects. 1) properly handle constants like One, Ones, Zero -- do not make 
 a 
 VAR_PACKAGE when these are used as a package length. 2) Allow the 
 VAR_PACKAGE 
 opcode (in addition to PACKAGE) when validating object types for 
 predefined 
 names.
 
 iASL: Emit statistics for all output files (instead of just the ASL input 
 and 
 AML output). Includes listings, hex files, etc.
 
 iASL: Added -G option to the table compiler to allow the compilation of 
 custom 
 ACPI tables. The only part of a table that is required is the standard 36-
 byte 
 ACPI header.
 
 AcpiXtract: Ported to the standard ACPICA environment (with ACPICA 
 headers), 
 which also adds correct 64-bit support. Also, now all output filenames are 
 completely lower case.
 
 AcpiExec: Ignore any non-AML tables (tables other than DSDT or SSDT) when 
 loading table files. A warning is issued for any such tables. The only 
 exception is an FADT. This also fixes a possible fault when attempting to 
 load 
 non-AML tables. ACPICA BZ 932.
 
 AcpiHelp: Added the AccessAs and Offset operators. Fixed a problem where a 
 missing table terminator could cause a fault when using the -p option.
 
 AcpiSrc: Fixed a possible divide-by-zero fault when generating file 
 statistics.
 
 3) Example Code and Data Size
 
 These are the sizes for the OS-independent acpica.lib produced by the 
 Microsoft Visual C++ 9.0 32-bit compiler. The debug version of the code 
 includes the debug output trace mechanism and has a much larger code and 
 data 
 size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  90.2K Code, 23.9K Data, 114.1K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
   Current Release (VC 9.0):
     Non-Debug Version:  90.2K Code, 23.9K Data, 114.1K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
 
 
 ----------------------------------------
 23 June 2011. Summary of changes for version 20110623:
 
 1) ACPI CA Core Subsystem:
 
 Updated the predefined name repair mechanism to not attempt repair of a 
 _TSS 
 return object if a _PSS object is present. We can only sort the _TSS 
 return 
 package if there is no _PSS within the same scope. This is because if _PSS 
 is 
 present, the ACPI specification dictates that the _TSS Power Dissipation 
 field 
 is to be ignored, and therefore some BIOSs leave garbage values in the 
 _TSS 
 Power field(s). In this case, it is best to just return the _TSS package 
 as-
 is. Reported by, and fixed with assistance from Fenghua Yu.
 
 Added an option to globally disable the control method return value 
 validation 
 and repair. This runtime option can be used to disable return value repair 
 if 
 this is causing a problem on a particular machine. Also added an option to 
 AcpiExec (-dr) to set this disable flag.
 
 All makefiles and project files: Major changes to improve generation of 
 ACPICA 
 tools. ACPICA BZ 912:
     Reduce default optimization levels to improve compatibility
     For Linux, add strict-aliasing=0 for gcc 4
     Cleanup and simplify use of command line defines
     Cleanup multithread library support
     Improve usage messages
 
 Linux-specific header: update handling of THREAD_ID and pthread. For the 
 32-
 bit case, improve casting to eliminate possible warnings, especially with 
 the 
 acpica tools.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  90.1K Code, 23.9K Data, 114.0K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
   Current Release (VC 9.0):
     Non-Debug Version:  90.2K Code, 23.9K Data, 114.1K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 With this release, a new utility named "acpihelp" has been added to the 
 ACPICA 
 package. This utility summarizes the ACPI specification chapters for the 
 ASL 
 and AML languages. It generates under Linux/Unix as well as Windows, and 
 provides the following functionality:
     Find/display ASL operator(s) -- with description and syntax.
     Find/display ASL keyword(s) -- with exact spelling and descriptions.
     Find/display ACPI predefined name(s) -- with description, number
         of arguments, and the return value data type.
     Find/display AML opcode name(s) -- with opcode, arguments, and 
 grammar.
     Decode/display AML opcode -- with opcode name, arguments, and grammar.
 
 Service Layers: Make multi-thread support configurable. Conditionally 
 compile 
 the multi-thread support so that threading libraries will not be linked if 
 not 
 necessary. The only tool that requires multi-thread support is AcpiExec.
 
 iASL: Update yyerrror/AslCompilerError for "const" errors. Newer versions 
 of 
 Bison appear to want the interface to yyerror to be a const char * (or at 
 least this is a problem when generating iASL on some systems.) ACPICA BZ 
 923 
 Pierre Lejeune.
 
 Tools: Fix for systems where O_BINARY is not defined. Only used for 
 Windows 
 versions of the tools.
 
 ----------------------------------------
 27 May 2011. Summary of changes for version 20110527:
 
 1) ACPI CA Core Subsystem:
 
 ASL Load() operator: Reinstate most restrictions on the incoming ACPI 
 table 
 signature. Now, only allow SSDT, OEMx, and a null signature. History:
     1) Originally, we checked the table signature for "SSDT" or "PSDT".
        (PSDT is now obsolete.)
     2) We added support for OEMx tables, signature "OEM" plus a fourth
        "don't care" character.
     3) Valid tables were encountered with a null signature, so we just
        gave up on validating the signature, (05/2008).
     4) We encountered non-AML tables such as the MADT, which caused
        interpreter errors and kernel faults. So now, we once again allow
        only SSDT, OEMx, and now, also a null signature. (05/2011).
 
 Added the missing _TDL predefined name to the global name list in order to 
 enable validation. Affects both the core ACPICA code and the iASL 
 compiler.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug 
 version of the code includes the debug output trace mechanism and has a 
 much 
 larger code and data size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  90.0K Code, 23.8K Data, 113.8K Total
     Debug Version:     164.5K Code, 68.0K Data, 232.5K Total
   Current Release (VC 9.0):
     Non-Debug Version:  90.1K Code, 23.9K Data, 114.0K Total
     Debug Version:     165.6K Code, 68.4K Data, 234.0K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Debugger/AcpiExec: Implemented support for "complex" method arguments on 
 the 
 debugger command line. This adds support beyond simple integers -- 
 including 
 Strings, Buffers, and Packages. Includes support for nested packages. 
 Increased the default command line buffer size to accommodate these 
 arguments. 
 See the ACPICA reference for details and syntax. ACPICA BZ 917.
  
 Debugger/AcpiExec: Implemented support for "default" method arguments for 
 the 
 Execute/Debug command. Now, the debugger will always invoke a control 
 method 
 with the required number of arguments -- even if the command line 
 specifies 
 none or insufficient arguments. It uses default integer values for any 
 missing 
 arguments. Also fixes a bug where only six method arguments maximum were 
 supported instead of the required seven.
 
 Debugger/AcpiExec: Add a maximum buffer length parameter to AcpiOsGetLine 
 and 
 also return status in order to prevent buffer overruns. See the ACPICA 
 reference for details and syntax. ACPICA BZ 921
 
 iASL: Cleaned up support for Berkeley yacc. A general cleanup of code and 
 makefiles to simplify support for the two different but similar parser 
 generators, bison and yacc.
 
 Updated the generic unix makefile for gcc 4. The default gcc version is 
 now 
 expected to be 4 or greater, since options specific to gcc 4 are used.
 
 ----------------------------------------
 13 April 2011. Summary of changes for version 20110413:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support to execute a so-called "orphan" _REG method under the 
 EC 
 device. This change will force the execution of a _REG method underneath 
 the 
 EC 
 device even if there is no corresponding operation region of type 
 EmbeddedControl. Fixes a problem seen on some machines and apparently is 
 compatible with Windows behavior. ACPICA BZ 875.
 
 Added more predefined methods that are eligible for automatic NULL package 
 element removal. This change adds another group of predefined names to the 
 list 
 of names that can be repaired by having NULL package elements dynamically 
 removed. This group are those methods that return a single variable-length 
 package containing simple data types such as integers, buffers, strings. 
 This 
 includes: _ALx, _BCL, _CID,_ DOD, _EDL, _FIX, _PCL, _PLD, _PMD, _PRx, 
 _PSL, 
 _Sx, 
 and _TZD. ACPICA BZ 914.
 
 Split and segregated all internal global lock functions to a new file, 
 evglock.c.
 
 Updated internal address SpaceID for DataTable regions. Moved this 
 internal 
 space 
 id in preparation for ACPI 5.0 changes that will include some new space 
 IDs. 
 This 
 change should not affect user/host code.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib 
 produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug 
 version of 
 the code includes the debug output trace mechanism and has a much larger 
 code 
 and 
 data size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  89.8K Code, 23.8K Data, 113.6K Total
     Debug Version:     164.2K Code, 67.9K Data, 232.1K Total
   Current Release (VC 9.0):
     Non-Debug Version:  90.0K Code, 23.8K Data, 113.8K Total
     Debug Version:     164.5K Code, 68.0K Data, 232.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL/DTC: Major update for new grammar features. Allow generic data types 
 in 
 custom ACPI tables. Field names are now optional. Any line can be split to 
 multiple lines using the continuation char (\). Large buffers now use 
 line-
 continuation character(s) and no colon on the continuation lines. See the 
 grammar 
 update in the iASL compiler reference. ACPI BZ 910,911. Lin Ming, Bob 
 Moore.
 
 iASL: Mark ASL "Return()" and the simple "Return" as "Null" return 
 statements. 
 Since the parser stuffs a "zero" as the return value for these statements 
 (due 
 to 
 the underlying AML grammar), they were seen as "return with value" by the 
 iASL 
 semantic checking. They are now seen correctly as "null" return 
 statements.
 
 iASL: Check if a_REG declaration has a corresponding Operation Region. 
 Adds a 
 check for each _REG to ensure that there is in fact a corresponding 
 operation 
 region declaration in the same scope. If not, the _REG method is not very 
 useful 
 since it probably won't be executed. ACPICA BZ 915.
 
 iASL/DTC: Finish support for expression evaluation. Added a new expression 
 parser 
 that implements c-style operator precedence and parenthesization. ACPICA 
 bugzilla 
 908.
 
 Disassembler/DTC: Remove support for () and <> style comments in data 
 tables. 
 Now 
 that DTC has full expression support, we don't want to have comment 
 strings 
 that 
 start with a parentheses or a less-than symbol. Now, only the standard /* 
 and 
 // 
 comments are supported, as well as the bracket [] comments.
 
 AcpiXtract: Fix for RSDP and dynamic SSDT extraction. These tables have 
 "unusual" 
 headers in the acpidump file. Update the header validation to support 
 these 
 tables. Problem introduced in previous AcpiXtract version in the change to 
 support "wrong checksum" error messages emitted by acpidump utility.
 
 iASL: Add a * option to generate all template files (as a synonym for ALL) 
 as 
 in 
 "iasl -T *" or "iasl -T ALL".
 
 iASL/DTC: Do not abort compiler on fatal errors. We do not want to 
 completely 
 abort the compiler on "fatal" errors, simply should abort the current 
 compile. 
 This allows multiple compiles with a single (possibly wildcard) compiler 
 invocation.
 
 ----------------------------------------
 16 March 2011. Summary of changes for version 20110316:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem caused by a _PRW method appearing at the namespace root 
 scope 
 during the setup of wake GPEs. A fault could occur if a _PRW directly 
 under 
 the 
 root object was passed to the AcpiSetupGpeForWake interface. Lin Ming.
 
 Implemented support for "spurious" Global Lock interrupts. On some 
 systems, a 
 global lock interrupt can occur without the pending flag being set. Upon a 
 GL 
 interrupt, we now ensure that a thread is actually waiting for the lock 
 before 
 signaling GL availability. Rafael Wysocki, Bob Moore.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib 
 produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug 
 version of 
 the code includes the debug output trace mechanism and has a much larger 
 code 
 and 
 data size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  89.7K Code, 23.7K Data, 113.4K Total
     Debug Version:     163.9K Code, 67.5K Data, 231.4K Total
   Current Release (VC 9.0):
     Non-Debug Version:  89.8K Code, 23.8K Data, 113.6K Total
     Debug Version:     164.2K Code, 67.9K Data, 232.1K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented full support for the "SLIC" ACPI table. Includes support in 
 the 
 header files, disassembler, table compiler, and template generator. Bob 
 Moore, 
 Lin Ming.
 
 AcpiXtract: Correctly handle embedded comments and messages from AcpiDump. 
 Apparently some or all versions of acpidump will occasionally emit a 
 comment 
 like 
 "Wrong checksum", etc., into the dump file. This was causing problems for 
 AcpiXtract. ACPICA BZ 905.
 
 iASL: Fix the Linux makefile by removing an inadvertent double file 
 inclusion. 
 ACPICA BZ 913.
 
 AcpiExec: Update installation of operation region handlers. Install one 
 handler 
 for a user-defined address space. This is used by the ASL test suite 
 (ASLTS).
 
 ----------------------------------------
 11 February 2011. Summary of changes for version 20110211:
 
 1) ACPI CA Core Subsystem:
 
 Added a mechanism to defer _REG methods for some early-installed handlers. 
 Most user handlers should be installed before call to AcpiEnableSubsystem. 
 However, Event handlers and region handlers should be installed after 
 AcpiInitializeObjects. Override handlers for the "default" regions should 
 be 
 installed early, however. This change executes all _REG methods for the 
 default regions (Memory/IO/PCI/DataTable) simultaneously to prevent any 
 chicken/egg issues between them. ACPICA BZ 848.
 
 Implemented an optimization for GPE detection. This optimization will 
 simply 
 ignore GPE registers that contain no enabled GPEs -- there is no need to 
 read the register since this information is available internally. This 
 becomes more important on machines with a large GPE space. ACPICA bugzilla 
 884. Lin Ming. Suggestion from Joe Liu.
 
 Removed all use of the highly unreliable FADT revision field. The revision 
 number in the FADT has been found to be completely unreliable and cannot 
 be 
 trusted. Only the actual table length can be used to infer the version. 
 This 
 change updates the ACPICA core and the disassembler so that both no longer 
 even look at the FADT version and instead depend solely upon the FADT 
 length.
 
 Fix an unresolved name issue for the no-debug and no-error-message source 
 generation cases. The _AcpiModuleName was left undefined in these cases, 
 but 
 it is actually needed as a parameter to some interfaces. Define 
 _AcpiModuleName as a null string in these cases. ACPICA Bugzilla 888.
 
 Split several large files (makefiles and project files updated)
   utglobal.c   -> utdecode.c
   dbcomds.c    -> dbmethod.c dbnames.c
   dsopcode.c   -> dsargs.c dscontrol.c
   dsload.c     -> dsload2.c
   aslanalyze.c -> aslbtypes.c aslwalks.c
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release (VC 9.0):
     Non-Debug Version:  89.7K Code, 23.7K Data, 113.4K Total
     Debug Version:     163.9K Code, 67.5K Data, 231.4K Total
   Current Release (VC 9.0):
     Non-Debug Version:  89.7K Code, 23.7K Data, 113.4K Total
     Debug Version:     163.9K Code, 67.5K Data, 231.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented the predefined macros __LINE__, __FILE__, and __DATE__. 
 These are useful C-style macros with the standard definitions. ACPICA 
 bugzilla 898.
 
 iASL/DTC: Added support for integer expressions and labels. Support for 
 full 
 expressions for all integer fields in all ACPI tables. Support for labels 
 in 
 "generic" portions of tables such as UEFI. See the iASL reference manual.
 
 Debugger: Added a command to display the status of global handlers. The 
 "handlers" command will display op region, fixed event, and miscellaneous 
 global handlers. installation status -- and for op regions, whether 
 default 
 or user-installed handler will be used.
 
 iASL: Warn if reserved method incorrectly returns a value. Many predefined 
 names are defined such that they do not return a value. If implemented as 
 a 
 method, issue a warning if such a name explicitly returns a value. ACPICA 
 Bugzilla 855.
 
 iASL: Added detection of GPE method name conflicts. Detects a conflict 
 where 
 there are two GPE methods of the form _Lxy and _Exy in the same scope. 
 (For 
 example, _L1D and _E1D in the same scope.) ACPICA bugzilla 848.
 
 iASL/DTC: Fixed a couple input scanner issues with comments and line 
 numbers. Comment remover could get confused and miss a comment ending. 
 Fixed 
 a problem with line counter maintenance.
 
 iASL/DTC: Reduced the severity of some errors from fatal to error. There 
 is 
 no need to abort on simple errors within a field definition.
 
 Debugger: Simplified the output of the help command. All help output now 
 in 
 a single screen, instead of help subcommands. ACPICA Bugzilla 897.
 
 ----------------------------------------
 12 January 2011. Summary of changes for version 20110112:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a race condition between method execution and namespace walks that 
 can 
 possibly cause a fault. The problem was apparently introduced in version 
 20100528 as a result of a performance optimization that reduces the number 
 of 
 namespace walks upon method exit by using the delete_namespace_subtree 
 function instead of the delete_namespace_by_owner function used 
 previously. 
 Bug is a missing namespace lock in the delete_namespace_subtree function. 
 dana.myers@oracle.com
 
 Fixed several issues and a possible fault with the automatic "serialized" 
 method support. History: This support changes a method to "serialized" on 
 the 
 fly if the method generates an AE_ALREADY_EXISTS error, indicating the 
 possibility that it cannot handle reentrancy. This fix repairs a couple of 
 issues seen in the field, especially on machines with many cores:
 
     1) Delete method children only upon the exit of the last thread,
        so as to not delete objects out from under other running threads
       (and possibly causing a fault.)
     2) Set the "serialized" bit for the method only upon the exit of the
        Last thread, so as to not cause deadlock when running threads
        attempt to exit.
     3) Cleanup the use of the AML "MethodFlags" and internal method flags
        so that there is no longer any confusion between the two.
 
     Lin Ming, Bob Moore. Reported by dana.myers@oracle.com.
 
 Debugger: Now lock the namespace for duration of a namespace dump. 
 Prevents 
 issues if the namespace is changing dynamically underneath the debugger. 
 Especially affects temporary namespace nodes, since the debugger displays 
 these also.
 
 Updated the ordering of include files. The ACPICA headers should appear 
 before any compiler-specific headers (stdio.h, etc.) so that acenv.h can 
 set 
 any necessary compiler-specific defines, etc. Affects the ACPI-related 
 tools 
 and utilities.
 
 Updated all ACPICA copyrights and signons to 2011. Added the 2011 
 copyright 
 to all module headers and signons, including the Linux header. This 
 affects 
 virtually every file in the ACPICA core subsystem, iASL compiler, and all 
 utilities.
 
 Added project files for MS Visual Studio 2008 (VC++ 9.0). The original 
 project files for VC++ 6.0 are now obsolete. New project files can be 
 found 
 under acpica/generate/msvc9. See acpica/generate/msvc9/readme.txt for 
 details.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release (VC 6.0):
     Non-Debug Version:  89.8K Code, 18.9K Data, 108.7K Total
     Debug Version:     166.6K Code, 52.1K Data, 218.7K Total
   Current Release (VC 9.0):
     Non-Debug Version:  89.7K Code, 23.7K Data, 113.4K Total
     Debug Version:     163.9K Code, 67.5K Data, 231.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Added generic data types to the Data Table compiler. Add "generic" 
 data 
 types such as UINT32, String, Unicode, etc., to simplify the generation of 
 platform-defined tables such as UEFI. Lin Ming.
 
 iASL: Added listing support for the Data Table Compiler. Adds listing 
 support 
 (-l) to display actual binary output for each line of input code.
 
 ----------------------------------------
 09 December 2010. Summary of changes for version 20101209:
 
 1) ACPI CA Core Subsystem:
 
 Completed the major overhaul of the GPE support code that was begun in 
 July 
 2010. Major features include: removal of _PRW execution in ACPICA (host 
 executes _PRWs anyway), cleanup of "wake" GPE interfaces and processing, 
 changes to existing interfaces, simplification of GPE handler operation, 
 and 
 a handful of new interfaces:
 
     AcpiUpdateAllGpes
     AcpiFinishGpe
     AcpiSetupGpeForWake
     AcpiSetGpeWakeMask
     One new file, evxfgpe.c to consolidate all external GPE interfaces.
 
 See the ACPICA Programmer Reference for full details and programming 
 information. See the new section 4.4 "General Purpose Event (GPE) Support" 
 for a full overview, and section 8.7 "ACPI General Purpose Event 
 Management" 
 for programming details. ACPICA BZ 858,870,877. Matthew Garrett, Lin Ming, 
 Bob Moore, Rafael Wysocki.
 
 Implemented a new GPE feature for Windows compatibility, the "Implicit 
 Wake 
 GPE Notify". This feature will automatically issue a Notify(2) on a device 
 when a Wake GPE is received if there is no corresponding GPE method or 
 handler. ACPICA BZ 870.
 
 Fixed a problem with the Scope() operator during table parse and load 
 phase. 
 During load phase (table load or method execution), the scope operator 
 should 
 not enter the target into the namespace. Instead, it should open a new 
 scope 
 at the target location. Linux BZ 19462, ACPICA BZ 882.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  89.8K Code, 18.9K Data, 108.7K Total
     Debug Version:     166.6K Code, 52.1K Data, 218.7K Total
   Current Release:
     Non-Debug Version:  89.9K Code, 19.0K Data, 108.9K Total
     Debug Version:     166.3K Code, 52.1K Data, 218.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Relax the alphanumeric restriction on _CID strings. These strings 
 are 
 "bus-specific" per the ACPI specification, and therefore any characters 
 are 
 acceptable. The only checks that can be performed are for a null string 
 and 
 perhaps for a leading asterisk. ACPICA BZ 886.
 
 iASL: Fixed a problem where a syntax error that caused a premature EOF 
 condition on the source file emitted a very confusing error message. The 
 premature EOF is now detected correctly. ACPICA BZ 891.
 
 Disassembler: Decode the AccessSize within a Generic Address Structure 
 (byte 
 access, word access, etc.) Note, this field does not allow arbitrary bit 
 access, the size is encoded as 1=byte, 2=word, 3=dword, and 4=qword.
 
 New: AcpiNames utility - Example namespace dump utility. Shows an example 
 of 
 ACPICA configuration for a minimal namespace dump utility. Uses table and 
 namespace managers, but no AML interpreter. Does not add any functionality 
 over AcpiExec, it is a subset of AcpiExec. The purpose is to show how to 
 partition and configure ACPICA. ACPICA BZ 883.
 
 AML Debugger: Increased the debugger buffer size for method return 
 objects. 
 Was 4K, increased to 16K. Also enhanced error messages for debugger method 
 execution, including the buffer overflow case.
 
 ----------------------------------------
 13 October 2010. Summary of changes for version 20101013:
 
 1) ACPI CA Core Subsystem:
 
 Added support to clear the PCIEXP_WAKE event. When clearing ACPI events, 
 now 
 clear the PCIEXP_WAKE_STS bit in the ACPI PM1 Status Register, via 
 HwClearAcpiStatus. Original change from Colin King. ACPICA BZ 880.
 
 Changed the type of the predefined namespace object _TZ from ThermalZone 
 to 
 Device. This was found to be confusing to the host software that processes 
 the various thermal zones, since _TZ is not really a ThermalZone. However, 
 a 
 Notify() can still be performed on it. ACPICA BZ 876. Suggestion from Rui 
 Zhang.
 
 Added Windows Vista SP2 to the list of supported _OSI strings. The actual 
 string is "Windows 2006 SP2".
 
 Eliminated duplicate code in AcpiUtExecute* functions. Now that the 
 nsrepair 
 code automatically repairs _HID-related strings, this type of code is no 
 longer needed in Execute_HID, Execute_CID, and Execute_UID. ACPICA BZ 878.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  89.9K Code, 19.0K Data, 108.9K Total
     Debug Version:     166.3K Code, 52.1K Data, 218.4K Total
   Current Release:
     Non-Debug Version:  89.9K Code, 19.0K Data, 108.9K Total
     Debug Version:     166.3K Code, 52.1K Data, 218.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented additional compile-time validation for _HID strings. The 
 non-hex prefix (such as "PNP" or "ACPI") must be uppercase, and the length 
 of 
 the string must be exactly seven or eight characters. For both _HID and 
 _CID 
 strings, all characters must be alphanumeric. ACPICA BZ 874.
 
 iASL: Allow certain "null" resource descriptors. Some BIOS code creates 
 descriptors that are mostly or all zeros, with the expectation that they 
 will 
 be filled in at runtime. iASL now allows this as long as there is a 
 "resource 
 tag" (name) associated with the descriptor, which gives the ASL a handle 
 needed to modify the descriptor. ACPICA BZ 873.
 
 Added single-thread support to the generic Unix application OSL. Primarily 
 for iASL support, this change removes the use of semaphores in the single-
 threaded ACPICA tools/applications - increasing performance. The 
 _MULTI_THREADED option was replaced by the (reverse) ACPI_SINGLE_THREADED 
 option. ACPICA BZ 879.
 
 AcpiExec: several fixes for the 64-bit version. Adds XSDT support and 
 support 
 for 64-bit DSDT/FACS addresses in the FADT. Lin Ming.
 
 iASL: Moved all compiler messages to a new file, aslmessages.h.
 
 ----------------------------------------
 15 September 2010. Summary of changes for version 20100915:
 
 1) ACPI CA Core Subsystem:
 
 Removed the AcpiOsDerivePciId OSL interface. The various host 
 implementations 
 of this function were not OS-dependent and are now obsolete and can be 
 removed from all host OSLs. This function has been replaced by 
 AcpiHwDerivePciId, which is now part of the ACPICA core code. 
 AcpiHwDerivePciId has been implemented without recursion. Adds one new 
 module, hwpci.c. ACPICA BZ 857.
 
 Implemented a dynamic repair for _HID and _CID strings. The following 
 problems are now repaired at runtime: 1) Remove a leading asterisk in the 
 string, and 2) the entire string is uppercased. Both repairs are in 
 accordance with the ACPI specification and will simplify host driver code. 
 ACPICA BZ 871.
 
 The ACPI_THREAD_ID type is no longer configurable, internally it is now 
 always UINT64. This simplifies the ACPICA code, especially any printf 
 output. 
 UINT64 is the only common data type for all thread_id types across all 
 operating systems. It is now up to the host OSL to cast the native 
 thread_id 
 type to UINT64 before returning the value to ACPICA (via 
 AcpiOsGetThreadId). 
 Lin Ming, Bob Moore.
 
 Added the ACPI_INLINE type to enhance the ACPICA configuration. The 
 "inline" 
 keyword is not standard across compilers, and this type allows inline to 
 be 
 configured on a per-compiler basis. Lin Ming.
 
 Made the system global AcpiGbl_SystemAwakeAndRunning publically available. 
 Added an extern for this boolean in acpixf.h. Some hosts utilize this 
 value 
 during suspend/restore operations. ACPICA BZ 869.
 
 All code that implements error/warning messages with the "ACPI:" prefix 
 has 
 been moved to a new module, utxferror.c.
 
 The UINT64_OVERLAY was moved to utmath.c, which is the only module where 
 it 
 is used. ACPICA BZ 829. Lin Ming, Bob Moore.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  89.1K Code, 19.0K Data, 108.1K Total
     Debug Version:     165.1K Code, 51.9K Data, 217.0K Total
   Current Release:
     Non-Debug Version:  89.9K Code, 19.0K Data, 108.9K Total
     Debug Version:     166.3K Code, 52.1K Data, 218.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL/Disassembler: Write ACPI errors to stderr instead of the output file. 
 This keeps the output files free of random error messages that may 
 originate 
 from within the namespace/interpreter code. Used this opportunity to merge 
 all ACPI:-style messages into a single new module, utxferror.c. ACPICA BZ 
 866. Lin Ming, Bob Moore.
 
 Tools: update some printfs for ansi warnings on size_t. Handle width 
 change 
 of size_t on 32-bit versus 64-bit generations. Lin Ming.
 
 ----------------------------------------
 06 August 2010. Summary of changes for version 20100806:
 
 1) ACPI CA Core Subsystem:
 
 Designed and implemented a new host interface to the _OSI support code. 
 This 
 will allow the host to dynamically add or remove multiple _OSI strings, as 
 well as install an optional handler that is called for each _OSI 
 invocation. 
 Also added a new AML debugger command, 'osi' to display and modify the 
 global 
 _OSI string table, and test support in the AcpiExec utility. See the 
 ACPICA 
 reference manual for full details. Lin Ming, Bob Moore. ACPICA BZ 836.
 New Functions:
     AcpiInstallInterface - Add an _OSI string.
     AcpiRemoveInterface - Delete an _OSI string.
     AcpiInstallInterfaceHandler - Install optional _OSI handler.
 Obsolete Functions:
     AcpiOsValidateInterface - no longer used.
 New Files:
     source/components/utilities/utosi.c
 
 Re-introduced the support to enable multi-byte transfers for Embedded 
 Controller (EC) operation regions. A reported problem was found to be a 
 bug 
 in the host OS, not in the multi-byte support. Previously, the maximum 
 data 
 size passed to the EC operation region handler was a single byte. There 
 are 
 often EC Fields larger than one byte that need to be transferred, and it 
 is 
 useful for the EC driver to lock these as a single transaction. This 
 change 
 enables single transfers larger than 8 bits. This effectively changes the 
 access to the EC space from ByteAcc to AnyAcc, and will probably require 
 changes to the host OS Embedded Controller driver to enable 16/32/64/256-
 bit 
 transfers in addition to 8-bit transfers. Alexey Starikovskiy, Lin Ming.
 
 Fixed a problem with the prototype for AcpiOsReadPciConfiguration. The 
 prototype in acpiosxf.h had the output value pointer as a (void *).
 It should be a (UINT64 *). This may affect some host OSL code.
 
 Fixed a couple problems with the recently modified Linux makefiles for 
 iASL 
 and AcpiExec. These new makefiles place the generated object files in the 
 local directory so that there can be no collisions between the files that 
 are 
 shared between them that are compiled with different options.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  88.3K Code, 18.8K Data, 107.1K Total
     Debug Version:     164.0K Code, 51.5K Data, 215.5K Total
   Current Release:
     Non-Debug Version:  89.1K Code, 19.0K Data, 108.1K Total
     Debug Version:     165.1K Code, 51.9K Data, 217.0K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL/Disassembler: Added a new option (-da, "disassemble all") to load the 
 namespace from and disassemble an entire group of AML files. Useful for 
 loading all of the AML tables for a given machine (DSDT, SSDT1...SSDTn) 
 and 
 disassembling with one simple command. ACPICA BZ 865. Lin Ming.
 
 iASL: Allow multiple invocations of -e option. This change allows multiple 
 uses of -e on the command line: "-e ssdt1.dat -e ssdt2.dat". ACPICA BZ 
 834. 
 Lin Ming.
 
 ----------------------------------------
 02 July 2010. Summary of changes for version 20100702:
 
 1) ACPI CA Core Subsystem:
 
 Implemented several updates to the recently added GPE reference count 
 support. The model for "wake" GPEs is changing to give the host OS 
 complete 
 control of these GPEs. Eventually, the ACPICA core will not execute any 
 _PRW 
 methods, since the host already must execute them. Also, additional 
 changes 
 were made to help ensure that the reference counts are kept in proper 
 synchronization with reality. Rafael J. Wysocki.
 
 1) Ensure that GPEs are not enabled twice during initialization.
 2) Ensure that GPE enable masks stay in sync with the reference count.
 3) Do not inadvertently enable GPEs when writing GPE registers.
 4) Remove the internal wake reference counter and add new AcpiGpeWakeup 
 interface. This interface will set or clear individual GPEs for wakeup.
 5) Remove GpeType argument from AcpiEnable and AcpiDisable. These 
 interfaces 
 are now used for "runtime" GPEs only.
 
 Changed the behavior of the GPE install/remove handler interfaces. The GPE 
 is 
 no longer disabled during this process, as it was found to cause problems 
 on 
 some machines. Rafael J. Wysocki.
 
 Reverted a change introduced in version 20100528 to enable Embedded 
 Controller multi-byte transfers. This change was found to cause problems 
 with 
 Index Fields and possibly Bank Fields. It will be reintroduced when these 
 problems have been resolved.
 
 Fixed a problem with references to Alias objects within Package Objects. A 
 reference to an Alias within the definition of a Package was not always 
 resolved properly. Aliases to objects like Processors, Thermal zones, etc. 
 were resolved to the actual object instead of a reference to the object as 
 it 
 should be. Package objects are only allowed to contain integer, string, 
 buffer, package, and reference objects. Redhat bugzilla 608648.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  88.3K Code, 18.8K Data, 107.1K Total
     Debug Version:     164.1K Code, 51.5K Data, 215.6K Total
   Current Release:
     Non-Debug Version:  88.3K Code, 18.8K Data, 107.1K Total
     Debug Version:     164.0K Code, 51.5K Data, 215.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented a new compiler subsystem to allow definition and 
 compilation of the non-AML ACPI tables such as FADT, MADT, SRAT, etc. 
 These 
 are called "ACPI Data Tables", and the new compiler is the "Data Table 
 Compiler". This compiler is intended to simplify the existing error-prone 
 process of creating these tables for the BIOS, as well as allowing the 
 disassembly, modification, recompilation, and override of existing ACPI 
 data 
 tables. See the iASL User Guide for detailed information.
 
 iASL: Implemented a new Template Generator option in support of the new 
 Data 
 Table Compiler. This option will create examples of all known ACPI tables 
 that can be used as the basis for table development. See the iASL 
 documentation and the -T option.
 
 Disassembler and headers: Added support for the WDDT ACPI table (Watchdog 
 Descriptor Table).
 
 Updated the Linux makefiles for iASL and AcpiExec to place the generated 
 object files in the local directory so that there can be no collisions 
 between the shared files between them that are generated with different 
 options.
 
 Added support for Mac OS X in the Unix OSL used for iASL and AcpiExec. Use 
 the #define __APPLE__ to enable this support.
 
 ----------------------------------------
 28 May 2010. Summary of changes for version 20100528:
 
 Note: The ACPI 4.0a specification was released on April 5, 2010 and is 
 available at www.acpi.info. This is primarily an errata release.
 
 1) ACPI CA Core Subsystem:
 
 Undefined ACPI tables: We are looking for the definitions for the 
 following 
 ACPI tables that have been seen in the field: ATKG, IEIT, GSCI.
 
 Implemented support to enable multi-byte transfers for Embedded Controller 
 (EC) operation regions. Previously, the maximum data size passed to the EC 
 operation region handler was a single byte. There are often EC Fields 
 larger 
 than one byte that need to be transferred, and it is useful for the EC 
 driver 
 to lock these as a single transaction. This change enables single 
 transfers 
 larger than 8 bits. This effectively changes the access to the EC space 
 from 
 ByteAcc to AnyAcc, and will probably require changes to the host OS 
 Embedded 
 Controller driver to enable 16/32/64/256-bit transfers in addition to 8-
 bit 
 transfers. Alexey Starikovskiy, Lin Ming
 
 Implemented a performance enhancement for namespace search and access. 
 This 
 change enhances the performance of namespace searches and walks by adding 
 a 
 backpointer to the parent in each namespace node. On large namespaces, 
 this 
 change can improve overall ACPI performance by up to 9X. Adding a pointer 
 to 
 each namespace node increases the overall size of the internal namespace 
 by 
 about 5%, since each namespace entry usually consists of both a namespace 
 node and an ACPI operand object. However, this is the first growth of the 
 namespace in ten years. ACPICA bugzilla 817. Alexey Starikovskiy.
 
 Implemented a performance optimization that reduces the number of 
 namespace 
 walks. On control method exit, only walk the namespace if the method is 
 known 
 to have created namespace objects outside of its local scope. Previously, 
 the 
 entire namespace was traversed on each control method exit. This change 
 can 
 improve overall ACPI performance by up to 3X. Alexey Starikovskiy, Bob 
 Moore.
 
 Added support to truncate I/O addresses to 16 bits for Windows 
 compatibility. 
 Some ASL code has been seen in the field that inadvertently has bits set 
 above bit 15. This feature is optional and is enabled if the BIOS requests 
 any Windows OSI strings. It can also be enabled by the host OS. Matthew 
 Garrett, Bob Moore.
 
 Added support to limit the maximum time for the ASL Sleep() operator. To 
 prevent accidental deep sleeps, limit the maximum time that Sleep() will 
 actually sleep. Configurable, the default maximum is two seconds. ACPICA 
 bugzilla 854.
 
 Added run-time validation support for the _WDG and_WED Microsoft 
 predefined 
 methods. These objects are defined by "Windows Instrumentation", and are 
 not 
 part of the ACPI spec. ACPICA BZ 860.
 
 Expanded all statistic counters used during namespace and device 
 initialization from 16 to 32 bits in order to support very large 
 namespaces.
 
 Replaced all instances of %d in printf format specifiers with %u since 
 nearly 
 all integers in ACPICA are unsigned.
 
 Fixed the exception namestring for AE_WAKE_ONLY_GPE. Was incorrectly 
 returned 
 as AE_NO_HANDLER.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  88.4K Code, 18.8K Data, 107.2K Total
     Debug Version:     164.2K Code, 51.5K Data, 215.7K Total
   Current Release:
     Non-Debug Version:  88.3K Code, 18.8K Data, 107.1K Total
     Debug Version:     164.1K Code, 51.5K Data, 215.6K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Added compiler support for the _WDG and_WED Microsoft predefined 
 methods. These objects are defined by "Windows Instrumentation", and are 
 not 
 part of the ACPI spec. ACPICA BZ 860.
 
 AcpiExec: added option to disable the memory tracking mechanism. The -dt 
 option will disable the tracking mechanism, which improves performance 
 considerably.
 
 AcpiExec: Restructured the command line options into -d (disable) and -e 
 (enable) options.
 
 ----------------------------------------
 28 April 2010. Summary of changes for version 20100428:
 
 1) ACPI CA Core Subsystem:
 
 Implemented GPE support for dynamically loaded ACPI tables. For all GPEs, 
 including FADT-based and GPE Block Devices, execute any _PRW methods in 
 the 
 new table, and process any _Lxx/_Exx GPE methods in the new table. Any 
 runtime GPE that is referenced by an _Lxx/_Exx method in the new table is 
 immediately enabled. Handles the FADT-defined GPEs as well as GPE Block 
 Devices. Provides compatibility with other ACPI implementations. Two new 
 files added, evgpeinit.c and evgpeutil.c. ACPICA BZ 833. Lin Ming, Bob 
 Moore.
 
 Fixed a regression introduced in version 20100331 within the table manager 
 where initial table loading could fail. This was introduced in the fix for 
 AcpiReallocateRootTable. Also, renamed some of fields in the table manager 
 data structures to clarify their meaning and use.
 
 Fixed a possible allocation overrun during internal object copy in 
 AcpiUtCopySimpleObject. The original code did not correctly handle the 
 case 
 where the object to be copied was a namespace node. Lin Ming. ACPICA BZ 
 847.
 
 Updated the allocation dump routine, AcpiUtDumpAllocation and fixed a 
 possible access beyond end-of-allocation. Also, now fully validate 
 descriptor 
 (size and type) before output. Lin Ming, Bob Moore. ACPICA BZ 847
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  87.9K Code, 18.6K Data, 106.5K Total
     Debug Version:     163.5K Code, 51.3K Data, 214.8K Total
   Current Release:
     Non-Debug Version:  88.4K Code, 18.8K Data, 107.2K Total
     Debug Version:     164.2K Code, 51.5K Data, 215.7K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented Min/Max/Len/Gran validation for address resource 
 descriptors. This change implements validation for the address fields that 
 are common to all address-type resource descriptors. These checks are 
 implemented: Checks for valid Min/Max, length within the Min/Max window, 
 valid granularity, Min/Max a multiple of granularity, and _MIF/_MAF as per 
 table 6-40 in the ACPI 4.0a specification. Also split the large 
 aslrestype1.c 
 and aslrestype2.c files into five new files. ACPICA BZ 840.
 
 iASL: Added support for the _Wxx predefined names. This support was 
 missing 
 and these names were not recognized by the compiler as valid predefined 
 names. ACPICA BZ 851.
 
 iASL: Added an error for all predefined names that are defined to return 
 no 
 value and thus must be implemented as Control Methods. These include all 
 of 
 the _Lxx, _Exx, _Wxx, and _Qxx names, as well as some other miscellaneous 
 names such as _DIS, _INI, _IRC, _OFF, _ON, and _PSx. ACPICA BZ 850, 856.
 
 iASL: Implemented the -ts option to emit hex AML data in ASL format, as an 
 ASL Buffer. Allows ACPI tables to be easily included within ASL files, to 
 be 
 dynamically loaded via the Load() operator. Also cleaned up output for the 
 -
 ta and -tc options. ACPICA BZ 853.
 
 Tests: Added a new file with examples of extended iASL error checking. 
 Demonstrates the advanced error checking ability of the iASL compiler. 
 Available at tests/misc/badcode.asl.
 
 ----------------------------------------
 31 March 2010. Summary of changes for version 20100331:
 
 1) ACPI CA Core Subsystem:
 
 Completed a major update for the GPE support in order to improve support 
 for 
 shared GPEs and to simplify both host OS and ACPICA code. Added a 
 reference 
 count mechanism to support shared GPEs that require multiple device 
 drivers. 
 Several external interfaces have changed. One external interface has been 
 removed. One new external interface was added. Most of the GPE external 
 interfaces now use the GPE spinlock instead of the events mutex (and the 
 Flags parameter for many GPE interfaces has been removed.) See the updated 
 ACPICA Programmer Reference for details. Matthew Garrett, Bob Moore, 
 Rafael 
 Wysocki. ACPICA BZ 831.
 
 Changed:
     AcpiEnableGpe, AcpiDisableGpe, AcpiClearGpe, AcpiGetGpeStatus
 Removed:
     AcpiSetGpeType
 New:
     AcpiSetGpe
 
 Implemented write support for DataTable operation regions. These regions 
 are 
 defined via the DataTableRegion() operator. Previously, only read support 
 was 
 implemented. The ACPI specification allows DataTableRegions to be 
 read/write, 
 however.
 
 Implemented a new subsystem option to force a copy of the DSDT to local 
 memory. Optionally copy the entire DSDT to local memory (instead of simply 
 mapping it.) There are some (albeit very rare) BIOSs that corrupt or 
 replace 
 the original DSDT, creating the need for this option. Default is FALSE, do 
 not copy the DSDT.
 
 Implemented detection of a corrupted or replaced DSDT. This change adds 
 support to detect a DSDT that has been corrupted and/or replaced from 
 outside 
 the OS (by firmware). This is typically catastrophic for the system, but 
 has 
 been seen on some machines. Once this problem has been detected, the DSDT 
 copy option can be enabled via system configuration. Lin Ming, Bob Moore.
 
 Fixed two problems with AcpiReallocateRootTable during the root table 
 copy. 
 When copying the root table to the new allocation, the length used was 
 incorrect. The new size was used instead of the current table size, 
 meaning 
 too much data was copied. Also, the count of available slots for ACPI 
 tables 
 was not set correctly. Alexey Starikovskiy, Bob Moore.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  87.5K Code, 18.4K Data, 105.9K Total
     Debug Version:     163.4K Code, 51.1K Data, 214.5K Total
   Current Release:
     Non-Debug Version:  87.9K Code, 18.6K Data, 106.5K Total
     Debug Version:     163.5K Code, 51.3K Data, 214.8K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implement limited typechecking for values returned from predefined 
 control methods. The type of any returned static (unnamed) object is now 
 validated. For example, Return(1). ACPICA BZ 786.
 
 iASL: Fixed a predefined name object verification regression. Fixes a 
 problem 
 introduced in version 20100304. An error is incorrectly generated if a 
 predefined name is declared as a static named object with a value defined 
 using the keywords "Zero", "One", or "Ones". Lin Ming.
 
 iASL: Added Windows 7 support for the -g option (get local ACPI tables) by 
 reducing the requested registry access rights. ACPICA BZ 842.
 
 Disassembler: fixed a possible fault when generating External() 
 statements. 
 Introduced in commit ae7d6fd: Properly handle externals with parent-prefix 
 (carat). Fixes a string length allocation calculation. Lin Ming.
 
 ----------------------------------------
 04 March 2010. Summary of changes for version 20100304:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a possible problem with the AML Mutex handling function 
 AcpiExReleaseMutex where the function could fault under the very rare 
 condition when the interpreter has blocked, the interpreter lock is 
 released, 
 the interpreter is then reentered via the same thread, and attempts to 
 acquire an AML mutex that was previously acquired. FreeBSD report 140979. 
 Lin 
 Ming.
 
 Implemented additional configuration support for the AML "Debug Object". 
 Output from the debug object can now be enabled via a global variable, 
 AcpiGbl_EnableAmlDebugObject. This will assist with remote machine 
 debugging. 
 This debug output is now available in the release version of ACPICA 
 instead 
 of just the debug version. Also, the entire debug output module can now be 
 configured out of the ACPICA build if desired. One new file added, 
 executer/exdebug.c. Lin Ming, Bob Moore.
 
 Added header support for the ACPI MCHI table (Management Controller Host 
 Interface Table). This table was added in ACPI 4.0, but the defining 
 document 
 has only recently become available.
 
 Standardized output of integer values for ACPICA warnings/errors. Always 
 use 
 0x prefix for hex output, always use %u for unsigned integer decimal 
 output. 
 Affects ACPI_INFO, ACPI_ERROR, ACPI_EXCEPTION, and ACPI_WARNING (about 400 
 invocations.) These invocations were converted from the original 
 ACPI_DEBUG_PRINT invocations and were not consistent. ACPICA BZ 835.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  87.1K Code, 18.0K Data, 105.1K Total
     Debug Version:     163.5K Code, 50.9K Data, 214.4K Total
   Current Release:
     Non-Debug Version:  87.5K Code, 18.4K Data, 105.9K Total
     Debug Version:     163.4K Code, 51.1K Data, 214.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented typechecking support for static (non-control method) 
 predefined named objects that are declared with the Name() operator. For 
 example, the type of this object is now validated to be of type Integer: 
 Name(_BBN, 1). This change migrates the compiler to using the core 
 predefined 
 name table instead of maintaining a local version. Added a new file, 
 aslpredef.c. ACPICA BZ 832.
 
 Disassembler: Added support for the ACPI 4.0 MCHI table.
 
 ----------------------------------------
 21 January 2010. Summary of changes for version 20100121:
 
 1) ACPI CA Core Subsystem:
 
 Added the 2010 copyright to all module headers and signons. This affects 
 virtually every file in the ACPICA core subsystem, the iASL compiler, the 
 tools/utilities, and the test suites.
 
 Implemented a change to the AcpiGetDevices interface to eliminate 
 unnecessary 
 invocations of the _STA method. In the case where a specific _HID is 
 requested, do not run _STA until a _HID match is found. This eliminates 
 potentially dozens of _STA calls during a search for a particular 
 device/HID, 
 which in turn can improve boot times. ACPICA BZ 828. Lin Ming.
 
 Implemented an additional repair for predefined method return values. 
 Attempt 
 to repair unexpected NULL elements within returned Package objects. Create 
 an 
 Integer of value zero, a NULL String, or a zero-length Buffer as 
 appropriate. 
 ACPICA BZ 818. Lin Ming, Bob Moore.
 
 Removed the obsolete ACPI_INTEGER data type. This type was introduced as 
 the 
 code was migrated from ACPI 1.0 (with 32-bit AML integers) to ACPI 2.0 
 (with 
 64-bit AML integers). It is now obsolete and this change removes it from 
 the 
 ACPICA code base, replaced by UINT64. The original typedef has been 
 retained 
 for now for compatibility with existing device driver code. ACPICA BZ 824.
 
 Removed the unused UINT32_STRUCT type, and the obsolete Integer64 field in 
 the parse tree object.
 
 Added additional warning options for the gcc-4 generation. Updated the 
 source 
 accordingly. This includes some code restructuring to eliminate 
 unreachable 
 code, elimination of some gotos, elimination of unused return values, some 
 additional casting, and removal of redundant declarations.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  87.0K Code, 18.0K Data, 105.0K Total
     Debug Version:     163.4K Code, 50.8K Data, 214.2K Total
   Current Release:
     Non-Debug Version:  87.1K Code, 18.0K Data, 105.1K Total
     Debug Version:     163.5K Code, 50.9K Data, 214.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 No functional changes for this release.
 
 ----------------------------------------
 14 December 2009. Summary of changes for version 20091214:
 
 1) ACPI CA Core Subsystem:
 
 Enhanced automatic data type conversions for predefined name repairs. This 
 change expands the automatic repairs/conversions for predefined name 
 return 
 values to make Integers, Strings, and Buffers fully interchangeable. Also, 
 a 
 Buffer can be converted to a Package of Integers if necessary. The 
 nsrepair.c 
 module was completely restructured. Lin Ming, Bob Moore.
 
 Implemented automatic removal of null package elements during predefined 
 name 
 repairs. This change will automatically remove embedded and trailing NULL 
 package elements from returned package objects that are defined to contain 
 a 
 variable number of sub-packages. The driver is then presented with a 
 package 
 with no null elements to deal with. ACPICA BZ 819.
 
 Implemented a repair for the predefined _FDE and _GTM names. The expected 
 return value for both names is a Buffer of 5 DWORDs. This repair fixes two 
 possible problems (both seen in the field), where a package of integers is 
 returned, or a buffer of BYTEs is returned. With assistance from Jung-uk 
 Kim.
 
 Implemented additional module-level code support. This change will 
 properly 
 execute module-level code that is not at the root of the namespace (under 
 a 
 Device object, etc.). Now executes the code within the current scope 
 instead 
 of the root. ACPICA BZ 762. Lin Ming.
 
 Fixed possible mutex acquisition errors when running _REG methods. Fixes a 
 problem where mutex errors can occur when running a _REG method that is in 
 the same scope as a method-defined operation region or an operation region 
 under a module-level IF block. This type of code is rare, so the problem 
 has 
 not been seen before. ACPICA BZ 826. Lin Ming, Bob Moore.
 
 Fixed a possible memory leak during module-level code execution. An object 
 could be leaked for each block of executed module-level code if the 
 interpreter slack mode is enabled This change deletes any implicitly 
 returned 
 object from the module-level code block. Lin Ming.
 
 Removed messages for successful predefined repair(s). The repair mechanism 
 was considered too wordy. Now, messages are only unconditionally emitted 
 if 
 the return object cannot be repaired. Existing messages for successful 
 repairs were converted to ACPI_DEBUG_PRINT messages for now. ACPICA BZ 
 827.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  86.6K Code, 18.2K Data, 104.8K Total
     Debug Version:     162.7K Code, 50.8K Data, 213.5K Total
   Current Release:
     Non-Debug Version:  87.0K Code, 18.0K Data, 105.0K Total
     Debug Version:     163.4K Code, 50.8K Data, 214.2K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a regression introduced in 20091112 where intermediate .SRC 
 files 
 were no longer automatically removed at the termination of the compile.
 
 acpiexec: Implemented the -f option to specify default region fill value. 
 This option specifies the value used to initialize buffers that simulate 
 operation regions. Default value is zero. Useful for debugging problems 
 that 
 depend on a specific initial value for a region or field.
 
 ----------------------------------------
 12 November 2009. Summary of changes for version 20091112:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a post-order callback to AcpiWalkNamespace. The existing 
 interface only has a pre-order callback. This change adds an additional 
 parameter for a post-order callback which will be more useful for bus 
 scans. 
 ACPICA BZ 779. Lin Ming. Updated the ACPICA Programmer Reference.
 
 Modified the behavior of the operation region memory mapping cache for 
 SystemMemory. Ensure that the memory mappings created for operation 
 regions 
 do not cross 4K page boundaries. Crossing a page boundary while mapping 
 regions can cause kernel warnings on some hosts if the pages have 
 different 
 attributes. Such regions are probably BIOS bugs, and this is the 
 workaround. 
 Linux BZ 14445. Lin Ming.
 
 Implemented an automatic repair for predefined methods that must return 
 sorted lists. This change will repair (by sorting) packages returned by 
 _ALR, 
 _PSS, and _TSS. Drivers can now assume that the packages are correctly 
 sorted 
 and do not contain NULL package elements. Adds one new file, 
 namespace/nsrepair2.c. ACPICA BZ 784. Lin Ming, Bob Moore.
 
 Fixed a possible fault during predefined name validation if a return 
 Package 
 object contains NULL elements. Also adds a warning if a NULL element is 
 followed by any non-null elements. ACPICA BZ 813, 814. Future enhancement 
 may 
 include repair or removal of all such NULL elements where possible.
 
 Implemented additional module-level executable AML code support. This 
 change 
 will execute module-level code that is not at the root of the namespace 
 (under a Device object, etc.) at table load time. Module-level executable 
 AML 
 code has been illegal since ACPI 2.0. ACPICA BZ 762. Lin Ming.
 
 Implemented a new internal function to create Integer objects. This 
 function 
 simplifies miscellaneous object creation code. ACPICA BZ 823.
 
 Reduced the severity of predefined repair messages, Warning to Info. Since 
 the object was successfully repaired, a warning is too severe. Reduced to 
 an 
 info message for now. These messages may eventually be changed to debug-
 only. 
 ACPICA BZ 812.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  85.8K Code, 18.0K Data, 103.8K Total
     Debug Version:     161.8K Code, 50.6K Data, 212.4K Total
   Current Release:
     Non-Debug Version:  86.6K Code, 18.2K Data, 104.8K Total
     Debug Version:     162.7K Code, 50.8K Data, 213.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented Switch() with While(1) so that Break works correctly. 
 This 
 change correctly implements the Switch operator with a surrounding 
 While(1) 
 so that the Break operator works as expected. ACPICA BZ 461. Lin Ming.
 
 iASL: Added a message if a package initializer list is shorter than 
 package 
 length. Adds a new remark for a Package() declaration if an initializer 
 list 
 exists, but is shorter than the declared length of the package. Although 
 technically legal, this is probably a coding error and it is seen in the 
 field. ACPICA BZ 815. Lin Ming, Bob Moore.
 
 iASL: Fixed a problem where the compiler could fault after the maximum 
 number 
 of errors was reached (200).
 
 acpixtract: Fixed a possible warning for pointer cast if the compiler 
 warning 
 level set very high.
 
 ----------------------------------------
 13 October 2009. Summary of changes for version 20091013:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where an Operation Region _REG method could be executed 
 more 
 than once. If a custom address space handler is installed by the host 
 before 
 the "initialize operation regions" phase of the ACPICA initialization, any 
 _REG methods for that address space could be executed twice. This change 
 fixes the problem. ACPICA BZ 427. Lin Ming.
 
 Fixed a possible memory leak for the Scope() ASL operator. When the exact 
 invocation of "Scope(\)" is executed (change scope to root), one internal 
 operand object was leaked. Lin Ming.
 
 Implemented a run-time repair for the _MAT predefined method. If the _MAT 
 return value is defined as a Field object in the AML, and the field
 size is less than or equal to the default width of an integer (32 or 
 64),_MAT 
 can incorrectly return an Integer instead of a Buffer. ACPICA now 
 automatically repairs this problem. ACPICA BZ 810.
 
 Implemented a run-time repair for the _BIF and _BIX predefined methods. 
 The 
 "OEM Information" field is often incorrectly returned as an Integer with 
 value zero if the field is not supported by the platform. This is due to 
 an 
 ambiguity in the ACPI specification. The field should always be a string. 
 ACPICA now automatically repairs this problem by returning a NULL string 
 within the returned Package. ACPICA BZ 807.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  85.6K Code, 18.0K Data, 103.6K Total
     Debug Version:     161.7K Code, 50.9K Data, 212.6K Total
   Current Release:
     Non-Debug Version:  85.8K Code, 18.0K Data, 103.8K Total
     Debug Version:     161.8K Code, 50.6K Data, 212.4K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Fixed a problem where references to external symbols that 
 contained one or more parent-prefixes (carats) were not handled correctly, 
 possibly causing a fault. ACPICA BZ 806. Lin Ming.
 
 Disassembler: Restructured the code so that all functions that handle 
 external symbols are in a single module. One new file is added, 
 common/dmextern.c.
 
 AML Debugger: Added a max count argument for the Batch command (which 
 executes multiple predefined methods within the namespace.)
 
 iASL: Updated the compiler documentation (User Reference.) Available at 
 http://www.acpica.org/documentation/. ACPICA BZ 750.
 
 AcpiXtract: Updated for Lint and other formatting changes. Close all open 
 files.
 
 ----------------------------------------
 03 September 2009. Summary of changes for version 20090903:
 
 1) ACPI CA Core Subsystem:
 
 For Windows Vista compatibility, added the automatic execution of an _INI 
 method located at the namespace root (\_INI). This method is executed at 
 table load time. This support is in addition to the automatic execution of 
 \_SB._INI. Lin Ming.
 
 Fixed a possible memory leak in the interpreter for AML package objects if 
 the package initializer list is longer than the defined size of the 
 package. 
 This apparently can only happen if the BIOS changes the package size on 
 the 
 fly (seen in a _PSS object), as ASL compilers do not allow this. The 
 interpreter will truncate the package to the defined size (and issue an 
 error 
 message), but previously could leave the extra objects undeleted if they 
 were 
 pre-created during the argument processing (such is the case if the 
 package 
 consists of a number of sub-packages as in the _PSS.) ACPICA BZ 805.
 
 Fixed a problem seen when a Buffer or String is stored to itself via ASL. 
 This has been reported in the field. Previously, ACPICA would zero out the 
 buffer/string. Now, the operation is treated as a noop. Provides Windows 
 compatibility. ACPICA BZ 803. Lin Ming.
 
 Removed an extraneous error message for ASL constructs of the form 
 Store(LocalX,LocalX) when LocalX is uninitialized. These curious 
 statements 
 are seen in many BIOSs and are once again treated as NOOPs and no error is 
 emitted when they are encountered. ACPICA BZ 785.
 
 Fixed an extraneous warning message if a _DSM reserved method returns a 
 Package object. _DSM can return any type of object, so validation on the 
 return type cannot be performed. ACPICA BZ 802.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  85.5K Code, 18.0K Data, 103.5K Total
     Debug Version:     161.6K Code, 50.9K Data, 212.5K Total
   Current Release:
     Non-Debug Version:  85.6K Code, 18.0K Data, 103.6K Total
     Debug Version:     161.7K Code, 50.9K Data, 212.6K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a problem with the use of the Alias operator and Resource 
 Templates. The correct alias is now constructed and no error is emitted. 
 ACPICA BZ 738.
 
 iASL: Implemented the -I option to specify additional search directories 
 for 
 include files. Allows multiple additional search paths for include files. 
 Directories are searched in the order specified on the command line (after 
 the local directory is searched.) ACPICA BZ 800.
 
 iASL: Fixed a problem where the full pathname for include files was not 
 emitted for warnings/errors. This caused the IDE support to not work 
 properly. ACPICA BZ 765.
 
 iASL: Implemented the -@ option to specify a Windows-style response file 
 containing additional command line options. ACPICA BZ 801.
 
 AcpiExec: Added support to load multiple AML files simultaneously (such as 
 a 
 DSDT and multiple SSDTs). Also added support for wildcards within the AML 
 pathname. These features allow all machine tables to be easily loaded and 
 debugged together. ACPICA BZ 804.
 
 Disassembler: Added missing support for disassembly of HEST table Error 
 Bank 
 subtables. 
 
 ----------------------------------------
 30 July 2009. Summary of changes for version 20090730:
 
 The ACPI 4.0 implementation for ACPICA is complete with this release.
 
 1) ACPI CA Core Subsystem:
 
 ACPI 4.0: Added header file support for all new and changed ACPI tables. 
 Completely new tables are: IBFT, IVRS, MSCT, and WAET. Tables that are new 
 for ACPI 4.0, but have previously been supported in ACPICA are: CPEP, 
 BERT, 
 EINJ, ERST, and HEST. Other newly supported tables are: UEFI and WDAT. 
 There 
 have been some ACPI 4.0 changes to other existing tables. Split the large 
 actbl1.h header into the existing actbl2.h header. ACPICA BZ 774.
 
 ACPI 4.0: Implemented predefined name validation for all new names. There 
 are 
 31 new names in ACPI 4.0. The predefined validation module was split into 
 two 
 files. The new file is namespace/nsrepair.c. ACPICA BZ 770.
 
 Implemented support for so-called "module-level executable code". This is 
 executable AML code that exists outside of any control method and is 
 intended 
 to be executed at table load time. Although illegal since ACPI 2.0, this 
 type 
 of code still exists and is apparently still being created. Blocks of this 
 code are now detected and executed as intended. Currently, the code blocks 
 must exist under either an If, Else, or While construct; these are the 
 typical cases seen in the field. ACPICA BZ 762. Lin Ming.
 
 Implemented an automatic dynamic repair for predefined names that return 
 nested Package objects. This applies to predefined names that are defined 
 to 
 return a variable-length Package of sub-packages. If the number of sub-
 packages is one, BIOS code is occasionally seen that creates a simple 
 single 
 package with no sub-packages. This code attempts to fix the problem by 
 wrapping a new package object around the existing package. These methods 
 can 
 be repaired: _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, and _TSS. ACPICA BZ 
 790.
 
 Fixed a regression introduced in 20090625 for the AcpiGetDevices 
 interface. 
 The _HID/_CID matching was broken and no longer matched IDs correctly. 
 ACPICA 
 BZ 793.
 
 Fixed a problem with AcpiReset where the reset would silently fail if the 
 register was one of the protected I/O ports. AcpiReset now bypasses the 
 port 
 validation mechanism. This may eventually be driven into the 
 AcpiRead/Write 
 interfaces.
 
 Fixed a regression related to the recent update of the AcpiRead/Write 
 interfaces. A sleep/suspend could fail if the optional PM2 Control 
 register 
 does not exist during an attempt to write the Bus Master Arbitration bit. 
 (However, some hosts already delete the code that writes this bit, and the 
 code may in fact be obsolete at this date.) ACPICA BZ 799.
 
 Fixed a problem where AcpiTerminate could fault if inadvertently called 
 twice 
 in succession. ACPICA BZ 795.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  84.7K Code, 17.8K Data, 102.5K Total
     Debug Version:     160.5K Code, 50.6K Data, 211.1K Total
   Current Release:
     Non-Debug Version:  85.5K Code, 18.0K Data, 103.5K Total
     Debug Version:     161.6K Code, 50.9K Data, 212.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 ACPI 4.0: Implemented disassembler support for all new ACPI tables and 
 changes to existing tables. ACPICA BZ 775.
 
 ----------------------------------------
 25 June 2009. Summary of changes for version 20090625:
 
 The ACPI 4.0 Specification was released on June 16 and is available at 
 www.acpi.info. ACPICA implementation of ACPI 4.0 is underway and will 
 continue for the next few releases.
 
 1) ACPI CA Core Subsystem:
 
 ACPI 4.0: Implemented interpreter support for the IPMI operation region 
 address space. Includes support for bi-directional data buffers and an 
 IPMI 
 address space handler (to be installed by an IPMI device driver.) ACPICA 
 BZ 
 773. Lin Ming.
 
 ACPI 4.0: Added changes for existing ACPI tables - FACS and SRAT. Includes 
 support in both the header files and the disassembler.
 
 Completed a major update for the AcpiGetObjectInfo external interface. 
 Changes include:
  - Support for variable, unlimited length HID, UID, and CID strings.
  - Support Processor objects the same as Devices (HID,UID,CID,ADR,STA, 
 etc.)
  - Call the _SxW power methods on behalf of a device object.
  - Determine if a device is a PCI root bridge.
  - Change the ACPI_BUFFER parameter to ACPI_DEVICE_INFO.
 These changes will require an update to all callers of this interface. See 
 the updated ACPICA Programmer Reference for details. One new source file 
 has 
 been added - utilities/utids.c. ACPICA BZ 368, 780.
 
 Updated the AcpiRead and AcpiWrite external interfaces to support 64-bit 
 transfers. The Value parameter has been extended from 32 bits to 64 bits 
 in 
 order to support new ACPI 4.0 tables. These changes will require an update 
 to 
 all callers of these interfaces. See the ACPICA Programmer Reference for 
 details. ACPICA BZ 768.
 
 Fixed several problems with AcpiAttachData. The handler was not invoked 
 when 
 the host node was deleted. The data sub-object was not automatically 
 deleted 
 when the host node was deleted. The interface to the handler had an unused 
 parameter, this was removed. ACPICA BZ 778.
 
 Enhanced the function that dumps ACPI table headers. All non-printable 
 characters in the string fields are now replaced with '?' (Signature, 
 OemId, 
 OemTableId, and CompilerId.) ACPI tables with non-printable characters in 
 these fields are occasionally seen in the field. ACPICA BZ 788.
 
 Fixed a problem with predefined method repair code where the code that 
 attempts to repair/convert an object of incorrect type is only executed on 
 the first time the predefined method is called. The mechanism that 
 disables 
 warnings on subsequent calls was interfering with the repair mechanism. 
 ACPICA BZ 781.
 
 Fixed a possible memory leak in the predefined validation/repair code when 
 a 
 buffer is automatically converted to an expected string object.
 
 Removed obsolete 16-bit files from the distribution and from the current 
 git 
 tree head. ACPICA BZ 776.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  83.4K Code, 17.5K Data, 100.9K Total
     Debug Version:     158.9K Code, 50.0K Data, 208.9K Total
   Current Release:
     Non-Debug Version:  84.7K Code, 17.8K Data, 102.5K Total
     Debug Version:     160.5K Code, 50.6K Data, 211.1K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 ACPI 4.0: iASL and Disassembler - implemented support for the new IPMI 
 operation region keyword. ACPICA BZ 771, 772. Lin Ming.
 
 ACPI 4.0: iASL - implemented compile-time validation support for all new 
 predefined names and control methods (31 total). ACPICA BZ 769.
 
 ----------------------------------------
 21 May 2009. Summary of changes for version 20090521:
 
 1) ACPI CA Core Subsystem:
 
 Disabled the preservation of the SCI enable bit in the PM1 control 
 register. 
 The SCI enable bit (bit 0, SCI_EN) is defined by the ACPI specification to 
 be 
 a "preserved" bit - "OSPM always preserves this bit position", section 
 4.7.3.2.1. However, some machines fail if this bit is in fact preserved 
 because the bit needs to be explicitly set by the OS as a workaround. No 
 machines fail if the bit is not preserved. Therefore, ACPICA no longer 
 attempts to preserve this bit.
 
 Fixed a problem in AcpiRsGetPciRoutingTableLength where an invalid or 
 incorrectly formed _PRT package could cause a fault. Added validation to 
 ensure that each package element is actually a sub-package.
 
 Implemented a new interface to install or override a single control 
 method, 
 AcpiInstallMethod. This interface is useful when debugging in order to 
 repair 
 an existing method or to install a missing method without having to 
 override 
 the entire ACPI table. See the ACPICA Programmer Reference for use and 
 examples. Lin Ming, Bob Moore.
 
 Fixed several reference count issues with the DdbHandle object that is 
 created from a Load or LoadTable operator. Prevent premature deletion of 
 the 
 object. Also, mark the object as invalid once the table has been unloaded. 
 This is needed because the handle itself may not be deleted after the 
 table 
 unload, depending on whether it has been stored in a named object by the 
 caller. Lin Ming.
 
 Fixed a problem with Mutex Sync Levels. Fixed a problem where if multiple 
 mutexes of the same sync level are acquired but then not released in 
 strict 
 opposite order, the internally maintained Current Sync Level becomes 
 confused 
 and can cause subsequent execution errors. ACPICA BZ 471.
 
 Changed the allowable release order for ASL mutex objects. The ACPI 4.0 
 specification has been changed to make the SyncLevel for mutex objects 
 more 
 useful. When releasing a mutex, the SyncLevel of the mutex must now be the 
 same as the current sync level. This makes more sense than the previous 
 rule 
 (SyncLevel less than or equal). This change updates the code to match the 
 specification.
 
 Fixed a problem with the local version of the AcpiOsPurgeCache function. 
 The 
 (local) cache must be locked during all cache object deletions. Andrew 
 Baumann.
 
 Updated the Load operator to use operation region interfaces. This 
 replaces 
 direct memory mapping with region access calls. Now, all region accesses 
 go 
 through the installed region handler as they should.
 
 Simplified and optimized the NsGetNextNode function. Reduced parameter 
 count 
 and reduced code for this frequently used function.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  82.8K Code, 17.5K Data, 100.3K Total
     Debug Version:     158.0K Code, 49.9K Data, 207.9K Total
   Current Release:
     Non-Debug Version:  83.4K Code, 17.5K Data, 100.9K Total
     Debug Version:     158.9K Code, 50.0K Data, 208.9K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Fixed some issues with DMAR, HEST, MADT tables. Some 
 problems 
 with sub-table disassembly and handling invalid sub-tables. Attempt 
 recovery 
 after an invalid sub-table ID.
 
 ----------------------------------------
 22 April 2009. Summary of changes for version 20090422:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a compatibility issue with the recently released I/O port protection 
 mechanism. For windows compatibility, 1) On a port protection violation, 
 simply ignore the request and do not return an exception (allow the 
 control 
 method to continue execution.) 2) If only part of the request overlaps a 
 protected port, read/write the individual ports that are not protected. 
 Linux 
 BZ 13036. Lin Ming
 
 Enhanced the execution of the ASL/AML BreakPoint operator so that it 
 actually 
 breaks into the AML debugger if the debugger is present. This matches the 
 ACPI-defined behavior.
 
 Fixed several possible warnings related to the use of the configurable 
 ACPI_THREAD_ID. This type can now be configured as either an integer or a 
 pointer with no warnings. Also fixes several warnings in printf-like 
 statements for the 64-bit build when the type is configured as a pointer. 
 ACPICA BZ 766, 767.
 
 Fixed a number of possible warnings when compiling with gcc 4+ (depending 
 on 
 warning options.) Examples include printf formats, aliasing, unused 
 globals, 
 missing prototypes, missing switch default statements, use of non-ANSI 
 library functions, use of non-ANSI constructs. See generate/unix/Makefile 
 for 
 a list of warning options used with gcc 3 and 4. ACPICA BZ 735.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  82.6K Code, 17.6K Data, 100.2K Total
     Debug Version:     157.7K Code, 49.9K Data, 207.6K Total
   Current Release:
     Non-Debug Version:  82.8K Code, 17.5K Data, 100.3K Total
     Debug Version:     158.0K Code, 49.9K Data, 207.9K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Fixed a generation warning from Bison 2.3 and fixed several warnings 
 on 
 the 64-bit build.
 
 iASL: Fixed a problem where the Unix/Linux versions of the compiler could 
 not 
 correctly digest Windows/DOS formatted files (with CR/LF).
 
 iASL: Added a new option for "quiet mode" (-va) that produces only the 
 compilation summary, not individual errors and warnings. Useful for large 
 batch compilations.
 
 AcpiExec: Implemented a new option (-z) to enable a forced semaphore/mutex 
 timeout that can be used to detect hang conditions during execution of AML 
 code (includes both internal semaphores and AML-defined mutexes and 
 events.)
 
 Added new makefiles for the generation of acpica in a generic unix-like 
 environment. These makefiles are intended to generate the acpica tools and 
 utilities from the original acpica git source tree structure.
 
 Test Suites: Updated and cleaned up the documentation files. Updated the 
 copyrights to 2009, affecting all source files. Use the new version of 
 iASL 
 with quiet mode. Increased the number of available semaphores in the 
 Windows 
 OSL, allowing the aslts to execute fully on Windows. For the Unix OSL, 
 added 
 an alternate implementation of the semaphore timeout to allow aslts to 
 execute fully on Cygwin.
 
 ----------------------------------------
 20 March 2009. Summary of changes for version 20090320:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a possible race condition between AcpiWalkNamespace and dynamic 
 table 
 unloads. Added a reader/writer locking mechanism to allow multiple 
 concurrent 
 namespace walks (readers), but block a dynamic table unload until it can 
 gain 
 exclusive write access to the namespace. This fixes a problem where a 
 table 
 unload could (possibly catastrophically) delete the portion of the 
 namespace 
 that is currently being examined by a walk. Adds a new file, utlock.c, 
 that 
 implements the reader/writer lock mechanism. ACPICA BZ 749.
 
 Fixed a regression introduced in version 20090220 where a change to the 
 FADT 
 handling could cause the ACPICA subsystem to access non-existent I/O 
 ports.
 
 Modified the handling of FADT register and table (FACS/DSDT) addresses. 
 The 
 FADT can contain both 32-bit and 64-bit versions of these addresses. 
 Previously, the 64-bit versions were favored, meaning that if both 32 and 
 64 
 versions were valid, but not equal, the 64-bit version was used. This was 
 found to cause some machines to fail. Now, in this case, the 32-bit 
 version 
 is used instead. This now matches the Windows behavior.
 
 Implemented a new mechanism to protect certain I/O ports. Provides 
 Microsoft 
 compatibility and protects the standard PC I/O ports from access via AML 
 code. Adds a new file, hwvalid.c
 
 Fixed a possible extraneous warning message from the FADT support. The 
 message warns of a 32/64 length mismatch between the legacy and GAS 
 definitions for a register.
 
 Removed the obsolete AcpiOsValidateAddress OSL interface. This interface 
 is 
 made obsolete by the port protection mechanism above. It was previously 
 used 
 to validate the entire address range of an operation region, which could 
 be 
 incorrect if the range included illegal ports, but fields within the 
 operation region did not actually access those ports. Validation is now 
 performed on a per-field basis instead of the entire region.
 
 Modified the handling of the PM1 Status Register ignored bit (bit 11.) 
 Ignored bits must be "preserved" according to the ACPI spec. Usually, this 
 means a read/modify/write when writing to the register. However, for 
 status 
 registers, writing a one means clear the event. Writing a zero means 
 preserve 
 the event (do not clear.) This behavior is clarified in the ACPI 4.0 spec, 
 and the ACPICA code now simply always writes a zero to the ignored bit.
 
 Modified the handling of ignored bits for the PM1 A/B Control Registers. 
 As 
 per the ACPI specification, for the control registers, preserve 
 (read/modify/write) all bits that are defined as either reserved or 
 ignored.
 
 Updated the handling of write-only bits in the PM1 A/B Control Registers. 
 When reading the register, zero the write-only bits as per the ACPI spec. 
 ACPICA BZ 443. Lin Ming.
 
 Removed "Linux" from the list of supported _OSI strings. Linux no longer 
 wants to reply true to this request. The Windows strings are the only 
 paths 
 through the AML that are tested and known to work properly.
 
   Previous Release:
     Non-Debug Version:  82.0K Code, 17.5K Data,  99.5K Total
     Debug Version:     156.9K Code, 49.8K Data, 206.7K Total
   Current Release:
     Non-Debug Version:  82.6K Code, 17.6K Data, 100.2K Total
     Debug Version:     157.7K Code, 49.9K Data, 207.6K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Acpiexec: Split the large aeexec.c file into two new files, aehandlers.c 
 and 
 aetables.c
 
 ----------------------------------------
 20 February 2009. Summary of changes for version 20090220:
 
 1) ACPI CA Core Subsystem:
 
 Optimized the ACPI register locking. Removed locking for reads from the 
 ACPI 
 bit registers in PM1 Status, Enable, Control, and PM2 Control. The lock is 
 not required when reading the single-bit registers. The 
 AcpiGetRegisterUnlocked function is no longer needed and has been removed. 
 This will improve performance for reads on these registers. ACPICA BZ 760.
 
 Fixed the parameter validation for AcpiRead/Write. Now return 
 AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS 
 if 
 the register has an address of zero. Previously, these cases simply 
 returned 
 AE_OK. For optional registers such as PM1B status/enable/control, the 
 caller 
 should check for a valid register address before calling. ACPICA BZ 748.
 
 Renamed the external ACPI bit register access functions. Renamed 
 AcpiGetRegister and AcpiSetRegister to clarify the purpose of these 
 functions. The new names are AcpiReadBitRegister and AcpiWriteBitRegister. 
 Also, restructured the code for these functions by simplifying the code 
 path 
 and condensing duplicate code to reduce code size.
 
 Added new functions to transparently handle the possibly split PM1 A/B 
 registers. AcpiHwReadMultiple and AcpiHwWriteMultiple. These two functions 
 now handle the split registers for PM1 Status, Enable, and Control. ACPICA 
 BZ 
 746.
 
 Added a function to handle the PM1 control registers, 
 AcpiHwWritePm1Control. 
 This function writes both of the PM1 control registers (A/B). These 
 registers 
 are different than the PM1 A/B status and enable registers in that 
 different 
 values can be written to the A/B registers. Most notably, the SLP_TYP bits 
 can be different, as per the values returned from the _Sx predefined 
 methods.
 
 Removed an extra register write within AcpiHwClearAcpiStatus. This 
 function 
 was writing an optional PM1B status register twice. The existing call to 
 the 
 low-level AcpiHwRegisterWrite automatically handles a possibly split PM1 
 A/B 
 register. ACPICA BZ 751.
 
 Split out the PM1 Status registers from the FADT. Added new globals for 
 these 
 registers (A/B), similar to the way the PM1 Enable registers are handled. 
 Instead of overloading the FADT Event Register blocks. This makes the code 
 clearer and less prone to error.
 
 Fixed the warning message for when the platform contains too many ACPI 
 tables 
 for the default size of the global root table data structure. The 
 calculation 
 for the truncation value was incorrect.
 
 Removed the ACPI_GET_OBJECT_TYPE macro. Removed all instances of this 
 obsolete macro, since it is now a simple reference to ->common.type. There 
 were about 150 invocations of the macro across 41 files. ACPICA BZ 755.
 
 Removed the redundant ACPI_BITREG_SLEEP_TYPE_B. This type is the same as 
 TYPE_A. Removed this and all related instances. Renamed SLEEP_TYPE_A to 
 simply SLEEP_TYPE. ACPICA BZ 754.
 
 Conditionally compile the AcpiSetFirmwareWakingVector64 function. This 
 function is only needed on 64-bit host operating systems and is thus not 
 included for 32-bit hosts.
 
 Debug output: print the input and result for invocations of the _OSI 
 reserved 
 control method via the ACPI_LV_INFO debug level. Also, reduced some of the 
 verbosity of this debug level. Len Brown.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  82.3K Code, 17.5K Data,  99.8K Total
     Debug Version:     157.3K Code, 49.8K Data, 207.1K Total
   Current Release:
     Non-Debug Version:  82.0K Code, 17.5K Data,  99.5K Total
     Debug Version:     156.9K Code, 49.8K Data, 206.7K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Decode the FADT PM_Profile field. Emit ascii names for the 
 various legal performance profiles.
 
 ----------------------------------------
 23 January 2009. Summary of changes for version 20090123:
 
 1) ACPI CA Core Subsystem:
 
 Added the 2009 copyright to all module headers and signons. This affects 
 virtually every file in the ACPICA core subsystem, the iASL compiler, and 
 the tools/utilities.
 
 Implemented a change to allow the host to override any ACPI table, 
 including 
 dynamically loaded tables. Previously, only the DSDT could be replaced by 
 the 
 host. With this change, the AcpiOsTableOverride interface is called for 
 each 
 table found in the RSDT/XSDT during ACPICA initialization, and also 
 whenever 
 a table is dynamically loaded via the AML Load operator.
 
 Updated FADT flag definitions, especially the Boot Architecture flags.
 
 Debugger: For the Find command, automatically pad the input ACPI name with 
 underscores if the name is shorter than 4 characters. This enables a match 
 with the actual namespace entry which is itself padded with underscores.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  82.3K Code, 17.4K Data,  99.7K Total
     Debug Version:     157.1K Code, 49.7K Data, 206.8K Total
   Current Release:
     Non-Debug Version:  82.3K Code, 17.5K Data,  99.8K Total
     Debug Version:     157.3K Code, 49.8K Data, 207.1K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fix build error under Bison-2.4.
 
 Dissasembler: Enhanced FADT support. Added decoding of the Boot 
 Architecture 
 flags. Now decode all flags, regardless of the FADT version. Flag output 
 includes the FADT version which first defined each flag.
 
 The iASL -g option now dumps the RSDT to a file (in addition to the FADT 
 and 
 DSDT). Windows only.
 
 ----------------------------------------
 04 December 2008. Summary of changes for version 20081204:
 
 1) ACPI CA Core Subsystem:
 
 The ACPICA Programmer Reference has been completely updated and revamped 
 for 
 this release. This includes updates to the external interfaces, OSL 
 interfaces, the overview sections, and the debugger reference.
 
 Several new ACPICA interfaces have been implemented and documented in the 
 programmer reference:
 AcpiReset - Writes the reset value to the FADT-defined reset register.
 AcpiDisableAllGpes - Disable all available GPEs.
 AcpiEnableAllRuntimeGpes - Enable all available runtime GPEs.
 AcpiGetGpeDevice - Get the GPE block device associated with a GPE.
 AcpiGbl_CurrentGpeCount - Tracks the current number of available GPEs.
 AcpiRead - Low-level read ACPI register (was HwLowLevelRead.)
 AcpiWrite - Low-level write ACPI register (was HwLowLevelWrite.)
 
 Most of the public ACPI hardware-related interfaces have been moved to a 
 new 
 file, components/hardware/hwxface.c
 
 Enhanced the FADT parsing and low-level ACPI register access: The ACPI 
 register lengths within the FADT are now used, and the low level ACPI 
 register access no longer hardcodes the ACPI register lengths. Given that 
 there may be some risk in actually trusting the FADT register lengths, a 
 run-
 time option was added to fall back to the default hardcoded lengths if the 
 FADT proves to contain incorrect values - UseDefaultRegisterWidths. This 
 option is set to true for now, and a warning is issued if a suspicious 
 FADT 
 register length is overridden with the default value.
 
 Fixed a reference count issue in NsRepairObject. This problem was 
 introduced 
 in version 20081031 as part of a fix to repair Buffer objects within 
 Packages. Lin Ming.
 
 Added semaphore support to the Linux/Unix application OS-services layer 
 (OSL). ACPICA BZ 448. Lin Ming.
 
 Added the ACPI_MUTEX_TYPE configuration option to select whether mutexes 
 will 
 be implemented in the OSL, or will binary semaphores be used instead.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  81.7K Code, 17.3K Data,  99.0K Total
     Debug Version:     156.4K Code, 49.4K Data, 205.8K Total
   Current Release:
     Non-Debug Version:  82.3K Code, 17.4K Data,  99.7K Total
     Debug Version:     157.1K Code, 49.7K Data, 206.8K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Completed the '-e' option to include additional ACPI tables in order 
 to 
 aid with disassembly and External statement generation. ACPICA BZ 742. Lin 
 Ming.
 
 iASL: Removed the "named object in while loop" error. The compiler cannot 
 determine how many times a loop will execute. ACPICA BZ 730.
 
 Disassembler: Implemented support for FADT revision 2 (MS extension). 
 ACPICA 
 BZ 743.
 
 Disassembler: Updates for several ACPI data tables (HEST, EINJ, and MCFG).
 
 ----------------------------------------
 31 October 2008. Summary of changes for version 20081031:
 
 1) ACPI CA Core Subsystem:
 
 Restructured the ACPICA header files into public/private. acpi.h now 
 includes 
 only the "public" acpica headers. All other acpica headers are "private" 
 and 
 should not be included by acpica users. One new file, accommon.h is used 
 to 
 include the commonly used private headers for acpica code generation. 
 Future 
 plans include moving all private headers to a new subdirectory.
 
 Implemented an automatic Buffer->String return value conversion for 
 predefined ACPI methods. For these methods (such as _BIF), added automatic 
 conversion for return objects that are required to be a String, but a 
 Buffer 
 was found instead. This can happen when reading string battery data from 
 an 
 operation region, because it used to be difficult to convert the data from 
 buffer to string from within the ASL. Ensures that the host OS is provided 
 with a valid null-terminated string. Linux BZ 11822.
 
 Updated the FACS waking vector interfaces. Split 
 AcpiSetFirmwareWakingVector 
 into two: one for the 32-bit vector, another for the 64-bit vector. This 
 is 
 required because the host OS must setup the wake much differently for each 
 vector (real vs. protected mode, etc.) and the interface itself should not 
 be 
 deciding which vector to use. Also, eliminated the GetFirmwareWakingVector 
 interface, as it served no purpose (only the firmware reads the vector, OS 
 only writes the vector.) ACPICA BZ 731.
 
 Implemented a mechanism to escape infinite AML While() loops. Added a loop 
 counter to force exit from AML While loops if the count becomes too large. 
 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. The maximum 
 loop count is configurable. A new exception code is returned when a loop 
 is 
 broken, AE_AML_INFINITE_LOOP. Alexey Starikovskiy, Bob Moore.
 
 Optimized the execution of AML While loops. Previously, a control state 
 object was allocated and freed for each execution of the loop. The 
 optimization is to simply reuse the control state for each iteration. This 
 speeds up the raw loop execution time by about 5%.
 
 Enhanced the implicit return mechanism. For Windows compatibility, return 
 an 
 implicit integer of value zero for methods that contain no executable 
 code. 
 Such methods are seen in the field as stubs (presumably), and can cause 
 drivers to fail if they expect a return value. Lin Ming.
 
 Allow multiple backslashes as root prefixes in namepaths. In a fully 
 qualified namepath, allow multiple backslash prefixes. This can happen 
 (and 
 is seen in the field) because of the use of a double-backslash in strings 
 (since backslash is the escape character) causing confusion. ACPICA BZ 739 
 Lin Ming.
 
 Emit a warning if two different FACS or DSDT tables are discovered in the 
 FADT. Checks if there are two valid but different addresses for the FACS 
 and 
 DSDT within the FADT (mismatch between the 32-bit and 64-bit fields.)
 
 Consolidated the method argument count validation code. Merged the code 
 that 
 validates control method argument counts into the predefined validation 
 module. Eliminates possible multiple warnings for incorrect argument 
 counts.
 
 Implemented ACPICA example code. Includes code for ACPICA initialization, 
 handler installation, and calling a control method. Available at 
 source/tools/examples.
 
 Added a global pointer for FACS table to simplify internal FACS access. 
 Use 
 the global pointer instead of using AcpiGetTableByIndex for each FACS 
 access. 
 This simplifies the code for the Global Lock and the Firmware Waking 
 Vector(s).
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  81.2K Code, 17.0K Data,  98.2K Total
     Debug Version:     155.8K Code, 49.1K Data, 204.9K Total
   Current Release:
     Non-Debug Version:  81.7K Code, 17.3K Data,  99.0K Total
     Debug Version:     156.4K Code, 49.4K Data, 205.8K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Improved disassembly of external method calls. Added the -e option 
 to 
 allow the inclusion of additional ACPI tables to help with the disassembly 
 of 
 method invocations and the generation of external declarations during the 
 disassembly. Certain external method invocations cannot be disassembled 
 properly without the actual declaration of the method. Use the -e option 
 to 
 include the table where the external method(s) are actually declared. Most 
 useful for disassembling SSDTs that make method calls back to the master 
 DSDT. Lin Ming. Example: To disassemble an SSDT with calls to DSDT:  iasl 
 -d 
 -e dsdt.aml ssdt1.aml
 
 iASL: Fix to allow references to aliases within ASL namepaths. Fixes a 
 problem where the use of an alias within a namepath would result in a not 
 found error or cause the compiler to fault. Also now allows forward 
 references from the Alias operator itself. ACPICA BZ 738.
 
 ----------------------------------------
 26 September 2008. Summary of changes for version 20080926:
 
 1) ACPI CA Core Subsystem:
 
 Designed and implemented a mechanism to validate predefined ACPI methods 
 and 
 objects. This code validates the predefined ACPI objects (objects whose 
 names 
 start with underscore) that appear in the namespace, at the time they are 
 evaluated. The argument count and the type of the returned object are 
 validated against the ACPI specification. The purpose of this validation 
 is 
 to detect problems with the BIOS-implemented predefined ACPI objects 
 before 
 the results are returned to the ACPI-related drivers. Future enhancements 
 may 
 include actual repair of incorrect return objects where possible. Two new 
 files are nspredef.c and acpredef.h.
 
 Fixed a fault in the AML parser if a memory allocation fails during the Op 
 completion routine AcpiPsCompleteThisOp. Lin Ming. ACPICA BZ 492.
 
 Fixed an issue with implicit return compatibility. This change improves 
 the 
 implicit return mechanism to be more compatible with the MS interpreter. 
 Lin 
 Ming, ACPICA BZ 349.
 
 Implemented support for zero-length buffer-to-string conversions. Allow 
 zero 
 length strings during interpreter buffer-to-string conversions. For 
 example, 
 during the ToDecimalString and ToHexString operators, as well as implicit 
 conversions. Fiodor Suietov, ACPICA BZ 585.
 
 Fixed two possible memory leaks in the error exit paths of 
 AcpiUtUpdateObjectReference and AcpiUtWalkPackageTree. These functions are 
 similar in that they use a stack of state objects in order to eliminate 
 recursion. The stack must be fully unwound and deallocated if an error 
 occurs. Lin Ming. ACPICA BZ 383.
 
 Removed the unused ACPI_BITREG_WAKE_ENABLE definition and entry in the 
 global 
 ACPI register table. This bit does not exist and is unused. Lin Ming, Bob 
 Moore ACPICA BZ 442.
 
 Removed the obsolete version number in module headers. Removed the 
 "$Revision" number that appeared in each module header. This version 
 number 
 was useful under SourceSafe and CVS, but has no meaning under git. It is 
 not 
 only incorrect, it could also be misleading.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.7K Code, 16.4K Data,  96.1K Total
     Debug Version:     153.7K Code, 48.2K Data, 201.9K Total
   Current Release:
     Non-Debug Version:  81.2K Code, 17.0K Data,  98.2K Total
     Debug Version:     155.8K Code, 49.1K Data, 204.9K Total
 
 ----------------------------------------
 29 August 2008. Summary of changes for version 20080829:
 
 1) ACPI CA Core Subsystem:
 
 Completed a major cleanup of the internal ACPI_OPERAND_OBJECT of type 
 Reference. Changes include the elimination of cheating on the Object field 
 for the DdbHandle subtype, addition of a reference class field to 
 differentiate the various reference types (instead of an AML opcode), and 
 the 
 cleanup of debug output for this object. Lin Ming, Bob Moore. BZ 723
 
 Reduce an error to a warning for an incorrect method argument count. 
 Previously aborted with an error if too few arguments were passed to a 
 control method via the external ACPICA interface. Now issue a warning 
 instead 
 and continue. Handles the case where the method inadvertently declares too 
 many arguments, but does not actually use the extra ones. Applies mainly 
 to 
 the predefined methods. Lin Ming. Linux BZ 11032.
 
 Disallow the evaluation of named object types with no intrinsic value. 
 Return 
 AE_TYPE for objects that have no value and therefore evaluation is 
 undefined: 
 Device, Event, Mutex, Region, Thermal, and Scope. Previously, evaluation 
 of 
 these types were allowed, but an exception would be generated at some 
 point 
 during the evaluation. Now, the error is generated up front.
 
 Fixed a possible memory leak in the AcpiNsGetExternalPathname function 
 (nsnames.c). Fixes a leak in the error exit path.
 
 Removed the obsolete debug levels ACPI_DB_WARN and ACPI_DB_ERROR. These 
 debug 
 levels were made obsolete by the ACPI_WARNING, ACPI_ERROR, and 
 ACPI_EXCEPTION 
 interfaces. Also added ACPI_DB_EVENTS to correspond with the existing 
 ACPI_LV_EVENTS.
 
 Removed obsolete and/or unused exception codes from the acexcep.h header. 
 There is the possibility that certain device drivers may be affected if 
 they 
 use any of these exceptions.
 
 The ACPICA documentation has been added to the public git source tree, 
 under 
 acpica/documents. Included are the ACPICA programmer reference, the iASL 
 compiler reference, and the changes.txt release logfile.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.7K Code, 16.4K Data,  96.1K Total
     Debug Version:     153.9K Code, 48.4K Data, 202.3K Total
   Current Release:
     Non-Debug Version:  79.7K Code, 16.4K Data,  96.1K Total
     Debug Version:     153.7K Code, 48.2K Data, 201.9K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Allow multiple argument counts for the predefined _SCP method. ACPI 3.0 
 defines _SCP with 3 arguments. Previous versions defined it with only 1 
 argument. iASL now allows both definitions.
 
 iASL/disassembler: avoid infinite loop on bad ACPI tables. Check for zero-
 length subtables when disassembling ACPI tables. Also fixed a couple of 
 errors where a full 16-bit table type field was not extracted from the 
 input 
 properly.
 
 acpisrc: Improve comment counting mechanism for generating source code 
 statistics. Count first and last lines of multi-line comments as 
 whitespace, 
 not comment lines. Handle Linux legal header in addition to standard 
 acpica 
 header.
 
 ----------------------------------------
 
 29 July 2008. Summary of changes for version 20080729:
 
 1) ACPI CA Core Subsystem:
 
 Fix a possible deadlock in the GPE dispatch. Remove call to 
 AcpiHwDisableAllGpes during wake in AcpiEvGpeDispatch. This call will 
 attempt 
 to acquire the GPE lock but can deadlock since the GPE lock is already 
 held 
 at dispatch time. This code was introduced in version 20060831 as a 
 response 
 to Linux BZ 6881 and has since been removed from Linux.
 
 Add a function to dereference returned reference objects. Examines the 
 return 
 object from a call to AcpiEvaluateObject. Any Index or RefOf references 
 are 
 automatically dereferenced in an attempt to return something useful (these 
 reference types cannot be converted into an external ACPI_OBJECT.) 
 Provides 
 MS compatibility. Lin Ming, Bob Moore. Linux BZ 11105
 
 x2APIC support: changes for MADT and SRAT ACPI tables. There are 2 new 
 subtables for the MADT and one new subtable for the SRAT. Includes 
 disassembler and AcpiSrc support. Data from the Intel 64 Architecture 
 x2APIC 
 Specification, June 2008.
 
 Additional error checking for pathname utilities. Add error check after 
 all 
 calls to AcpiNsGetPathnameLength. Add status return from 
 AcpiNsBuildExternalPath and check after all calls. Add parameter 
 validation 
 to AcpiUtInitializeBuffer. Reported by and initial patch by Ingo Molnar.
 
 Return status from the global init function AcpiUtGlobalInitialize. This 
 is 
 used by both the kernel subsystem and the utilities such as iASL compiler. 
 The function could possibly fail when the caches are initialized. Yang Yi.
 
 Add a function to decode reference object types to strings. Created for 
 improved error messages. 
 
 Improve object conversion error messages. Better error messages during 
 object 
 conversion from internal to the external ACPI_OBJECT. Used for external 
 calls 
 to AcpiEvaluateObject.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.6K Code, 16.2K Data,  95.8K Total
     Debug Version:     153.5K Code, 48.2K Data, 201.7K Total
   Current Release:
     Non-Debug Version:  79.7K Code, 16.4K Data,  96.1K Total
     Debug Version:     153.9K Code, 48.4K Data, 202.3K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Debugger: fix a possible hang when evaluating non-methods. Fixes a problem 
 introduced in version 20080701. If the object being evaluated (via execute 
 command) is not a method, the debugger can hang while trying to obtain 
 non-
 existent parameters.
 
 iASL: relax error for using reserved "_T_x" identifiers. These names can 
 appear in a disassembled ASL file if they were emitted by the original 
 compiler. Instead of issuing an error or warning and forcing the user to 
 manually change these names, issue a remark instead.
 
 iASL: error if named object created in while loop. Emit an error if any 
 named 
 object is created within a While loop. If allowed, this code will generate 
 a 
 run-time error on the second iteration of the loop when an attempt is made 
 to 
 create the same named object twice. ACPICA bugzilla 730.
 
 iASL: Support absolute pathnames for include files. Add support for 
 absolute 
 pathnames within the Include operator. previously, only relative pathnames 
 were supported.
 
 iASL: Enforce minimum 1 interrupt in interrupt macro and Resource 
 Descriptor. 
 The ACPI spec requires one interrupt minimum. BZ 423
 
 iASL: Handle a missing ResourceSource arg, with a present SourceIndex. 
 Handles the case for the Interrupt Resource Descriptor where
 the ResourceSource argument is omitted but ResourceSourceIndex
 is present. Now leave room for the Index. BZ 426
 
 iASL: Prevent error message if CondRefOf target does not exist. Fixes 
 cases 
 where an error message is emitted if the target does not exist. BZ 516
 
 iASL: Fix broken -g option (get Windows ACPI tables). Fixes the -g option 
 (get ACPI tables on Windows). This was apparently broken in version 
 20070919.
 
 AcpiXtract: Handle EOF while extracting data. Correctly handle the case 
 where 
 the EOF happens immediately after the last table in the input file. Print 
 completion message. Previously, no message was displayed in this case.
 
 ----------------------------------------
 01 July 2008. Summary of changes for version 20080701:
 
 0) Git source tree / acpica.org
 
 Fixed a problem where a git-clone from http would not transfer the entire 
 source tree.
 
 1) ACPI CA Core Subsystem:
 
 Implemented a "careful" GPE disable in AcpiEvDisableGpe, only modify one 
 enable bit. Now performs a read-change-write of the enable register 
 instead 
 of simply writing out the cached enable mask. This will prevent 
 inadvertent 
 enabling of GPEs if a rogue GPE is received during initialization (before 
 GPE 
 handlers are installed.)
 
 Implemented a copy for dynamically loaded tables. Previously, dynamically 
 loaded tables were simply mapped - but on some machines this memory is 
 corrupted after suspend. Now copy the table to a local buffer. For the 
 OpRegion case, added checksum verify. Use the table length from the table 
 header, not the region length. For the Buffer case, use the table length 
 also. Dennis Noordsij, Bob Moore. BZ 10734
 
 Fixed a problem where the same ACPI table could not be dynamically loaded 
 and 
 unloaded more than once. Without this change, a table cannot be loaded 
 again 
 once it has been loaded/unloaded one time. The current mechanism does not 
 unregister a table upon an unload. During a load, if the same table is 
 found, 
 this no longer returns an exception. BZ 722
 
 Fixed a problem where the wrong descriptor length was calculated for the 
 EndTag descriptor in 64-bit mode. The "minimal" descriptors such as EndTag 
 are calculated as 12 bytes long, but the actual length in the internal 
 descriptor is 16 because of the round-up to 8 on the 64-bit build. 
 Reported 
 by Linn Crosetto. BZ 728
 
 Fixed a possible memory leak in the Unload operator. The DdbHandle 
 returned 
 by Load() did not have its reference count decremented during unload, 
 leading 
 to a memory leak. Lin Ming. BZ 727
 
 Fixed a possible memory leak when deleting thermal/processor objects. Any 
 associated notify handlers (and objects) were not being deleted. Fiodor 
 Suietov. BZ 506
 
 Fixed the ordering of the ASCII names in the global mutex table to match 
 the 
 actual mutex IDs. Used by AcpiUtGetMutexName, a function used for debug 
 only. 
 Vegard Nossum. BZ 726
 
 Enhanced the AcpiGetObjectInfo interface to return the number of required 
 arguments if the object is a control method. Added this call to the 
 debugger 
 so the proper number of default arguments are passed to a method. This 
 prevents a warning when executing methods from AcpiExec.
 
 Added a check for an invalid handle in AcpiGetObjectInfo. Return 
 AE_BAD_PARAMETER if input handle is invalid. BZ 474
 
 Fixed an extraneous warning from exconfig.c on the 64-bit build.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.3K Code, 16.2K Data,  95.5K Total
     Debug Version:     153.0K Code, 48.2K Data, 201.2K Total
   Current Release:
     Non-Debug Version:  79.6K Code, 16.2K Data,  95.8K Total
     Debug Version:     153.5K Code, 48.2K Data, 201.7K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Added two missing ACPI reserved names. Added _MTP and _ASZ, both 
 resource descriptor names.
 
 iASL: Detect invalid ASCII characters in input (windows version). Removed 
 the 
 "-CF" flag from the flex compile, enables correct detection of non-ASCII 
 characters in the input. BZ 441
 
 iASL: Eliminate warning when result of LoadTable is not used. Eliminate 
 the 
 "result of operation not used" warning when the DDB handle returned from 
 LoadTable is not used. The warning is not needed. BZ 590
 
 AcpiExec: Add support for dynamic table load/unload. Now calls _CFG method 
 to 
 pass address of table to the AML. Added option to disable OpRegion 
 simulation 
 to allow creation of an OpRegion with a real address that was passed to 
 _CFG. 
 All of this allows testing of the Load and Unload operators from AcpiExec.
 
 Debugger: update tables command for unloaded tables. Handle unloaded 
 tables 
 and use the standard table header output routine.
 
 ----------------------------------------
 09 June 2008. Summary of changes for version 20080609:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a workaround for reversed _PRT entries. A significant number 
 of 
 BIOSs erroneously reverse the _PRT SourceName and the SourceIndex. This 
 change dynamically detects and repairs this problem. Provides 
 compatibility 
 with MS ACPI. BZ 6859
 
 Simplified the internal ACPI hardware interfaces to eliminate the locking 
 flag parameter from Register Read/Write. Added a new external interface, 
 AcpiGetRegisterUnlocked.
 
 Fixed a problem where the invocation of a GPE control method could hang. 
 This 
 was a regression introduced in 20080514. The new method argument count 
 validation mechanism can enter an infinite loop when a GPE method is 
 dispatched. Problem fixed by removing the obsolete code that passed GPE 
 block 
 information to the notify handler via the control method parameter 
 pointer.
 
 Fixed a problem where the _SST execution status was incorrectly returned 
 to 
 the caller of AcpiEnterSleepStatePrep. This was a regression introduced in 
 20080514. _SST is optional and a NOT_FOUND exception should never be 
 returned. BZ 716
 
 Fixed a problem where a deleted object could be accessed from within the 
 AML 
 parser. This was a regression introduced in version 20080123 as a fix for 
 the 
 Unload operator. Lin Ming. BZ 10669
 
 Cleaned up the debug operand dump mechanism. Eliminated unnecessary 
 operands 
 and eliminated the use of a negative index in a loop. Operands are now 
 displayed in the correct order, not backwards. This also fixes a 
 regression 
 introduced in 20080514 on 64-bit systems where the elimination of 
 ACPI_NATIVE_UINT caused the negative index to go large and positive. BZ 
 715
 
 Fixed a possible memory leak in EvPciConfigRegionSetup where the error 
 exit 
 path did not delete a locally allocated structure.
 
 Updated definitions for the DMAR and SRAT tables to synchronize with the 
 current specifications. Includes disassembler support.
 
 Fixed a problem in the mutex debug code (in utmutex.c) where an incorrect 
 loop termination value was used. Loop terminated on iteration early, 
 missing 
 one mutex. Linn Crosetto
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.5K Code, 16.2K Data,  95.7K Total
     Debug Version:     153.3K Code, 48.3K Data, 201.6K Total
   Current Release:
     Non-Debug Version:  79.3K Code, 16.2K Data,  95.5K Total
     Debug Version:     153.0K Code, 48.2K Data, 201.2K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Implemented support for EisaId() within _CID objects. Now 
 disassemble integer _CID objects back to EisaId invocations, including 
 multiple integers within _CID packages. Includes single-step support for 
 debugger also.
 
 Disassembler: Added support for DMAR and SRAT table definition changes.
 
 ----------------------------------------
 14 May 2008. Summary of changes for version 20080514:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where GPEs were enabled too early during the ACPICA 
 initialization. This could lead to "handler not installed" errors on some 
 machines. Moved GPE enable until after _REG/_STA/_INI methods are run. 
 This 
 ensures that all operation regions and devices throughout the namespace 
 have 
 been initialized before GPEs are enabled. Alexey Starikovskiy, BZ 9916.
 
 Implemented a change to the enter sleep code. Moved execution of the _GTS 
 method to just before setting sleep enable bit. The execution was moved 
 from 
 AcpiEnterSleepStatePrep to AcpiEnterSleepState. _GTS is now executed 
 immediately before the SLP_EN bit is set, as per the ACPI specification. 
 Luming Yu, BZ 1653.
 
 Implemented a fix to disable unknown GPEs (2nd version). Now always 
 disable 
 the GPE, even if ACPICA thinks that that it is already disabled. It is 
 possible that the AML or some other code has enabled the GPE unbeknownst 
 to 
 the ACPICA code.
 
 Fixed a problem with the Field operator where zero-length fields would 
 return 
 an AE_AML_NO_OPERAND exception during table load. Fix enables zero-length 
 ASL 
 field declarations in Field(), BankField(), and IndexField(). BZ 10606.
 
 Implemented a fix for the Load operator, now load the table at the 
 namespace 
 root. This reverts a change introduced in version 20071019. The table is 
 now 
 loaded at the namespace root even though this goes against the ACPI 
 specification. This provides compatibility with other ACPI 
 implementations. 
 The ACPI specification will be updated to reflect this in ACPI 4.0. Lin 
 Ming.
 
 Fixed a problem where ACPICA would not Load() tables with unusual 
 signatures. 
 Now ignore ACPI table signature for Load() operator. Only "SSDT" is 
 acceptable to the ACPI spec, but tables are seen with OEMx and null sigs. 
 Therefore, signature validation is worthless. Apparently MS ACPI accepts 
 such 
 signatures, ACPICA must be compatible. BZ 10454.
 
 Fixed a possible negative array index in AcpiUtValidateException. Added 
 NULL 
 fields to the exception string arrays to eliminate a -1 subtraction on the 
 SubStatus field.
 
 Updated the debug tracking macros to reduce overall code and data size. 
 Changed ACPI_MODULE_NAME and ACPI_FUNCTION_NAME to use arrays of strings 
 instead of pointers to static strings. Jan Beulich and Bob Moore.
 
 Implemented argument count checking in control method invocation via 
 AcpiEvaluateObject. Now emit an error if too few arguments, warning if too 
 many. This applies only to extern programmatic control method execution, 
 not 
 method-to-method calls within the AML. Lin Ming.
 
 Eliminated the ACPI_NATIVE_UINT type across all ACPICA code. This type is 
 no 
 longer needed, especially with the removal of 16-bit support. It was 
 replaced 
 mostly with UINT32, but also ACPI_SIZE where a type that changes 32/64 bit 
 on 
 32/64-bit platforms is required.
 
 Added the C const qualifier for appropriate string constants -- mostly 
 MODULE_NAME and printf format strings. Jan Beulich.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has a 
 much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.0K Code, 17.4K Data,  97.4K Total
     Debug Version:     159.4K Code, 64.4K Data, 223.8K Total
   Current Release:
     Non-Debug Version:  79.5K Code, 16.2K Data,  95.7K Total
     Debug Version:     153.3K Code, 48.3K Data, 201.6K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented ACPI table revision ID validation in the disassembler. Zero is 
 always invalid. For DSDTs, the ID controls the interpreter integer width. 
 1 
 means 32-bit and this is unusual. 2 or greater is 64-bit.
 
 ----------------------------------------
 21 March 2008. Summary of changes for version 20080321:
 
 1) ACPI CA Core Subsystem:
 
 Implemented an additional change to the GPE support in order to suppress 
 spurious or stray GPEs. The AcpiEvDisableGpe function will now permanently 
 disable incoming GPEs that are neither enabled nor disabled -- meaning 
 that 
 the GPE is unknown to the system. This should prevent future interrupt 
 floods 
 from that GPE. BZ 6217 (Zhang Rui)
 
 Fixed a problem where NULL package elements were not returned to the 
 AcpiEvaluateObject interface correctly. The element was simply ignored 
 instead of returning a NULL ACPI_OBJECT package element, potentially 
 causing 
 a buffer overflow and/or confusing the caller who expected a fixed number 
 of 
 elements. BZ 10132 (Lin Ming, Bob Moore)
 
 Fixed a problem with the CreateField, CreateXXXField (Bit, Byte, Word, 
 Dword, 
 Qword), Field, BankField, and IndexField operators when invoked from 
 inside 
 an executing control method. In this case, these operators created 
 namespace 
 nodes that were incorrectly left marked as permanent nodes instead of 
 temporary nodes. This could cause a problem if there is race condition 
 between an exiting control method and a running namespace walk. (Reported 
 by 
 Linn Crosetto)
 
 Fixed a problem where the CreateField and CreateXXXField operators would 
 incorrectly allow duplicate names (the name of the field) with no 
 exception 
 generated.
 
 Implemented several changes for Notify handling. Added support for new 
 Notify 
 values (ACPI 2.0+) and improved the Notify debug output. Notify on 
 PowerResource objects is no longer allowed, as per the ACPI specification. 
 (Bob Moore, Zhang Rui)
 
 All Reference Objects returned via the AcpiEvaluateObject interface are 
 now 
 marked as type "REFERENCE" instead of "ANY". The type ANY is now reserved 
 for 
 NULL objects - either NULL package elements or unresolved named 
 references.
 
 Fixed a problem where an extraneous debug message was produced for package 
 objects (when debugging enabled). The message "Package List length larger 
 than NumElements count" is now produced in the correct case, and is now an 
 error message rather than a debug message. Added a debug message for the 
 opposite case, where NumElements is larger than the Package List (the 
 package 
 will be padded out with NULL elements as per the ACPI spec.)
 
 Implemented several improvements for the output of the ASL "Debug" object 
 to 
 clarify and keep all data for a given object on one output line.
 
 Fixed two size calculation issues with the variable-length Start Dependent 
 resource descriptor.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.7K Code, 17.3K Data,  97.0K Total
     Debug Version:     158.9K Code, 64.0K Data, 222.9K Total
   Current Release:
     Non-Debug Version:  80.0K Code, 17.4K Data,  97.4K Total
     Debug Version:     159.4K Code, 64.4K Data, 223.8K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed a problem with the use of the Switch operator where execution of the 
 containing method by multiple concurrent threads could cause an 
 AE_ALREADY_EXISTS exception. This is caused by the fact that there is no 
 actual Switch opcode, it must be simulated with local named temporary 
 variables and if/else pairs. The solution chosen was to mark any method 
 that 
 uses Switch as Serialized, thus preventing multiple thread entries. BZ 
 469.
 
 ----------------------------------------
 13 February 2008. Summary of changes for version 20080213:
 
 1) ACPI CA Core Subsystem:
 
 Implemented another MS compatibility design change for GPE/Notify 
 handling. 
 GPEs are now cleared/enabled asynchronously to allow all pending notifies 
 to 
 complete first. It is expected that the OSL will queue the enable request 
 behind all pending notify requests (may require changes to the local host 
 OSL 
 in AcpiOsExecute). Alexey Starikovskiy.
 
 Fixed a problem where buffer and package objects passed as arguments to a 
 control method via the external AcpiEvaluateObject interface could cause 
 an 
 AE_AML_INTERNAL exception depending on the order and type of operators 
 executed by the target control method.
 
 Fixed a problem where resource descriptor size optimization could cause a 
 problem when a _CRS resource template is passed to a _SRS method. The _SRS 
 resource template must use the same descriptors (with the same size) as 
 returned from _CRS. This change affects the following resource 
 descriptors: 
 IRQ / IRQNoFlags and StartDependendentFn / StartDependentFnNoPri. (BZ 
 9487)
 
 Fixed a problem where a CopyObject to RegionField, BankField, and 
 IndexField 
 objects did not perform an implicit conversion as it should. These types 
 must 
 retain their initial type permanently as per the ACPI specification. 
 However, 
 a CopyObject to all other object types should not perform an implicit 
 conversion, as per the ACPI specification. (Lin Ming, Bob Moore) BZ 388
 
 Fixed a problem with the AcpiGetDevices interface where the mechanism to 
 match device CIDs did not examine the entire list of available CIDs, but 
 instead aborted on the first non-matching CID. Andrew Patterson.
 
 Fixed a regression introduced in version 20071114. The ACPI_HIDWORD macro 
 was 
 inadvertently changed to return a 16-bit value instead of a 32-bit value, 
 truncating the upper dword of a 64-bit value. This macro is only used to 
 display debug output, so no incorrect calculations were made. Also, 
 reimplemented the macro so that a 64-bit shift is not performed by 
 inefficient compilers.
 
 Added missing va_end statements that should correspond with each va_start 
 statement.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.5K Code, 17.2K Data,  96.7K Total
     Debug Version:     159.0K Code, 63.8K Data, 222.8K Total
   Current Release:
     Non-Debug Version:  79.7K Code, 17.3K Data,  97.0K Total
     Debug Version:     158.9K Code, 64.0K Data, 222.9K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented full disassembler support for the following new ACPI tables: 
 BERT, EINJ, and ERST. Implemented partial disassembler support for the 
 complicated HEST table. These tables support the Windows Hardware Error 
 Architecture (WHEA).
 
 ----------------------------------------
 23 January 2008. Summary of changes for version 20080123:
 
 1) ACPI CA Core Subsystem:
 
 Added the 2008 copyright to all module headers and signons. This affects 
 virtually every file in the ACPICA core subsystem, the iASL compiler, and 
 the tools/utilities.
 
 Fixed a problem with the SizeOf operator when used with Package and Buffer 
 objects. These objects have deferred execution for some arguments, and the 
 execution is now completed before the SizeOf is executed. This problem 
 caused 
 unexpected AE_PACKAGE_LIMIT errors on some systems (Lin Ming, Bob Moore) 
 BZ 
 9558
 
 Implemented an enhancement to the interpreter "slack mode". In the absence 
 of 
 an explicit return or an implicitly returned object from the last executed 
 opcode, a control method will now implicitly return an integer of value 0 
 for 
 Microsoft compatibility. (Lin Ming) BZ 392
 
 Fixed a problem with the Load operator where an exception was not returned 
 in 
 the case where the table is already loaded. (Lin Ming) BZ 463
 
 Implemented support for the use of DDBHandles as an Indexed Reference, as 
 per 
 the ACPI spec. (Lin Ming) BZ 486
 
 Implemented support for UserTerm (Method invocation) for the Unload 
 operator 
 as per the ACPI spec. (Lin Ming) BZ 580
 
 Fixed a problem with the LoadTable operator where the OemId and OemTableId 
 input strings could cause unexpected failures if they were shorter than 
 the 
 maximum lengths allowed. (Lin Ming, Bob Moore) BZ 576
 
 Implemented support for UserTerm (Method invocation) for the Unload 
 operator 
 as per the ACPI spec. (Lin Ming) BZ 580
 
 Implemented header file support for new ACPI tables - BERT, ERST, EINJ, 
 HEST, 
 IBFT, UEFI, WDAT. Disassembler support is forthcoming.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.3K Code, 17.2K Data,  96.5K Total
     Debug Version:     158.6K Code, 63.8K Data, 222.4K Total
   Current Release:
     Non-Debug Version:  79.5K Code, 17.2K Data,  96.7K Total
     Debug Version:     159.0K Code, 63.8K Data, 222.8K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented support in the disassembler for checksum validation on 
 incoming 
 binary DSDTs and SSDTs. If incorrect, a message is displayed within the 
 table 
 header dump at the start of the disassembly.
 
 Implemented additional debugging information in the namespace listing file 
 created during compilation. In addition to the namespace hierarchy, the 
 full 
 pathname to each namespace object is displayed.
 
 Fixed a problem with the disassembler where invalid ACPI tables could 
 cause 
 faults or infinite loops.
 
 Fixed an unexpected parse error when using the optional "parameter types" 
 list in a control method declaration. (Lin Ming) BZ 397
 
 Fixed a problem where two External declarations with the same name did not 
 cause an error (Lin Ming) BZ 509
 
 Implemented support for full TermArgs (adding Argx, Localx and method 
 invocation) for the ParameterData parameter to the LoadTable operator. 
 (Lin 
 Ming) BZ 583,587
 
 ----------------------------------------
 19 December 2007. Summary of changes for version 20071219:
 
 1) ACPI CA Core Subsystem:
 
 Implemented full support for deferred execution for the TermArg string 
 arguments for DataTableRegion. This enables forward references and full 
 operand resolution for the three string arguments. Similar to 
 OperationRegion 
 deferred argument execution.) Lin Ming. BZ 430
 
 Implemented full argument resolution support for the BankValue argument to 
 BankField. Previously, only constants were supported, now any TermArg may 
 be 
 used. Lin Ming BZ 387, 393
 
 Fixed a problem with AcpiGetDevices where the search of a branch of the 
 device tree could be terminated prematurely. In accordance with the ACPI 
 specification, the search down the current branch is terminated if a 
 device 
 is both not present and not functional (instead of just not present.) 
 Yakui 
 Zhao.
 
 Fixed a problem where "unknown" GPEs could be allowed to fire repeatedly 
 if 
 the underlying AML code changed the GPE enable registers. Now, any unknown 
 incoming GPE (no _Lxx/_Exx method and not the EC GPE) is immediately 
 disabled 
 instead of simply ignored. Rui Zhang.
 
 Fixed a problem with Index Fields where the Index register was incorrectly 
 limited to a maximum of 32 bits. Now any size may be used.
 
 Fixed a couple memory leaks associated with "implicit return" objects when 
 the AML Interpreter slack mode is enabled. Lin Ming BZ 349
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.0K Code, 17.2K Data,  96.2K Total
     Debug Version:     157.9K Code, 63.6K Data, 221.5K Total
   Current Release:
     Non-Debug Version:  79.3K Code, 17.2K Data,  96.5K Total
     Debug Version:     158.6K Code, 63.8K Data, 222.4K Total
 
 ----------------------------------------
 14 November 2007. Summary of changes for version 20071114:
 
 1) ACPI CA Core Subsystem:
 
 Implemented event counters for each of the Fixed Events, the ACPI SCI 
 (interrupt) itself, and control methods executed. Named 
 AcpiFixedEventCount[], AcpiSciCount, and AcpiMethodCount respectively. 
 These 
 should be useful for debugging and statistics.
 
 Implemented a new external interface, AcpiGetStatistics, to retrieve the 
 contents of the various event counters. Returns the current values for 
 AcpiSciCount, AcpiGpeCount, the AcpiFixedEventCount array, and 
 AcpiMethodCount. The interface can be expanded in the future if new 
 counters 
 are added. Device drivers should use this interface rather than access the 
 counters directly.
 
 Fixed a problem with the FromBCD and ToBCD operators. With some compilers, 
 the ShortDivide function worked incorrectly, causing problems with the BCD 
 functions with large input values. A truncation from 64-bit to 32-bit 
 inadvertently occurred. Internal BZ 435. Lin Ming
 
 Fixed a problem with Index references passed as method arguments. 
 References 
 passed as arguments to control methods were dereferenced immediately 
 (before 
 control was passed to the called method). The references are now correctly 
 passed directly to the called method. BZ 5389. Lin Ming
 
 Fixed a problem with CopyObject used in conjunction with the Index 
 operator. 
 The reference was incorrectly dereferenced before the copy. The reference 
 is 
 now correctly copied. BZ 5391. Lin Ming
 
 Fixed a problem with Control Method references within Package objects. 
 These 
 references are now correctly generated. This completes the package 
 construction overhaul that began in version 20071019.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.8K Code, 17.2K Data,  96.0K Total
     Debug Version:     157.2K Code, 63.4K Data, 220.6K Total
   Current Release:
     Non-Debug Version:  79.0K Code, 17.2K Data,  96.2K Total
     Debug Version:     157.9K Code, 63.6K Data, 221.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 The AcpiExec utility now installs handlers for all of the predefined 
 Operation Region types. New types supported are: PCI_Config, CMOS, and 
 PCIBARTarget.
 
 Fixed a problem with the 64-bit version of AcpiExec where the extended 
 (64-
 bit) address fields for the DSDT and FACS within the FADT were not being 
 used, causing truncation of the upper 32-bits of these addresses. Lin Ming 
 and Bob Moore
 
 ----------------------------------------
 19 October 2007. Summary of changes for version 20071019:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem with the Alias operator when the target of the alias is a 
 named ASL operator that opens a new scope -- Scope, Device, PowerResource, 
 Processor, and ThermalZone. In these cases, any children of the original 
 operator could not be accessed via the alias, potentially causing 
 unexpected 
 AE_NOT_FOUND exceptions. (BZ 9067)
 
 Fixed a problem with the Package operator where all named references were 
 created as object references and left otherwise unresolved. According to 
 the 
 ACPI specification, a Package can only contain Data Objects or references 
 to 
 control methods. The implication is that named references to Data Objects 
 (Integer, Buffer, String, Package, BufferField, Field) should be resolved 
 immediately upon package creation. This is the approach taken with this 
 change. References to all other named objects (Methods, Devices, Scopes, 
 etc.) are all now properly created as reference objects. (BZ 5328)
 
 Reverted a change to Notify handling that was introduced in version 
 20070508. This version changed the Notify handling from asynchronous to 
 fully synchronous (Device driver Notify handling with respect to the 
 Notify 
 ASL operator). It was found that this change caused more problems than it 
 solved and was removed by most users.
 
 Fixed a problem with the Increment and Decrement operators where the type 
 of 
 the target object could be unexpectedly and incorrectly changed. (BZ 353) 
 Lin Ming.
 
 Fixed a problem with the Load and LoadTable operators where the table 
 location within the namespace was ignored. Instead, the table was always 
 loaded into the root or current scope. Lin Ming.
 
 Fixed a problem with the Load operator when loading a table from a buffer 
 object. The input buffer was prematurely zeroed and/or deleted. (BZ 577)
 
 Fixed a problem with the Debug object where a store of a DdbHandle 
 reference 
 object to the Debug object could cause a fault.
 
 Added a table checksum verification for the Load operator, in the case 
 where 
 the load is from a buffer. (BZ 578).
 
 Implemented additional parameter validation for the LoadTable operator. 
 The 
 length of the input strings SignatureString, OemIdString, and OemTableId 
 are 
 now checked for maximum lengths. (BZ 582) Lin Ming.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.5K Code, 17.1K Data,  95.6K Total
     Debug Version:     156.7K Code, 63.2K Data, 219.9K Total
   Current Release:
     Non-Debug Version:  78.8K Code, 17.2K Data,  96.0K Total
     Debug Version:     157.2K Code, 63.4K Data, 220.6K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem where if a single file was specified and the file did not 
 exist, no error message was emitted. (Introduced with wildcard support in 
 version 20070917.)
 
 ----------------------------------------
 19 September 2007. Summary of changes for version 20070919:
 
 1) ACPI CA Core Subsystem:
 
 Designed and implemented new external interfaces to install and remove 
 handlers for ACPI table-related events. Current events that are defined 
 are 
 LOAD and UNLOAD. These interfaces allow the host to track ACPI tables as 
 they are dynamically loaded and unloaded. See AcpiInstallTableHandler and 
 AcpiRemoveTableHandler. (Lin Ming and Bob Moore)
 
 Fixed a problem where the use of the AcpiGbl_AllMethodsSerialized flag 
 (acpi_serialized option on Linux) could cause some systems to hang during 
 initialization. (Bob Moore) BZ 8171
 
 Fixed a problem where objects of certain types (Device, ThermalZone, 
 Processor, PowerResource) can be not found if they are declared and 
 referenced from within the same control method (Lin Ming) BZ 341
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.3K Code, 17.0K Data,  95.3K Total
     Debug Version:     156.3K Code, 63.1K Data, 219.4K Total
   Current Release:
     Non-Debug Version:  78.5K Code, 17.1K Data,  95.6K Total
     Debug Version:     156.7K Code, 63.2K Data, 219.9K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support to allow multiple files to be compiled/disassembled in 
 a 
 single invocation. This includes command line wildcard support for both 
 the 
 Windows and Unix versions of the compiler. This feature simplifies the 
 disassembly and compilation of multiple ACPI tables in a single directory.
 
 ----------------------------------------
 08 May 2007. Summary of changes for version 20070508:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a Microsoft compatibility design change for the handling of 
 the 
 Notify AML operator. Previously, notify handlers were dispatched and 
 executed completely asynchronously in a deferred thread. The new design 
 still executes the notify handlers in a different thread, but the original 
 thread that executed the Notify() now waits at a synchronization point for 
 the notify handler to complete. Some machines depend on a synchronous 
 Notify 
 operator in order to operate correctly.
 
 Implemented support to allow Package objects to be passed as method 
 arguments to the external AcpiEvaluateObject interface. Previously, this 
 would return the AE_NOT_IMPLEMENTED exception. This feature had not been 
 implemented since there were no reserved control methods that required it 
 until recently.
 
 Fixed a problem with the internal FADT conversion where ACPI 1.0 FADTs 
 that 
 contained invalid non-zero values in reserved fields could cause later 
 failures because these fields have meaning in later revisions of the FADT. 
 For incoming ACPI 1.0 FADTs, these fields are now always zeroed. (The 
 fields 
 are: Preferred_PM_Profile, PSTATE_CNT, CST_CNT, and IAPC_BOOT_FLAGS.)
 
 Fixed a problem where the Global Lock handle was not properly updated if a 
 thread that acquired the Global Lock via executing AML code then attempted 
 to acquire the lock via the AcpiAcquireGlobalLock interface. Reported by 
 Joe 
 Liu.
 
 Fixed a problem in AcpiEvDeleteGpeXrupt where the global interrupt list 
 could be corrupted if the interrupt being removed was at the head of the 
 list. Reported by Linn Crosetto.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.9K Code, 63.1K Data, 219.0K Total
   Current Release:
     Non-Debug Version:  78.3K Code, 17.0K Data,  95.3K Total
     Debug Version:     156.3K Code, 63.1K Data, 219.4K Total
 
 ----------------------------------------
 20 March 2007. Summary of changes for version 20070320:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a change to the order of interpretation and evaluation of AML 
 operand objects within the AML interpreter. The interpreter now evaluates 
 operands in the order that they appear in the AML stream (and the 
 corresponding ASL code), instead of in the reverse order (after the entire 
 operand list has been parsed). The previous behavior caused several subtle 
 incompatibilities with the Microsoft AML interpreter as well as being 
 somewhat non-intuitive. BZ 7871, local BZ 263. Valery Podrezov.
 
 Implemented a change to the ACPI Global Lock support. All interfaces to 
 the 
 global lock now allow the same thread to acquire the lock multiple times. 
 This affects the AcpiAcquireGlobalLock external interface to the global 
 lock 
 as well as the internal use of the global lock to support AML fields -- a 
 control method that is holding the global lock can now simultaneously 
 access 
 AML fields that require global lock protection. Previously, in both cases, 
 this would have resulted in an AE_ALREADY_ACQUIRED exception. The change 
 to 
 AcpiAcquireGlobalLock is of special interest to drivers for the Embedded 
 Controller. There is no change to the behavior of the AML Acquire 
 operator, 
 as this can already be used to acquire a mutex multiple times by the same 
 thread. BZ 8066. With assistance from Alexey Starikovskiy.
 
 Fixed a problem where invalid objects could be referenced in the AML 
 Interpreter after error conditions. During operand evaluation, ensure that 
 the internal "Return Object" field is cleared on error and only valid 
 pointers are stored there. Caused occasional access to deleted objects 
 that 
 resulted in "large reference count" warning messages. Valery Podrezov.
 
 Fixed a problem where an AE_STACK_OVERFLOW internal exception could occur 
 on 
 deeply nested control method invocations. BZ 7873, local BZ 487. Valery 
 Podrezov.
 
 Fixed an internal problem with the handling of result objects on the 
 interpreter result stack. BZ 7872. Valery Podrezov.
 
 Removed obsolete code that handled the case where AML_NAME_OP is the 
 target 
 of a reference (Reference.Opcode). This code was no longer necessary. BZ 
 7874. Valery Podrezov.
 
 Removed obsolete ACPI_NO_INTEGER64_SUPPORT from two header files. This was 
 a 
 remnant from the previously discontinued 16-bit support.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.8K Code, 63.3K Data, 219.1K Total
   Current Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.9K Code, 63.1K Data, 219.0K Total
 
 ----------------------------------------
 26 January 2007. Summary of changes for version 20070126:
 
 1) ACPI CA Core Subsystem:
 
 Added the 2007 copyright to all module headers and signons. This affects 
 virtually every file in the ACPICA core subsystem, the iASL compiler, and 
 the utilities.
 
 Implemented a fix for an incorrect parameter passed to AcpiTbDeleteTable 
 during a table load. A bad pointer was passed in the case where the DSDT 
 is 
 overridden, causing a fault in this case.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.8K Code, 63.3K Data, 219.1K Total
   Current Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.8K Code, 63.3K Data, 219.1K Total
 
 ----------------------------------------
 15 December 2006. Summary of changes for version 20061215:
 
 1) ACPI CA Core Subsystem:
 
 Support for 16-bit ACPICA has been completely removed since it is no 
 longer 
 necessary and it clutters the code. All 16-bit macros, types, and 
 conditional compiles have been removed, cleaning up and simplifying the 
 code 
 across the entire subsystem. DOS support is no longer needed since the 
 bootable Linux firmware kit is now available.
 
 The handler for the Global Lock is now removed during AcpiTerminate to 
 enable a clean subsystem restart, via the implementation of the 
 AcpiEvRemoveGlobalLockHandler function. (With assistance from Joel Bretz, 
 HP)
 
 Implemented enhancements to the multithreading support within the debugger 
 to enable improved multithreading debugging and evaluation of the 
 subsystem. 
 (Valery Podrezov)
 
 Debugger: Enhanced the Statistics/Memory command to emit the total 
 (maximum) 
 memory used during the execution, as well as the maximum memory consumed 
 by 
 each of the various object types. (Valery Podrezov)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  77.9K Code, 17.0K Data,  94.9K Total
     Debug Version:     155.2K Code, 63.1K Data, 218.3K Total
   Current Release:
     Non-Debug Version:  78.0K Code, 17.1K Data,  95.1K Total
     Debug Version:     155.8K Code, 63.3K Data, 219.1K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 AcpiExec: Implemented a new option (-m) to display full memory use 
 statistics upon subsystem/program termination. (Valery Podrezov)
 
 ----------------------------------------
 09 November 2006. Summary of changes for version 20061109:
 
 1) ACPI CA Core Subsystem:
 
 Optimized the Load ASL operator in the case where the source operand is an 
 operation region. Simply map the operation region memory, instead of 
 performing a bytewise read. (Region must be of type SystemMemory, see 
 below.)
 
 Fixed the Load ASL operator for the case where the source operand is a 
 region field. A buffer object is also allowed as the source operand. BZ 
 480
 
 Fixed a problem where the Load ASL operator allowed the source operand to 
 be 
 an operation region of any type. It is now restricted to regions of type 
 SystemMemory, as per the ACPI specification. BZ 481
 
 Additional cleanup and optimizations for the new Table Manager code.
 
 AcpiEnable will now fail if all of the required ACPI tables are not loaded 
 (FADT, FACS, DSDT). BZ 477
 
 Added #pragma pack(8/4) to acobject.h to ensure that the structures in 
 this 
 header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been 
 manually optimized to be aligned and will not work if it is byte-packed. 
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  78.1K Code, 17.1K Data,  95.2K Total
     Debug Version:     155.4K Code, 63.1K Data, 218.5K Total
   Current Release:
     Non-Debug Version:  77.9K Code, 17.0K Data,  94.9K Total
     Debug Version:     155.2K Code, 63.1K Data, 218.3K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed a problem where the presence of the _OSI predefined control method 
 within complex expressions could cause an internal compiler error.
 
 AcpiExec: Implemented full region support for multiple address spaces. 
 SpaceId is now part of the REGION object. BZ 429
 
 ----------------------------------------
 11 October 2006. Summary of changes for version 20061011:
 
 1) ACPI CA Core Subsystem:
 
 Completed an AML interpreter performance enhancement for control method 
 execution. Previously a 2-pass parse/execution, control methods are now 
 completely parsed and executed in a single pass. This improves overall 
 interpreter performance by ~25%, reduces code size, and reduces CPU stack 
 use. (Valery Podrezov + interpreter changes in version 20051202 that 
 eliminated namespace loading during the pass one parse.)
 
 Implemented _CID support for PCI Root Bridge detection. If the _HID does 
 not 
 match the predefined PCI Root Bridge IDs, the _CID list (if present) is 
 now 
 obtained and also checked for an ID match.
 
 Implemented additional support for the PCI _ADR execution: upsearch until 
 a 
 device scope is found before executing _ADR. This allows PCI_Config 
 operation regions to be declared locally within control methods underneath 
 PCI device objects.
 
 Fixed a problem with a possible race condition between threads executing 
 AcpiWalkNamespace and the AML interpreter. This condition was removed by 
 modifying AcpiWalkNamespace to (by default) ignore all temporary namespace 
 entries created during any concurrent control method execution. An 
 additional namespace race condition is known to exist between 
 AcpiWalkNamespace and the Load/Unload ASL operators and is still under 
 investigation.
 
 Restructured the AML ParseLoop function, breaking it into several 
 subfunctions in order to reduce CPU stack use and improve maintainability. 
 (Mikhail Kouzmich)
 
 AcpiGetHandle: Fix for parameter validation to detect invalid combinations 
 of prefix handle and pathname. BZ 478
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  77.9K Code, 17.1K Data,  95.0K Total
     Debug Version:     154.6K Code, 63.0K Data, 217.6K Total
   Current Release:
     Non-Debug Version:  78.1K Code, 17.1K Data,  95.2K Total
     Debug Version:     155.4K Code, 63.1K Data, 218.5K Total
 
 2) iASL Compiler/Disassembler and Tools:
 
 Ported the -g option (get local ACPI tables) to the new ACPICA Table 
 Manager 
 to restore original behavior.
 
 ----------------------------------------
 27 September 2006. Summary of changes for version 20060927:
 
 1) ACPI CA Core Subsystem:
 
 Removed the "Flags" parameter from AcpiGetRegister and AcpiSetRegister. 
 These functions now use a spinlock for mutual exclusion and the interrupt 
 level indication flag is not needed.
 
 Fixed a problem with the Global Lock where the lock could appear to be 
 obtained before it is actually obtained. The global lock semaphore was 
 inadvertently created with one unit instead of zero units. (BZ 464) Fiodor 
 Suietov.
 
 Fixed a possible memory leak and fault in AcpiExResolveObjectToValue 
 during 
 a read from a buffer or region field. (BZ 458) Fiodor Suietov.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  77.9K Code, 17.1K Data,  95.0K Total
     Debug Version:     154.7K Code, 63.0K Data, 217.7K Total
   Current Release:
     Non-Debug Version:  77.9K Code, 17.1K Data,  95.0K Total
     Debug Version:     154.6K Code, 63.0K Data, 217.6K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed a compilation problem with the pre-defined Resource Descriptor field 
 names where an "object does not exist" error could be incorrectly 
 generated 
 if the parent ResourceTemplate pathname places the template within a 
 different namespace scope than the current scope. (BZ 7212)
 
 Fixed a problem where the compiler could hang after syntax errors detected 
 in an ElseIf construct. (BZ 453)
 
 Fixed a problem with the AmlFilename parameter to the DefinitionBlock() 
 operator. An incorrect output filename was produced when this parameter 
 was 
 a null string (""). Now, the original input filename is used as the AML 
 output filename, with an ".aml" extension.
 
 Implemented a generic batch command mode for the AcpiExec utility (execute 
 any AML debugger command) (Valery Podrezov).
 
 ----------------------------------------
 12 September 2006. Summary of changes for version 20060912:
 
 1) ACPI CA Core Subsystem:
 
 Enhanced the implementation of the "serialized mode" of the interpreter 
 (enabled via the AcpiGbl_AllMethodsSerialized flag.) When this mode is 
 specified, instead of creating a serialization semaphore per control 
 method, 
 the interpreter lock is simply no longer released before a blocking 
 operation during control method execution. This effectively makes the AML 
 Interpreter single-threaded. The overhead of a semaphore per-method is 
 eliminated.
 
 Fixed a regression where an error was no longer emitted if a control 
 method 
 attempts to create 2 objects of the same name. This once again returns 
 AE_ALREADY_EXISTS. When this exception occurs, it invokes the mechanism 
 that 
 will dynamically serialize the control method to possible prevent future 
 errors. (BZ 440)
 
 Integrated a fix for a problem with PCI Express HID detection in the PCI 
 Config Space setup procedure. (BZ 7145)
 
 Moved all FADT-related functions to a new file, tbfadt.c. Eliminated the 
 AcpiHwInitialize function - the FADT registers are now validated when the 
 table is loaded.
 
 Added two new warnings during FADT verification - 1) if the FADT is larger 
 than the largest known FADT version, and 2) if there is a mismatch between 
 a 
 32-bit block address and the 64-bit X counterpart (when both are non-
 zero.)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  77.9K Code, 16.7K Data,  94.6K Total
     Debug Version:     154.9K Code, 62.6K Data, 217.5K Total
   Current Release:
     Non-Debug Version:  77.9K Code, 17.1K Data,  95.0K Total
     Debug Version:     154.7K Code, 63.0K Data, 217.7K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed a problem with the implementation of the Switch() operator where the 
 temporary variable was declared too close to the actual Switch, instead of 
 at method level. This could cause a problem if the Switch() operator is 
 within a while loop, causing an error on the second iteration. (BZ 460)
 
 Disassembler - fix for error emitted for unknown type for target of scope 
 operator. Now, ignore it and continue.
 
 Disassembly of an FADT now verifies the input FADT and reports any errors 
 found. Fix for proper disassembly of full-sized (ACPI 2.0) FADTs.
 
 Disassembly of raw data buffers with byte initialization data now prefixes 
 each output line with the current buffer offset.
 
 Disassembly of ASF! table now includes all variable-length data fields at 
 the end of some of the subtables.
 
 The disassembler now emits a comment if a buffer appears to be a 
 ResourceTemplate, but cannot be disassembled as such because the EndTag 
 does 
 not appear at the very end of the buffer.
 
 AcpiExec - Added the "-t" command line option to enable the serialized 
 mode 
 of the AML interpreter.
 
 ----------------------------------------
 31 August 2006. Summary of changes for version 20060831:
 
 1) ACPI CA Core Subsystem:
 
 Miscellaneous fixes for the Table Manager:
 - Correctly initialize internal common FADT for all 64-bit "X" fields
 - Fixed a couple table mapping issues during table load
 - Fixed a couple alignment issues for IA64
 - Initialize input array to zero in AcpiInitializeTables
 - Additional parameter validation for AcpiGetTable, AcpiGetTableHeader, 
 AcpiGetTableByIndex
 
 Change for GPE support: when a "wake" GPE is received, all wake GPEs are 
 now 
 immediately disabled to prevent the waking GPE from firing again and to 
 prevent other wake GPEs from interrupting the wake process.
 
 Added the AcpiGpeCount global that tracks the number of processed GPEs, to 
 be used for debugging systems with a large number of ACPI interrupts.
 
 Implemented support for the "DMAR" ACPI table (DMA Redirection Table) in 
 both the ACPICA headers and the disassembler.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  77.8K Code, 16.5K Data,  94.3K Total
     Debug Version:     154.6K Code, 62.3K Data, 216.9K Total
   Current Release:
     Non-Debug Version:  77.9K Code, 16.7K Data,  94.6K Total
     Debug Version:     154.9K Code, 62.6K Data, 217.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler support for the DMAR ACPI table.
 
 ----------------------------------------
 23 August 2006. Summary of changes for version 20060823:
 
 1) ACPI CA Core Subsystem:
 
 The Table Manager component has been completely redesigned and 
 reimplemented. The new design is much simpler, and reduces the overall 
 code 
 and data size of the kernel-resident ACPICA by approximately 5%. Also, it 
 is 
 now possible to obtain the ACPI tables very early during kernel 
 initialization, even before dynamic memory management is initialized. 
 (Alexey Starikovskiy, Fiodor Suietov, Bob Moore)
 
 Obsolete ACPICA interfaces:
 
 - AcpiGetFirmwareTable: Use AcpiGetTable instead (works at early kernel 
 init 
 time).
 - AcpiLoadTable: Not needed.
 - AcpiUnloadTable: Not needed.
 
 New ACPICA interfaces:
 
 - AcpiInitializeTables: Must be called before the table manager can be 
 used.
 - AcpiReallocateRootTable: Used to transfer the root table to dynamically 
 allocated memory after it becomes available.
 - AcpiGetTableByIndex: Allows the host to easily enumerate all ACPI tables 
 in the RSDT/XSDT.
 
 Other ACPICA changes:
 
 - AcpiGetTableHeader returns the actual mapped table header, not a copy. 
 Use 
 AcpiOsUnmapMemory to free this mapping.
 - AcpiGetTable returns the actual mapped table. The mapping is managed 
 internally and must not be deleted by the caller. Use of this interface 
 causes no additional dynamic memory allocation.
 - AcpiFindRootPointer: Support for physical addressing has been 
 eliminated, 
 it appeared to be unused.
 - The interface to AcpiOsMapMemory has changed to be consistent with the 
 other allocation interfaces.
 - The interface to AcpiOsGetRootPointer has changed to eliminate 
 unnecessary 
 parameters.
 - ACPI_PHYSICAL_ADDRESS is now 32 bits on 32-bit platforms, 64 bits on 64-
 bit platforms. Was previously 64 bits on all platforms.
 - The interface to the ACPI Global Lock acquire/release macros have 
 changed 
 slightly since ACPICA no longer keeps a local copy of the FACS with a 
 constructed pointer to the actual global lock.
 
 Porting to the new table manager:
 
 - AcpiInitializeTables: Must be called once, and can be called anytime 
 during the OS initialization process. It allows the host to specify an 
 area 
 of memory to be used to store the internal version of the RSDT/XSDT (root 
 table). This allows the host to access ACPI tables before memory 
 management 
 is initialized and running.
 - AcpiReallocateRootTable: Can be called after memory management is 
 running 
 to copy the root table to a dynamically allocated array, freeing up the 
 scratch memory specified in the call to AcpiInitializeTables.
 - AcpiSubsystemInitialize: This existing interface is independent of the 
 Table Manager, and does not have to be called before the Table Manager can 
 be used, it only must be called before the rest of ACPICA can be used.
 - ACPI Tables: Some changes have been made to the names and structure of 
 the 
 actbl.h and actbl1.h header files and may require changes to existing 
 code. 
 For example, bitfields have been completely removed because of their lack 
 of 
 portability across C compilers.
 - Update interfaces to the Global Lock acquire/release macros if local 
 versions are used. (see acwin.h)
 
 Obsolete files: tbconvrt.c, tbget.c, tbgetall.c, tbrsdt.c
 
 New files: tbfind.c
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.7K Code, 17.9K Data,  98.6K Total
     Debug Version:     161.0K Code, 65.1K Data, 226.1K Total
   Current Release:
     Non-Debug Version:  77.8K Code, 16.5K Data,  94.3K Total
     Debug Version:     154.6K Code, 62.3K Data, 216.9K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 No changes for this release.
 
 ----------------------------------------
 21 July 2006. Summary of changes for version 20060721:
 
 1) ACPI CA Core Subsystem:
 
 The full source code for the ASL test suite used to validate the iASL 
 compiler and the ACPICA core subsystem is being released with the ACPICA 
 source for the first time. The source is contained in a separate package 
 and 
 consists of over 1100 files that exercise all ASL/AML operators. The 
 package 
 should appear on the Intel/ACPI web site shortly. (Valery Podrezov, Fiodor 
 Suietov)
 
 Completed a new design and implementation for support of the ACPI Global 
 Lock. On the OS side, the global lock is now treated as a standard AML 
 mutex. Previously, multiple OS threads could "acquire" the global lock 
 simultaneously. However, this could cause the BIOS to be starved out of 
 the 
 lock - especially in cases such as the Embedded Controller driver where 
 there is a tight coupling between the OS and the BIOS.
 
 Implemented an optimization for the ACPI Global Lock interrupt mechanism. 
 The Global Lock interrupt handler no longer queues the execution of a 
 separate thread to signal the global lock semaphore. Instead, the 
 semaphore 
 is signaled directly from the interrupt handler.
 
 Implemented support within the AML interpreter for package objects that 
 contain a larger AML length (package list length) than the package element 
 count. In this case, the length of the package is truncated to match the 
 package element count. Some BIOS code apparently modifies the package 
 length 
 on the fly, and this change supports this behavior. Provides compatibility 
 with the MS AML interpreter. (With assistance from Fiodor Suietov)
 
 Implemented a temporary fix for the BankValue parameter of a Bank Field to 
 support all constant values, now including the Zero and One opcodes. 
 Evaluation of this parameter must eventually be converted to a full 
 TermArg 
 evaluation. A not-implemented error is now returned (temporarily) for non-
 constant values for this parameter.
 
 Fixed problem reports (Fiodor Suietov) integrated:
 - Fix for premature object deletion after CopyObject on Operation Region 
 (BZ 
 350)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.7K Code, 18.0K Data,  98.7K Total
     Debug Version:     160.9K Code, 65.1K Data, 226.0K Total
   Current Release:
     Non-Debug Version:  80.7K Code, 17.9K Data,  98.6K Total
     Debug Version:     161.0K Code, 65.1K Data, 226.1K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 No changes for this release.
 
 ----------------------------------------
 07 July 2006. Summary of changes for version 20060707:
 
 1) ACPI CA Core Subsystem:
 
 Added the ACPI_PACKED_POINTERS_NOT_SUPPORTED macro to support C compilers 
 that do not allow the initialization of address pointers within packed 
 structures - even though the hardware itself may support misaligned 
 transfers. Some of the debug data structures are packed by default to 
 minimize size.
 
 Added an error message for the case where AcpiOsGetThreadId() returns 
 zero. 
 A non-zero value is required by the core ACPICA code to ensure the proper 
 operation of AML mutexes and recursive control methods.
 
 The DSDT is now the only ACPI table that determines whether the AML 
 interpreter is in 32-bit or 64-bit mode. Not really a functional change, 
 but 
 the hooks for per-table 32/64 switching have been removed from the code. A 
 clarification to the ACPI specification is forthcoming in ACPI 3.0B.
 
 Fixed a possible leak of an OwnerID in the error path of 
 AcpiTbInitTableDescriptor (tbinstal.c), and migrated all table OwnerID 
 deletion to a single place in AcpiTbUninstallTable to correct possible 
 leaks 
 when using the AcpiTbDeleteTablesByType interface (with assistance from 
 Lance Ortiz.)
 
 Fixed a problem with Serialized control methods where the semaphore 
 associated with the method could be over-signaled after multiple method 
 invocations.
 
 Fixed two issues with the locking of the internal namespace data 
 structure. 
 Both the Unload() operator and AcpiUnloadTable interface now lock the 
 namespace during the namespace deletion associated with the table unload 
 (with assistance from Linn Crosetto.)
 
 Fixed problem reports (Valery Podrezov) integrated:
 - Eliminate unnecessary memory allocation for CreateXxxxField (BZ 5426)
 
 Fixed problem reports (Fiodor Suietov) integrated:
 - Incomplete cleanup branches in AcpiTbGetTableRsdt (BZ 369)
 - On Address Space handler deletion, needless deactivation call (BZ 374)
 - AcpiRemoveAddressSpaceHandler: validate Device handle parameter (BZ 375)
 - Possible memory leak, Notify sub-objects of Processor, Power, 
 ThermalZone 
 (BZ 376)
 - AcpiRemoveAddressSpaceHandler: validate Handler parameter (BZ 378)
 - Minimum Length of RSDT should be validated (BZ 379)
 - AcpiRemoveNotifyHandler: return AE_NOT_EXIST if Processor Obj has no 
 Handler (BZ (380)
 - AcpiUnloadTable: return AE_NOT_EXIST if no table of specified type 
 loaded 
 (BZ 381)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.5K Code, 17.8K Data,  98.3K Total
     Debug Version:     160.8K Code, 64.8K Data, 225.6K Total
   Current Release:
     Non-Debug Version:  80.7K Code, 17.9K Data,  98.6K Total
     Debug Version:     161.0K Code, 65.1K Data, 226.1K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed problem reports:
 Compiler segfault when ASL contains a long (>1024) String declaration (BZ 
 436)
 
 ----------------------------------------
 23 June 2006. Summary of changes for version 20060623:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a new ACPI_SPINLOCK type for the OSL lock interfaces. This 
 allows the type to be customized to the host OS for improved efficiency 
 (since a spinlock is usually a very small object.)
 
 Implemented support for "ignored" bits in the ACPI registers. According to 
 the ACPI specification, these bits should be preserved when writing the 
 registers via a read/modify/write cycle. There are 3 bits preserved in 
 this 
 manner: PM1_CONTROL[0] (SCI_EN), PM1_CONTROL[9], and PM1_STATUS[11].
 
 Implemented the initial deployment of new OSL mutex interfaces. Since some 
 host operating systems have separate mutex and semaphore objects, this 
 feature was requested. The base code now uses mutexes (and the new mutex 
 interfaces) wherever a binary semaphore was used previously. However, for 
 the current release, the mutex interfaces are defined as macros to map 
 them 
 to the existing semaphore interfaces. Therefore, no OSL changes are 
 required 
 at this time. (See acpiosxf.h)
 
 Fixed several problems with the support for the control method SyncLevel 
 parameter. The SyncLevel now works according to the ACPI specification and 
 in concert with the Mutex SyncLevel parameter, since the current SyncLevel 
 is a property of the executing thread. Mutual exclusion for control 
 methods 
 is now implemented with a mutex instead of a semaphore.
 
 Fixed three instances of the use of the C shift operator in the bitfield 
 support code (exfldio.c) to avoid the use of a shift value larger than the 
 target data width. The behavior of C compilers is undefined in this case 
 and 
 can cause unpredictable results, and therefore the case must be detected 
 and 
 avoided. (Fiodor Suietov)
 
 Added an info message whenever an SSDT or OEM table is loaded dynamically 
 via the Load() or LoadTable() ASL operators. This should improve debugging 
 capability since it will show exactly what tables have been loaded (beyond 
 the tables present in the RSDT/XSDT.)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.0K Code, 17.6K Data,  97.6K Total
     Debug Version:     160.2K Code, 64.7K Data, 224.9K Total
   Current Release:
     Non-Debug Version:  80.5K Code, 17.8K Data,  98.3K Total
     Debug Version:     160.8K Code, 64.8K Data, 225.6K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 No changes for this release.
 
 ----------------------------------------
 08 June 2006. Summary of changes for version 20060608:
 
 1) ACPI CA Core Subsystem:
 
 Converted the locking mutex used for the ACPI hardware to a spinlock. This 
 change should eliminate all problems caused by attempting to acquire a 
 semaphore at interrupt level, and it means that all ACPICA external 
 interfaces that directly access the ACPI hardware can be safely called 
 from 
 interrupt level. OSL code that implements the semaphore interfaces should 
 be 
 able to eliminate any workarounds for being called at interrupt level.
 
 Fixed a regression introduced in 20060526 where the ACPI device 
 initialization could be prematurely aborted with an AE_NOT_FOUND if a 
 device 
 did not have an optional _INI method.
 
 Fixed an IndexField issue where a write to the Data Register should be 
 limited in size to the AccessSize (width) of the IndexField itself. (BZ 
 433, 
 Fiodor Suietov)
 
 Fixed problem reports (Valery Podrezov) integrated:
 - Allow store of ThermalZone objects to Debug object (BZ 5369/5370)
 
 Fixed problem reports (Fiodor Suietov) integrated:
 - AcpiGetTableHeader doesn't handle multiple instances correctly (BZ 364)
 
 Removed four global mutexes that were obsolete and were no longer being 
 used.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.0K Code, 17.7K Data,  97.7K Total
     Debug Version:     160.3K Code, 64.9K Data, 225.2K Total
   Current Release:
     Non-Debug Version:  80.0K Code, 17.6K Data,  97.6K Total
     Debug Version:     160.2K Code, 64.7K Data, 224.9K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Fixed a fault when using -g option (get tables from registry) on Windows 
 machines.
 
 Fixed problem reports integrated:
 - Generate error if CreateField NumBits parameter is zero. (BZ 405)
 - Fault if Offset/Length in Field unit is very large (BZ 432, Fiodor 
 Suietov)
 - Global table revision override (-r) is ignored (BZ 413)
 
 ----------------------------------------
 26 May 2006. Summary of changes for version 20060526:
 
 1) ACPI CA Core Subsystem:
 
 Restructured, flattened, and simplified the internal interfaces for 
 namespace object evaluation - resulting in smaller code, less CPU stack 
 use, 
 and fewer interfaces. (With assistance from Mikhail Kouzmich)
 
 Fixed a problem with the CopyObject operator where the first parameter was 
 not typed correctly for the parser, interpreter, compiler, and 
 disassembler. 
 Caused various errors and unexpected behavior.
 
 Fixed a problem where a ShiftLeft or ShiftRight of more than 64 bits 
 produced incorrect results with some C compilers. Since the behavior of C 
 compilers when the shift value is larger than the datatype width is 
 apparently not well defined, the interpreter now detects this condition 
 and 
 simply returns zero as expected in all such cases. (BZ 395)
 
 Fixed problem reports (Valery Podrezov) integrated:
 - Update String-to-Integer conversion to match ACPI 3.0A spec (BZ 5329)
 - Allow interpreter to handle nested method declarations (BZ 5361)
 
 Fixed problem reports (Fiodor Suietov) integrated:
 - AcpiTerminate doesn't free debug memory allocation list objects (BZ 355)
 - After Core Subsystem shutdown, AcpiSubsystemStatus returns AE_OK (BZ 
 356)
 - AcpiOsUnmapMemory for RSDP can be invoked inconsistently (BZ 357)
 - Resource Manager should return AE_TYPE for non-device objects (BZ 358)
 - Incomplete cleanup branch in AcpiNsEvaluateRelative (BZ 359)
 - Use AcpiOsFree instead of ACPI_FREE in AcpiRsSetSrsMethodData (BZ 360)
 - Incomplete cleanup branch in AcpiPsParseAml (BZ 361)
 - Incomplete cleanup branch in AcpiDsDeleteWalkState (BZ 362)
 - AcpiGetTableHeader returns AE_NO_ACPI_TABLES until DSDT is loaded (BZ 
 365)
 - Status of the Global Initialization Handler call not used (BZ 366)
 - Incorrect object parameter to Global Initialization Handler (BZ 367)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.8K Code, 17.7K Data,  97.5K Total
     Debug Version:     160.5K Code, 65.1K Data, 225.6K Total
   Current Release:
     Non-Debug Version:  80.0K Code, 17.7K Data,  97.7K Total
     Debug Version:     160.3K Code, 64.9K Data, 225.2K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Modified the parser to allow the names IO, DMA, and IRQ to be used as 
 namespace identifiers with no collision with existing resource descriptor 
 macro names. This provides compatibility with other ASL compilers and is 
 most useful for disassembly/recompilation of existing tables without parse 
 errors. (With assistance from Thomas Renninger)
 
 Disassembler: fixed an incorrect disassembly problem with the 
 DataTableRegion and CopyObject operators. Fixed a possible fault during 
 disassembly of some Alias operators.
 
 ----------------------------------------
 12 May 2006. Summary of changes for version 20060512:
 
 1) ACPI CA Core Subsystem:
 
 Replaced the AcpiOsQueueForExecution interface with a new interface named 
 AcpiOsExecute. The major difference is that the new interface does not 
 have 
 a Priority parameter, this appeared to be useless and has been replaced by 
 a 
 Type parameter. The Type tells the host what type of execution is being 
 requested, such as global lock handler, notify handler, GPE handler, etc. 
 This allows the host to queue and execute the request as appropriate for 
 the 
 request type, possibly using different work queues and different 
 priorities 
 for the various request types. This enables fixes for multithreading 
 deadlock problems such as BZ #5534, and will require changes to all 
 existing 
 OS interface layers. (Alexey Starikovskiy and Bob Moore)
 
 Fixed a possible memory leak associated with the support for the so-called 
 "implicit return" ACPI extension. Reported by FreeBSD, BZ #6514. (Fiodor 
 Suietov)
 
 Fixed a problem with the Load() operator where a table load from an 
 operation region could overwrite an internal table buffer by up to 7 bytes 
 and cause alignment faults on IPF systems. (With assistance from Luming 
 Yu)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  79.7K Code, 17.7K Data,  97.4K Total
     Debug Version:     160.1K Code, 65.2K Data, 225.3K Total
   Current Release:
     Non-Debug Version:  79.8K Code, 17.7K Data,  97.5K Total
     Debug Version:     160.5K Code, 65.1K Data, 225.6K Total
 
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Implemented support to cross reference the internal 
 namespace 
 and automatically generate ASL External() statements for symbols not 
 defined 
 within the current table being disassembled. This will simplify the 
 disassembly and recompilation of interdependent tables such as SSDTs since 
 these statements will no longer have to be added manually.
 
 Disassembler: Implemented experimental support to automatically detect 
 invocations of external control methods and generate appropriate 
 External() 
 statements. This is problematic because the AML cannot be correctly parsed 
 until the number of arguments for each control method is known. Currently, 
 standalone method invocations and invocations as the source operand of a 
 Store() statement are supported.
 
 Disassembler: Implemented support for the ASL pseudo-operators LNotEqual, 
 LLessEqual, and LGreaterEqual. Previously disassembled as LNot(LEqual()), 
 LNot(LGreater()), and LNot(LLess()), this makes the disassembled ASL code 
 more readable and likely closer to the original ASL source.
 
 ----------------------------------------
 21 April 2006. Summary of changes for version 20060421:
 
 1) ACPI CA Core Subsystem:
 
 Removed a device initialization optimization introduced in 20051216 where 
 the _STA method was not run unless an _INI was also present for the same 
 device. This optimization could cause problems because it could allow _INI 
 methods to be run within a not-present device subtree. (If a not-present 
 device had no _INI, _STA would not be run, the not-present status would 
 not 
 be discovered, and the children of the device would be incorrectly 
 traversed.)
 
 Implemented a new _STA optimization where namespace subtrees that do not 
 contain _INI are identified and ignored during device initialization. 
 Selectively running _STA can significantly improve boot time on large 
 machines (with assistance from Len Brown.)
 
 Implemented support for the device initialization case where the returned 
 _STA flags indicate a device not-present but functioning. In this case, 
 _INI 
 is not run, but the device children are examined for presence, as per the 
 ACPI specification.
 
 Implemented an additional change to the IndexField support in order to 
 conform to MS behavior. The value written to the Index Register is not 
 simply a byte offset, it is a byte offset in units of the access width of 
 the parent Index Field. (Fiodor Suietov)
 
 Defined and deployed a new OSL interface, AcpiOsValidateAddress. This 
 interface is called during the creation of all AML operation regions, and 
 allows the host OS to exert control over what addresses it will allow the 
 AML code to access. Operation Regions whose addresses are disallowed will 
 cause a runtime exception when they are actually accessed (will not affect 
 or abort table loading.) See oswinxf or osunixxf for an example 
 implementation.
 
 Defined and deployed a new OSL interface, AcpiOsValidateInterface. This 
 interface allows the host OS to match the various "optional" 
 interface/behavior strings for the _OSI predefined control method as 
 appropriate (with assistance from Bjorn Helgaas.) See oswinxf or osunixxf 
 for an example implementation.
 
 Restructured and corrected various problems in the exception handling code 
 paths within DsCallControlMethod and DsTerminateControlMethod in dsmethod 
 (with assistance from Takayoshi Kochi.)
 
 Modified the Linux source converter to ignore quoted string literals while 
 converting identifiers from mixed to lower case. This will correct 
 problems 
 with the disassembler and other areas where such strings must not be 
 modified.
 
 The ACPI_FUNCTION_* macros no longer require quotes around the function 
 name. This allows the Linux source converter to convert the names, now 
 that 
 the converter ignores quoted strings.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
 
     Non-Debug Version:  81.1K Code, 17.7K Data,  98.8K Total
     Debug Version:     158.9K Code, 64.9K Data, 223.8K Total
   Current Release:
     Non-Debug Version:  79.7K Code, 17.7K Data,  97.4K Total
     Debug Version:     160.1K Code, 65.2K Data, 225.3K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented 3 new warnings for iASL, and implemented multiple warning 
 levels 
 (w2 flag).
 
 1) Ignored timeouts: If the TimeoutValue parameter to Wait or Acquire is 
 not 
 WAIT_FOREVER (0xFFFF) and the code does not examine the return value to 
 check for the possible timeout, a warning is issued.
 
 2) Useless operators: If an ASL operator does not specify an optional 
 target 
 operand and it also does not use the function return value from the 
 operator, a warning is issued since the operator effectively does nothing.
 
 3) Unreferenced objects: If a namespace object is created, but never 
 referenced, a warning is issued. This is a warning level 2 since there are 
 cases where this is ok, such as when a secondary table is loaded that uses 
 the unreferenced objects. Even so, care is taken to only flag objects that 
 don't look like they will ever be used. For example, the reserved methods 
 (starting with an underscore) are usually not referenced because it is 
 expected that the OS will invoke them.
 
 ----------------------------------------
 31 March 2006. Summary of changes for version 20060331:
 
 1) ACPI CA Core Subsystem:
 
 Implemented header file support for the following additional ACPI tables: 
 ASF!, BOOT, CPEP, DBGP, MCFG, SPCR, SPMI, TCPA, and WDRT. With this 
 support, 
 all current and known ACPI tables are now defined in the ACPICA headers 
 and 
 are available for use by device drivers and other software.
 
 Implemented support to allow tables that contain ACPI names with invalid 
 characters to be loaded. Previously, this would cause the table load to 
 fail, but since there are several known cases of such tables on existing 
 machines, this change was made to enable ACPI support for them. Also, this 
 matches the behavior of the Microsoft ACPI implementation.
 
 Fixed a couple regressions introduced during the memory optimization in 
 the 
 20060317 release. The namespace node definition required additional 
 reorganization and an internal datatype that had been changed to 8-bit was 
 restored to 32-bit. (Valery Podrezov)
 
 Fixed a problem where a null pointer passed to AcpiUtDeleteGenericState 
 could be passed through to AcpiOsReleaseObject which is unexpected. Such 
 null pointers are now trapped and ignored, matching the behavior of the 
 previous implementation before the deployment of AcpiOsReleaseObject.
 (Valery Podrezov, Fiodor Suietov)
 
 Fixed a memory mapping leak during the deletion of a SystemMemory 
 operation 
 region where a cached memory mapping was not deleted. This became a 
 noticeable problem for operation regions that are defined within 
 frequently 
 used control methods. (Dana Meyers)
 
 Reorganized the ACPI table header files into two main files: one for the 
 ACPI tables consumed by the ACPICA core, and another for the miscellaneous 
 ACPI tables that are consumed by the drivers and other software. The 
 various 
 FADT definitions were merged into one common section and three different 
 tables (ACPI 1.0, 1.0+, and 2.0)
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
 debug version of the code includes the debug output trace mechanism and 
 has 
 a much larger code and data size.
 
   Previous Release:
     Non-Debug Version:  80.9K Code, 17.7K Data,  98.6K Total
     Debug Version:     158.7K Code, 64.8K Data, 223.5K Total
   Current Release:
     Non-Debug Version:  81.1K Code, 17.7K Data,  98.8K Total
     Debug Version:     158.9K Code, 64.9K Data, 223.8K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Disassembler: Implemented support to decode and format all non-AML ACPI 
 tables (tables other than DSDTs and SSDTs.) This includes the new tables 
 added to the ACPICA headers, therefore all current and known ACPI tables 
 are 
 supported.
 
 Disassembler: The change to allow ACPI names with invalid characters also 
 enables the disassembly of such tables. Invalid characters within names 
 are 
 changed to '*' to make the name printable; the iASL compiler will still 
 generate an error for such names, however, since this is an invalid ACPI 
 character.
 
 Implemented an option for AcpiXtract (-a) to extract all tables found in 
 the 
 input file. The default invocation extracts only the DSDTs and SSDTs.
 
 Fixed a couple of gcc generation issues for iASL and AcpiExec and added a 
 makefile for the AcpiXtract utility.
 
 ----------------------------------------
 17 March 2006. Summary of changes for version 20060317:
 
 1) ACPI CA Core Subsystem:
 
 Implemented the use of a cache object for all internal namespace nodes. 
 Since there are about 1000 static nodes in a typical system, this will 
 decrease memory use for cache implementations that minimize per-allocation 
 overhead (such as a slab allocator.)
 
 Removed the reference count mechanism for internal namespace nodes, since 
 it 
 was deemed unnecessary. This reduces the size of each namespace node by 
 about 5%-10% on all platforms. Nodes are now 20 bytes for the 32-bit case, 
 and 32 bytes for the 64-bit case.
 
 Optimized several internal data structures to reduce object size on 64-bit 
 platforms by packing data within the 64-bit alignment. This includes the 
 frequently used ACPI_OPERAND_OBJECT, of which there can be ~1000 static 
 instances corresponding to the namespace objects.
 
 Added two new strings for the predefined _OSI method: "Windows 2001.1 SP1" 
 and "Windows 2006".
 
 Split the allocation tracking mechanism out to a separate file, from 
 utalloc.c to uttrack.c. This mechanism appears to be only useful for 
 application-level code. Kernels may wish to not include uttrack.c in 
 distributions.
 
 Removed all remnants of the obsolete ACPI_REPORT_* macros and the 
 associated 
 code. (These macros have been replaced by the ACPI_ERROR and ACPI_WARNING 
 macros.)
 
 Code and Data Size: These are the sizes for the acpica.lib produced by the 
 Microsoft Visual C++ 6.0 32-bit compiler. The values do not include any 
 ACPI 
 driver or OSPM code. The debug version of the code includes the debug 
 output 
 trace mechanism and has a much larger code and data size. Note that these 
 values will vary depending on the efficiency of the compiler and the 
 compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  81.1K Code, 17.8K Data,  98.9K Total
     Debug Version:     161.6K Code, 65.7K Data, 227.3K Total
   Current Release:
     Non-Debug Version:  80.9K Code, 17.7K Data,  98.6K Total
     Debug Version:     158.7K Code, 64.8K Data, 223.5K Total
 
 
 2) iASL Compiler/Disassembler and Tools:
 
 Implemented an ANSI C version of the acpixtract utility. This version will 
 automatically extract the DSDT and all SSDTs from the input acpidump text 
 file and dump the binary output to separate files. It can also display a 
 summary of the input file including the headers for each table found and 
 will extract any single ACPI table, with any signature. (See 
 source/tools/acpixtract)
 
 ----------------------------------------
 10 March 2006. Summary of changes for version 20060310:
 
 1) ACPI CA Core Subsystem:
 
 Tagged all external interfaces to the subsystem with the new 
 ACPI_EXPORT_SYMBOL macro. This macro can be defined as necessary to assist 
 kernel integration. For Linux, the macro resolves to the EXPORT_SYMBOL 
 macro. The default definition is NULL.
 
 Added the ACPI_THREAD_ID type for the return value from AcpiOsGetThreadId. 
 This allows the host to define this as necessary to simplify kernel 
 integration. The default definition is ACPI_NATIVE_UINT.
 
 Fixed two interpreter problems related to error processing, the deletion 
 of 
 objects, and placing invalid pointers onto the internal operator result 
 stack. BZ 6028, 6151 (Valery Podrezov)
 
 Increased the reference count threshold where a warning is emitted for 
 large 
 reference counts in order to eliminate unnecessary warnings on systems 
 with 
 large namespaces (especially 64-bit.) Increased the value from 0x400 to 
 0x800.
 
 Due to universal disagreement as to the meaning of the 'c' in the calloc() 
 function, the ACPI_MEM_CALLOCATE macro has been renamed to 
 ACPI_ALLOCATE_ZEROED so that the purpose of the interface is 'clear'. 
 ACPI_MEM_ALLOCATE and ACPI_MEM_FREE are renamed to ACPI_ALLOCATE and 
 ACPI_FREE.
 
 Code and Data Size: These are the sizes for the acpica.lib produced by the 
 Microsoft Visual C++ 6.0 32-bit compiler. The values do not include any 
 ACPI 
 driver or OSPM code. The debug version of the code includes the debug 
 output 
 trace mechanism and has a much larger code and data size. Note that these 
 values will vary depending on the efficiency of the compiler and the 
 compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  81.0K Code, 17.8K Data,  98.8K Total
     Debug Version:     161.4K Code, 65.7K Data, 227.1K Total
   Current Release:
     Non-Debug Version:  81.1K Code, 17.8K Data,  98.9K Total
     Debug Version:     161.6K Code, 65.7K Data, 227.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Disassembler: implemented support for symbolic resource descriptor 
 references. If a CreateXxxxField operator references a fixed offset within 
 a 
 resource descriptor, a name is assigned to the descriptor and the offset 
 is 
 translated to the appropriate resource tag and pathname. The addition of 
 this support brings the disassembled code very close to the original ASL 
 source code and helps eliminate run-time errors when the disassembled code 
 is modified (and recompiled) in such a way as to invalidate the original 
 fixed offsets.
 
 Implemented support for a Descriptor Name as the last parameter to the ASL 
 Register() macro. This parameter was inadvertently left out of the ACPI 
 specification, and will be added for ACPI 3.0b.
 
 Fixed a problem where the use of the "_OSI" string (versus the full path 
 "\_OSI") caused an internal compiler error. ("No back ptr to op")
 
 Fixed a problem with the error message that occurs when an invalid string 
 is 
 used for a _HID object (such as one with an embedded asterisk: 
 "*PNP010A".) 
 The correct message is now displayed.
 
 ----------------------------------------
 17 February 2006. Summary of changes for version 20060217:
 
 1) ACPI CA Core Subsystem:
 
 Implemented a change to the IndexField support to match the behavior of 
 the 
 Microsoft AML interpreter. The value written to the Index register is now 
 a 
 byte offset, no longer an index based upon the width of the Data register. 
 This should fix IndexField problems seen on some machines where the Data 
 register is not exactly one byte wide. The ACPI specification will be 
 clarified on this point.
 
 Fixed a problem where several resource descriptor types could overrun the 
 internal descriptor buffer due to size miscalculation: VendorShort, 
 VendorLong, and Interrupt. This was noticed on IA64 machines, but could 
 affect all platforms.
 
 Fixed a problem where individual resource descriptors were misaligned 
 within 
 the internal buffer, causing alignment faults on IA64 platforms.
 
 Code and Data Size: These are the sizes for the acpica.lib produced by the 
 Microsoft Visual C++ 6.0 32-bit compiler. The values do not include any 
 ACPI 
 driver or OSPM code. The debug version of the code includes the debug 
 output 
 trace mechanism and has a much larger code and data size. Note that these 
 values will vary depending on the efficiency of the compiler and the 
 compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  81.1K Code, 17.8K Data,  98.9K Total
     Debug Version:     161.3K Code, 65.6K Data, 226.9K Total
   Current Release:
     Non-Debug Version:  81.0K Code, 17.8K Data,  98.8K Total
     Debug Version:     161.4K Code, 65.7K Data, 227.1K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support for new reserved names: _WDG and _WED are Microsoft 
 extensions for Windows Instrumentation Management, _TDL is a new ACPI-
 defined method (Throttling Depth Limit.)
 
 Fixed a problem where a zero-length VendorShort or VendorLong resource 
 descriptor was incorrectly emitted as a descriptor of length one.
 
 ----------------------------------------
 10 February 2006. Summary of changes for version 20060210:
 
 1) ACPI CA Core Subsystem:
 
 Removed a couple of extraneous ACPI_ERROR messages that appeared during 
 normal execution. These became apparent after the conversion from 
 ACPI_DEBUG_PRINT.
 
 Fixed a problem where the CreateField operator could hang if the BitIndex 
 or 
 NumBits parameter referred to a named object. (Valery Podrezov, BZ 5359)
 
 Fixed a problem where a DeRefOf operation on a buffer object incorrectly 
 failed with an exception. This also fixes a couple of related RefOf and 
 DeRefOf issues. (Valery Podrezov, BZ 5360/5392/5387)
 
 Fixed a problem where the AE_BUFFER_LIMIT exception was returned instead 
 of 
 AE_STRING_LIMIT on an out-of-bounds Index() operation. (Valery Podrezov, 
 BZ 
 5480)
 
 Implemented a memory cleanup at the end of the execution of each iteration 
 of an AML While() loop, preventing the accumulation of outstanding 
 objects. 
 (Valery Podrezov, BZ 5427)
 
 Eliminated a chunk of duplicate code in the object resolution code. 
 (Valery 
 Podrezov, BZ 5336)
 
 Fixed several warnings during the 64-bit code generation.
 
 The AcpiSrc source code conversion tool now inserts one line of whitespace 
 after an if() statement that is followed immediately by a comment, 
 improving 
 readability of the Linux code.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  81.0K Code, 17.9K Data,  98.9K Total
     Debug Version:     161.3K Code, 65.7K Data, 227.0K Total
   Current Release:
     Non-Debug Version:  81.1K Code, 17.8K Data,  98.9K Total
     Debug Version:     161.3K Code, 65.6K Data, 226.9K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with the disassembly of a BankField operator with a 
 complex 
 expression for the BankValue parameter.
 
 ----------------------------------------
 27 January 2006. Summary of changes for version 20060127:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support in the Resource Manager to allow unresolved namestring 
 references within resource package objects for the _PRT method. This 
 support 
 is in addition to the previously implemented unresolved reference support 
 within the AML parser. If the interpreter slack mode is enabled, these 
 unresolved references will be passed through to the caller as a NULL 
 package 
 entry.
 
 Implemented and deployed new macros and functions for error and warning 
 messages across the subsystem. These macros are simpler and generate less 
 code than their predecessors. The new macros ACPI_ERROR, ACPI_EXCEPTION, 
 ACPI_WARNING, and ACPI_INFO replace the ACPI_REPORT_* macros. The older 
 macros remain defined to allow ACPI drivers time to migrate to the new 
 macros.
 
 Implemented the ACPI_CPU_FLAGS type to simplify host OS integration of the 
 Acquire/Release Lock OSL interfaces.
 
 Fixed a problem where Alias ASL operators are sometimes not correctly 
 resolved, in both the interpreter and the iASL compiler.
 
 Fixed several problems with the implementation of the 
 ConcatenateResTemplate 
 ASL operator. As per the ACPI specification, zero length buffers are now 
 treated as a single EndTag. One-length buffers always cause a fatal 
 exception. Non-zero length buffers that do not end with a full 2-byte 
 EndTag 
 cause a fatal exception.
 
 Fixed a possible structure overwrite in the AcpiGetObjectInfo external 
 interface. (With assistance from Thomas Renninger)
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  83.1K Code, 18.4K Data, 101.5K Total
     Debug Version:     163.2K Code, 66.2K Data, 229.4K Total
   Current Release:
     Non-Debug Version:  81.0K Code, 17.9K Data,  98.9K Total
     Debug Version:     161.3K Code, 65.7K Data, 227.0K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed an internal error that was generated for any forward references to 
 ASL 
 Alias objects.
 
 ----------------------------------------
 13 January 2006. Summary of changes for version 20060113:
 
 1) ACPI CA Core Subsystem:
 
 Added 2006 copyright to all module headers and signons. This affects 
 virtually every file in the ACPICA core subsystem, iASL compiler, and the 
 utilities.
  
 Enhanced the ACPICA error reporting in order to simplify user migration to 
 the non-debug version of ACPICA. Replaced all instances of the 
 ACPI_DEBUG_PRINT macro invoked at the ACPI_DB_ERROR and ACPI_DB_WARN debug 
 levels with the ACPI_REPORT_ERROR and ACPI_REPORT_WARNING macros, 
 respectively. This preserves all error and warning messages in the non-
 debug 
 version of the ACPICA code (this has been referred to as the "debug lite" 
 option.) Over 200 cases were converted to create a total of over 380 
 error/warning messages across the ACPICA code. This increases the code and 
 data size of the default non-debug version of the code somewhat (about 
 13K), 
 but all error/warning reporting may be disabled if desired (and code 
 eliminated) by specifying the ACPI_NO_ERROR_MESSAGES compile-time 
 configuration option. The size of the debug version of ACPICA remains 
 about 
 the same.
 
 Fixed a memory leak within the AML Debugger "Set" command. One object was 
 not properly deleted for every successful invocation of the command.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.6K Code, 12.3K Data,  88.9K Total
     Debug Version:     163.7K Code, 67.5K Data, 231.2K Total
   Current Release:
     Non-Debug Version:  83.1K Code, 18.4K Data, 101.5K Total
     Debug Version:     163.2K Code, 66.2K Data, 229.4K Total
 
 
 2) iASL Compiler/Disassembler:
 
 The compiler now officially supports the ACPI 3.0a specification that was 
 released on December 30, 2005. (Specification is available at 
 www.acpi.info)
 
 ----------------------------------------
 16 December 2005. Summary of changes for version 20051216:
 
 1) ACPI CA Core Subsystem:
 
 Implemented optional support to allow unresolved names within ASL Package 
 objects. A null object is inserted in the package when a named reference 
 cannot be located in the current namespace. Enabled via the interpreter 
 slack flag, this should eliminate AE_NOT_FOUND exceptions seen on machines 
 that contain such code.
 
 Implemented an optimization to the initialization sequence that can 
 improve 
 boot time. During ACPI device initialization, the _STA method is now run 
 if 
 and only if the _INI method exists. The _STA method is used to determine 
 if 
 the device is present; An _INI can only be run if _STA returns present, 
 but 
 it is a waste of time to run the _STA method if the _INI does not exist. 
 (Prototype and assistance from Dong Wei)
 
 Implemented use of the C99 uintptr_t for the pointer casting macros if it 
 is 
 available in the current compiler. Otherwise, the default (void *) cast is 
 used as before.
 
 Fixed some possible memory leaks found within the execution path of the 
 Break, Continue, If, and CreateField operators. (Valery Podrezov)
 
 Fixed a problem introduced in the 20051202 release where an exception is 
 generated during method execution if a control method attempts to declare 
 another method.
 
 Moved resource descriptor string constants that are used by both the AML 
 disassembler and AML debugger to the common utilities directory so that 
 these components are independent.
 
 Implemented support in the AcpiExec utility (-e switch) to globally ignore 
 exceptions during control method execution (method is not aborted.)
 
 Added the rsinfo.c source file to the AcpiExec makefile for Linux/Unix 
 generation.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.3K Code, 12.3K Data,  88.6K Total
     Debug Version:     163.2K Code, 67.4K Data, 230.6K Total
   Current Release:
     Non-Debug Version:  76.6K Code, 12.3K Data,  88.9K Total
     Debug Version:     163.7K Code, 67.5K Data, 231.2K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem where a CPU stack overflow fault could occur if a 
 recursive 
 method call was made from within a Return statement.
 
 ----------------------------------------
 02 December 2005. Summary of changes for version 20051202:
 
 1) ACPI CA Core Subsystem:
 
 Modified the parsing of control methods to no longer create namespace 
 objects during the first pass of the parse. Objects are now created only 
 during the execute phase, at the moment the namespace creation operator is 
 encountered in the AML (Name, OperationRegion, CreateByteField, etc.) This 
 should eliminate ALREADY_EXISTS exceptions seen on some machines where 
 reentrant control methods are protected by an AML mutex. The mutex will 
 now 
 correctly block multiple threads from attempting to create the same object 
 more than once.
 
 Increased the number of available Owner Ids for namespace object tracking 
 from 32 to 255. This should eliminate the OWNER_ID_LIMIT exceptions seen 
 on 
 some machines with a large number of ACPI tables (either static or 
 dynamic).
 
 Fixed a problem with the AcpiExec utility where a fault could occur when 
 the 
 -b switch (batch mode) is used.
 
 Enhanced the namespace dump routine to output the owner ID for each 
 namespace object.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.3K Code, 12.3K Data,  88.6K Total
     Debug Version:     163.0K Code, 67.4K Data, 230.4K Total
   Current Release:
     Non-Debug Version:  76.3K Code, 12.3K Data,  88.6K Total
     Debug Version:     163.2K Code, 67.4K Data, 230.6K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a parse error during compilation of certain Switch/Case constructs. 
 To 
 simplify the parse, the grammar now allows for multiple Default statements 
 and this error is now detected and flagged during the analysis phase.
 
 Disassembler: The disassembly now includes the contents of the original 
 table header within a comment at the start of the file. This includes the 
 name and version of the original ASL compiler.
 
 ----------------------------------------
 17 November 2005. Summary of changes for version 20051117:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem in the AML parser where the method thread count could be 
 decremented below zero if any errors occurred during the method parse 
 phase. 
 This should eliminate AE_AML_METHOD_LIMIT exceptions seen on some 
 machines. 
 This also fixed a related regression with the mechanism that detects and 
 corrects methods that cannot properly handle reentrancy (related to the 
 deployment of the new OwnerId mechanism.)
 
 Eliminated the pre-parsing of control methods (to detect errors) during 
 table load. Related to the problem above, this was causing unwind issues 
 if 
 any errors occurred during the parse, and it seemed to be overkill. A 
 table 
 load should not be aborted if there are problems with any single control 
 method, thus rendering this feature rather pointless.
 
 Fixed a problem with the new table-driven resource manager where an 
 internal 
 buffer overflow could occur for small resource templates.
 
 Implemented a new external interface, AcpiGetVendorResource. This 
 interface 
 will find and return a vendor-defined resource descriptor within a _CRS or 
 _PRS method via an ACPI 3.0 UUID match. With assistance from Bjorn 
 Helgaas.
 
 Removed the length limit (200) on string objects as per the upcoming ACPI 
 3.0A specification. This affects the following areas of the interpreter: 
 1) 
 any implicit conversion of a Buffer to a String, 2) a String object result 
 of the ASL Concatentate operator, 3) the String object result of the ASL 
 ToString operator.
 
 Fixed a problem in the Windows OS interface layer (OSL) where a 
 WAIT_FOREVER 
 on a semaphore object would incorrectly timeout. This allows the 
 multithreading features of the AcpiExec utility to work properly under 
 Windows.
 
 Updated the Linux makefiles for the iASL compiler and AcpiExec to include 
 the recently added file named "utresrc.c".
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.2K Code, 12.3K Data,  88.5K Total
     Debug Version:     163.0K Code, 67.4K Data, 230.4K Total
   Current Release:
     Non-Debug Version:  76.3K Code, 12.3K Data,  88.6K Total
     Debug Version:     163.0K Code, 67.4K Data, 230.4K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Removed the limit (200) on string objects as per the upcoming ACPI 3.0A 
 specification. For the iASL compiler, this means that string literals 
 within 
 the source ASL can be of any length. 
 
 Enhanced the listing output to dump the AML code for resource descriptors 
 immediately after the ASL code for each descriptor, instead of in a block 
 at 
 the end of the entire resource template.
 
 Enhanced the compiler debug output to dump the entire original parse tree 
 constructed during the parse phase, before any transforms are applied to 
 the 
 tree. The transformed tree is dumped also.
 
 ----------------------------------------
 02 November 2005. Summary of changes for version 20051102:
 
 1) ACPI CA Core Subsystem:
 
 Modified the subsystem initialization sequence to improve GPE support. The 
 GPE initialization has been split into two parts in order to defer 
 execution 
 of the _PRW methods (Power Resources for Wake) until after the hardware is 
 fully initialized and the SCI handler is installed. This allows the _PRW 
 methods to access fields protected by the Global Lock. This will fix 
 systems 
 where a NO_GLOBAL_LOCK exception has been seen during initialization.
 
 Converted the ACPI internal object disassemble and display code within the 
 AML debugger to fully table-driven operation, reducing code size and 
 increasing maintainability.
 
 Fixed a regression with the ConcatenateResTemplate() ASL operator 
 introduced 
 in the 20051021 release.
 
 Implemented support for "local" internal ACPI object types within the 
 debugger "Object" command and the AcpiWalkNamespace external interfaces. 
 These local types include RegionFields, BankFields, IndexFields, Alias, 
 and 
 reference objects.
 
 Moved common AML resource handling code into a new file, "utresrc.c". This 
 code is shared by both the Resource Manager and the AML Debugger.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.1K Code, 12.2K Data,  88.3K Total
     Debug Version:     163.5K Code, 67.0K Data, 230.5K Total
   Current Release:
     Non-Debug Version:  76.2K Code, 12.3K Data,  88.5K Total
     Debug Version:     163.0K Code, 67.4K Data, 230.4K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with very large initializer lists (more than 4000 
 elements) 
 for both Buffer and Package objects where the parse stack could overflow.
 
 Enhanced the pre-compile source code scan for non-ASCII characters to 
 ignore 
 characters within comment fields. The scan is now always performed and is 
 no 
 longer optional, detecting invalid characters within a source file 
 immediately rather than during the parse phase or later.
 
 Enhanced the ASL grammar definition to force early reductions on all list-
 style grammar elements so that the overall parse stack usage is greatly 
 reduced. This should improve performance and reduce the possibility of 
 parse 
 stack overflow.
 
 Eliminated all reduce/reduce conflicts in the iASL parser generation. 
 Also, 
 with the addition of a %expected statement, the compiler generates from 
 source with no warnings.
 
 Fixed a possible segment fault in the disassembler if the input filename 
 does not contain a "dot" extension (Thomas Renninger).
 
 ----------------------------------------
 21 October 2005. Summary of changes for version 20051021:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for the EM64T and other x86-64 processors. This 
 essentially entails recognizing that these processors support non-aligned 
 memory transfers. Previously, all 64-bit processors were assumed to lack 
 hardware support for non-aligned transfers.
 
 Completed conversion of the Resource Manager to nearly full table-driven 
 operation. Specifically, the resource conversion code (convert AML to 
 internal format and the reverse) and the debug code to dump internal 
 resource descriptors are fully table-driven, reducing code and data size 
 and 
 improving maintainability.
 
 The OSL interfaces for Acquire and Release Lock now use a 64-bit flag word 
 on 64-bit processors instead of a fixed 32-bit word. (With assistance from 
 Alexey Starikovskiy)
 
 Implemented support within the resource conversion code for the Type-
 Specific byte within the various ACPI 3.0 *WordSpace macros.
 
 Fixed some issues within the resource conversion code for the type-
 specific 
 flags for both Memory and I/O address resource descriptors. For Memory, 
 implemented support for the MTP and TTP flags. For I/O, split the TRS and 
 TTP flags into two separate fields.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.1K Code, 12.1K Data,  89.2K Total
     Debug Version:     168.0K Code, 68.3K Data, 236.3K Total
   Current Release:
     Non-Debug Version:  76.1K Code, 12.2K Data,  88.3K Total
     Debug Version:     163.5K Code, 67.0K Data, 230.5K Total
 
 
 
 2) iASL Compiler/Disassembler:
 
 Relaxed a compiler restriction that disallowed a ResourceIndex byte if the 
 corresponding ResourceSource string was not also present in a resource 
 descriptor declaration. This restriction caused problems with existing 
 AML/ASL code that includes the Index byte without the string. When such 
 AML 
 was disassembled, it could not be compiled without modification. Further, 
 the modified code created a resource template with a different size than 
 the 
 original, breaking code that used fixed offsets into the resource template 
 buffer.
 
 Removed a recent feature of the disassembler to ignore a lone 
 ResourceIndex 
 byte. This byte is now emitted if present so that the exact AML can be 
 reproduced when the disassembled code is recompiled.
 
 Improved comments and text alignment for the resource descriptor code 
 emitted by the disassembler.
 
 Implemented disassembler support for the ACPI 3.0 AccessSize field within 
 a 
 Register() resource descriptor.
 
 ----------------------------------------
 30 September 2005. Summary of changes for version 20050930:
 
 1) ACPI CA Core Subsystem:
 
 Completed a major overhaul of the Resource Manager code - specifically, 
 optimizations in the area of the AML/internal resource conversion code. 
 The 
 code has been optimized to simplify and eliminate duplicated code, CPU 
 stack 
 use has been decreased by optimizing function parameters and local 
 variables, and naming conventions across the manager have been 
 standardized 
 for clarity and ease of maintenance (this includes function, parameter, 
 variable, and struct/typedef names.) The update may force changes in some 
 driver code, depending on how resources are handled by the host OS.
 
 All Resource Manager dispatch and information tables have been moved to a 
 single location for clarity and ease of maintenance. One new file was 
 created, named "rsinfo.c".
 
 The ACPI return macros (return_ACPI_STATUS, etc.) have been modified to 
 guarantee that the argument is not evaluated twice, making them less prone 
 to macro side-effects. However, since there exists the possibility of 
 additional stack use if a particular compiler cannot optimize them (such 
 as 
 in the debug generation case), the original macros are optionally 
 available.  
 Note that some invocations of the return_VALUE macro may now cause size 
 mismatch warnings; the return_UINT8 and return_UINT32 macros are provided 
 to 
 eliminate these. (From Randy Dunlap)
 
 Implemented a new mechanism to enable debug tracing for individual control 
 methods. A new external interface, AcpiDebugTrace, is provided to enable 
 this mechanism. The intent is to allow the host OS to easily enable and 
 disable tracing for problematic control methods. This interface can be 
 easily exposed to a user or debugger interface if desired. See the file 
 psxface.c for details.
 
 AcpiUtCallocate will now return a valid pointer if a length of zero is 
 specified - a length of one is used and a warning is issued. This matches 
 the behavior of AcpiUtAllocate.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.5K Code, 12.0K Data,  89.5K Total
     Debug Version:     168.1K Code, 68.4K Data, 236.5K Total
   Current Release:
     Non-Debug Version:  77.1K Code, 12.1K Data,  89.2K Total
     Debug Version:     168.0K Code, 68.3K Data, 236.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 A remark is issued if the effective compile-time length of a package or 
 buffer is zero. Previously, this was a warning.
 
 ----------------------------------------
 16 September 2005. Summary of changes for version 20050916:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem within the Resource Manager where support for the Generic 
 Register descriptor was not fully implemented. This descriptor is now 
 fully 
 recognized, parsed, disassembled, and displayed.
 
 Completely restructured the Resource Manager code to utilize table-driven 
 dispatch and lookup, eliminating many of the large switch() statements. 
 This 
 reduces overall subsystem code size and code complexity. Affects the 
 resource parsing and construction, disassembly, and debug dump output.
 
 Cleaned up and restructured the debug dump output for all resource 
 descriptors. Improved readability of the output and reduced code size.
 
 Fixed a problem where changes to internal data structures caused the 
 optional ACPI_MUTEX_DEBUG code to fail compilation if specified.
 
 Code and Data Size: The current and previous library sizes for the core 
 subsystem are shown below. These are the code and data sizes for the 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. These 
 values do not include any ACPI driver or OSPM code. The debug version of 
 the 
 code includes the debug output trace mechanism and has a much larger code 
 and data size. Note that these values will vary depending on the 
 efficiency 
 of the compiler and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.4K Code, 11.8K Data,  90.2K Total
     Debug Version:     169.6K Code, 69.9K Data, 239.5K Total
   Current Release:
     Non-Debug Version:  77.5K Code, 12.0K Data,  89.5K Total
     Debug Version:     168.1K Code, 68.4K Data, 236.5K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Updated the disassembler to automatically insert an EndDependentFn() macro 
 into the ASL stream if this macro is missing in the original AML code, 
 simplifying compilation of the resulting ASL module.
 
 Fixed a problem in the disassembler where a disassembled ResourceSource 
 string (within a large resource descriptor) was not surrounded by quotes 
 and 
 not followed by a comma, causing errors when the resulting ASL module was 
 compiled. Also, escape sequences within a ResourceSource string are now 
 handled correctly (especially "\\")
 
 ----------------------------------------
 02 September 2005. Summary of changes for version 20050902:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem with the internal Owner ID allocation and deallocation 
 mechanisms for control method execution and recursive method invocation. 
 This should eliminate the OWNER_ID_LIMIT exceptions and "Invalid OwnerId" 
 messages seen on some systems. Recursive method invocation depth is 
 currently limited to 255. (Alexey Starikovskiy)
 
 Completely eliminated all vestiges of support for the "module-level 
 executable code" until this support is fully implemented and debugged. 
 This 
 should eliminate the NO_RETURN_VALUE exceptions seen during table load on 
 some systems that invoke this support.
 
 Fixed a problem within the resource manager code where the transaction 
 flags 
 for a 64-bit address descriptor were handled incorrectly in the type-
 specific flag byte.
 
 Consolidated duplicate code within the address descriptor resource manager 
 code, reducing overall subsystem code size.
 
 Fixed a fault when using the AML debugger "disassemble" command to 
 disassemble individual control methods.
 
 Removed references to the "release_current" directory within the Unix 
 release package.
 
 Code and Data Size: The current and previous core subsystem library sizes 
 are shown below. These are the code and data sizes for the acpica.lib 
 produced by the Microsoft Visual C++ 6.0 compiler. These values do not 
 include any ACPI driver or OSPM code. The debug version of the code 
 includes 
 the debug output trace mechanism and has a much larger code and data size. 
 Note that these values will vary depending on the efficiency of the 
 compiler 
 and the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.6K Code, 11.7K Data,  90.3K Total
     Debug Version:     170.0K Code, 69.9K Data, 239.9K Total
   Current Release:
     Non-Debug Version:  78.4K Code, 11.8K Data,  90.2K Total
     Debug Version:     169.6K Code, 69.9K Data, 239.5K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented an error check for illegal duplicate values in the interrupt 
 and 
 dma lists for the following ASL macros: Dma(), Irq(), IrqNoFlags(), and 
 Interrupt().
 
 Implemented error checking for the Irq() and IrqNoFlags() macros to detect 
 too many values in the interrupt list (16 max) and invalid values in the 
 list (range 0 - 15)
 
 The maximum length string literal within an ASL file is now restricted to 
 200 characters as per the ACPI specification.
 
 Fixed a fault when using the -ln option (generate namespace listing).
 
 Implemented an error check to determine if a DescriptorName within a 
 resource descriptor has already been used within the current scope.
 
 ----------------------------------------
 15 August 2005.  Summary of changes for version 20050815:
  
 1) ACPI CA Core Subsystem:
  
 Implemented a full bytewise compare to determine if a table load request 
 is 
 attempting to load a duplicate table. The compare is performed if the 
 table 
 signatures and table lengths match. This will allow different tables with 
 the same OEM Table ID and revision to be loaded - probably against the 
 ACPI 
 specification, but discovered in the field nonetheless.
  
 Added the changes.txt logfile to each of the zipped release packages.
  
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
  
   Previous Release:
     Non-Debug Version:  78.6K Code, 11.7K Data,  90.3K Total
     Debug Version:     167.0K Code, 69.9K Data, 236.9K Total
   Current Release:
     Non-Debug Version:  78.6K Code, 11.7K Data,  90.3K Total
     Debug Version:     170.0K Code, 69.9K Data, 239.9K Total
  
  
 2) iASL Compiler/Disassembler:
  
 Fixed a problem where incorrect AML code could be generated for Package 
 objects if optimization is disabled (via the -oa switch).
  
 Fixed a problem with where incorrect AML code is generated for variable-
 length packages when the package length is not specified and the number of 
 initializer values is greater than 255.
  
 
 ----------------------------------------
 29 July 2005.  Summary of changes for version 20050729:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support to ignore an attempt to install/load a particular ACPI 
 table more than once. Apparently there exists BIOS code that repeatedly 
 attempts to load the same SSDT upon certain events. With assistance from 
 Venkatesh Pallipadi.
 
 Restructured the main interface to the AML parser in order to correctly 
 handle all exceptional conditions. This will prevent leakage of the 
 OwnerId 
 resource and should eliminate the AE_OWNER_ID_LIMIT exceptions seen on 
 some 
 machines. With assistance from Alexey Starikovskiy.
 
 Support for "module level code" has been disabled in this version due to a 
 number of issues that have appeared on various machines. The support can 
 be 
 enabled by defining ACPI_ENABLE_MODULE_LEVEL_CODE during subsystem 
 compilation. When the issues are fully resolved, the code will be enabled 
 by 
 default again.
 
 Modified the internal functions for debug print support to define the 
 FunctionName parameter as a (const char *) for compatibility with compiler 
 built-in macros such as __FUNCTION__, etc.
 
 Linted the entire ACPICA source tree for both 32-bit and 64-bit.
 
 Implemented support to display an object count summary for the AML 
 Debugger 
 commands Object and Methods.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.6K Code, 11.6K Data,  90.2K Total
     Debug Version:     170.0K Code, 69.7K Data, 239.7K Total
   Current Release:
     Non-Debug Version:  78.6K Code, 11.7K Data,  90.3K Total
     Debug Version:     167.0K Code, 69.9K Data, 236.9K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a regression that appeared in the 20050708 version of the compiler 
 where an error message was inadvertently emitted for invocations of the 
 _OSI 
 reserved control method.
 
 ----------------------------------------
 08 July 2005.  Summary of changes for version 20050708:
 
 1) ACPI CA Core Subsystem:
 
 The use of the CPU stack in the debug version of the subsystem has been 
 considerably reduced. Previously, a debug structure was declared in every 
 function that used the debug macros. This structure has been removed in 
 favor of declaring the individual elements as parameters to the debug 
 functions. This reduces the cumulative stack use during nested execution 
 of 
 ACPI function calls at the cost of a small increase in the code size of 
 the 
 debug version of the subsystem. With assistance from Alexey Starikovskiy 
 and 
 Len Brown.
 
 Added the ACPI_GET_FUNCTION_NAME macro to enable the compiler-dependent 
 headers to define a macro that will return the current function name at 
 runtime (such as __FUNCTION__ or _func_, etc.) The function name is used 
 by 
 the debug trace output. If ACPI_GET_FUNCTION_NAME is not defined in the 
 compiler-dependent header, the function name is saved on the CPU stack 
 (one 
 pointer per function.) This mechanism is used because apparently there 
 exists no standard ANSI-C defined macro that that returns the function 
 name.
 
 Redesigned and reimplemented the "Owner ID" mechanism used to track 
 namespace objects created/deleted by ACPI tables and control method 
 execution. A bitmap is now used to allocate and free the IDs, thus solving 
 the wraparound problem present in the previous implementation. The size of 
 the namespace node descriptor was reduced by 2 bytes as a result (Alexey 
 Starikovskiy).
 
 Removed the UINT32_BIT and UINT16_BIT types that were used for the 
 bitfield 
 flag definitions within the headers for the predefined ACPI tables. These 
 have been replaced by UINT8_BIT in order to increase the code portability 
 of 
 the subsystem. If the use of UINT8 remains a problem, we may be forced to 
 eliminate bitfields entirely because of a lack of portability.
 
 Enhanced the performance of the AcpiUtUpdateObjectReference procedure. 
 This 
 is a frequently used function and this improvement increases the 
 performance 
 of the entire subsystem (Alexey Starikovskiy).
 
 Fixed several possible memory leaks and the inverse - premature object 
 deletion (Alexey Starikovskiy).
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.6K Code, 11.5K Data,  90.1K Total
     Debug Version:     165.2K Code, 69.6K Data, 234.8K Total
   Current Release:
     Non-Debug Version:  78.6K Code, 11.6K Data,  90.2K Total
     Debug Version:     170.0K Code, 69.7K Data, 239.7K Total
 
 ----------------------------------------
 24 June 2005.  Summary of changes for version 20050624:
 
 1) ACPI CA Core Subsystem:
 
 Modified the new OSL cache interfaces to use ACPI_CACHE_T as the type for 
 the host-defined cache object. This allows the OSL implementation to 
 define 
 and type this object in any manner desired, simplifying the OSL 
 implementation. For example, ACPI_CACHE_T is defined as kmem_cache_t for 
 Linux, and should be defined in the OS-specific header file for other 
 operating systems as required.
 
 Changed the interface to AcpiOsAcquireObject to directly return the 
 requested object as the function return (instead of ACPI_STATUS.) This 
 change was made for performance reasons, since this is the purpose of the 
 interface in the first place. AcpiOsAcquireObject is now similar to the 
 AcpiOsAllocate interface.
 
 Implemented a new AML debugger command named Businfo. This command 
 displays 
 information about all devices that have an associate _PRT object. The 
 _ADR, 
 _HID, _UID, and _CID are displayed for these devices.
 
 Modified the initialization sequence in AcpiInitializeSubsystem to call 
 the 
 OSL interface AcpiOslInitialize first, before any local initialization. 
 This 
 change was required because the global initialization now calls OSL 
 interfaces.
 
 Enhanced the Dump command to display the entire contents of Package 
 objects 
 (including all sub-objects and their values.) 
 
 Restructured the code base to split some files because of size and/or 
 because the code logically belonged in a separate file. New files are 
 listed 
 below. All makefiles and project files included in the ACPI CA release 
 have 
 been updated.
     utilities/utcache.c           /* Local cache interfaces */
     utilities/utmutex.c           /* Local mutex support */
     utilities/utstate.c           /* State object support */
     interpreter/parser/psloop.c   /* Main AML parse loop */
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.3K Code, 11.6K Data,  89.9K Total
     Debug Version:     164.0K Code, 69.1K Data, 233.1K Total
   Current Release:
     Non-Debug Version:  78.6K Code, 11.5K Data,  90.1K Total
     Debug Version:     165.2K Code, 69.6K Data, 234.8K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a regression introduced in version 20050513 where the use of a 
 Package 
 object within a Case() statement caused a compile time exception. The 
 original behavior has been restored (a Match() operator is emitted.)
 
 ----------------------------------------
 17 June 2005.  Summary of changes for version 20050617:
 
 1) ACPI CA Core Subsystem:
 
 Moved the object cache operations into the OS interface layer (OSL) to 
 allow 
 the host OS to handle these operations if desired (for example, the Linux 
 OSL will invoke the slab allocator). This support is optional; the compile 
 time define ACPI_USE_LOCAL_CACHE may be used to utilize the original cache 
 code in the ACPI CA core. The new OSL interfaces are shown below. See 
 utalloc.c for an example implementation, and acpiosxf.h for the exact 
 interface definitions. With assistance from Alexey Starikovskiy.
     AcpiOsCreateCache
     AcpiOsDeleteCache
     AcpiOsPurgeCache
     AcpiOsAcquireObject
     AcpiOsReleaseObject
 
 Modified the interfaces to AcpiOsAcquireLock and AcpiOsReleaseLock to 
 return 
 and restore a flags parameter. This fits better with many OS lock models. 
 Note: the current execution state (interrupt handler or not) is no longer 
 passed to these interfaces. If necessary, the OSL must determine this 
 state 
 by itself, a simple and fast operation. With assistance from Alexey 
 Starikovskiy.
 
 Fixed a problem in the ACPI table handling where a valid XSDT was assumed 
 present if the revision of the RSDP was 2 or greater. According to the 
 ACPI 
 specification, the XSDT is optional in all cases, and the table manager 
 therefore now checks for both an RSDP >=2 and a valid XSDT pointer. 
 Otherwise, the RSDT pointer is used. Some ACPI 2.0 compliant BIOSs contain 
 only the RSDT.
 
 Fixed an interpreter problem with the Mid() operator in the case of an 
 input 
 string where the resulting output string is of zero length. It now 
 correctly 
 returns a valid, null terminated string object instead of a string object 
 with a null pointer.
 
 Fixed a problem with the control method argument handling to allow a store 
 to an Arg object that already contains an object of type Device. The 
 Device 
 object is now correctly overwritten. Previously, an error was returned.
 
 
 Enhanced the debugger Find command to emit object values in addition to 
 the 
 found object pathnames. The output format is the same as the dump 
 namespace 
 command.
 
 Enhanced the debugger Set command. It now has the ability to set the value 
 of any Named integer object in the namespace (Previously, only method 
 locals 
 and args could be set.)
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.1K Code, 11.6K Data,  89.7K Total
     Debug Version:     164.0K Code, 69.3K Data, 233.3K Total
   Current Release:
     Non-Debug Version:  78.3K Code, 11.6K Data,  89.9K Total
     Debug Version:     164.0K Code, 69.1K Data, 233.1K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a regression in the disassembler where if/else/while constructs were 
 output incorrectly. This problem was introduced in the previous release 
 (20050526). This problem also affected the single-step disassembly in the 
 debugger.
 
 Fixed a problem where compiling the reserved _OSI method would randomly 
 (but 
 rarely) produce compile errors.
 
 Enhanced the disassembler to emit compilable code in the face of incorrect 
 AML resource descriptors. If the optional ResourceSourceIndex is present, 
 but the ResourceSource is not, do not emit the ResourceSourceIndex in the 
 disassembly. Otherwise, the resulting code cannot be compiled without 
 errors.
 
 ----------------------------------------
 26 May 2005.  Summary of changes for version 20050526:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support to execute Type 1 and Type 2 AML opcodes appearing at 
 the module level (not within a control method.) These opcodes are executed 
 exactly once at the time the table is loaded. This type of code was legal 
 up 
 until the release of ACPI 2.0B (2002) and is now supported within ACPI CA 
 in 
 order to provide backwards compatibility with earlier BIOS 
 implementations. 
 This eliminates the "Encountered executable code at module level" warning 
 that was previously generated upon detection of such code.
 
 Fixed a problem in the interpreter where an AE_NOT_FOUND exception could 
 inadvertently be generated during the lookup of namespace objects in the 
 second pass parse of ACPI tables and control methods. It appears that this 
 problem could occur during the resolution of forward references to 
 namespace 
 objects.
 
 Added the ACPI_MUTEX_DEBUG #ifdef to the AcpiUtReleaseMutex function, 
 corresponding to the same #ifdef in the AcpiUtAcquireMutex function. This 
 allows the deadlock detection debug code to be compiled out in the normal 
 case, improving mutex performance (and overall subsystem performance) 
 considerably.
 
 Implemented a handful of miscellaneous fixes for possible memory leaks on 
 error conditions and error handling control paths. These fixes were 
 suggested by FreeBSD and the Coverity Prevent source code analysis tool.
 
 Added a check for a null RSDT pointer in AcpiGetFirmwareTable (tbxfroot.c) 
 to prevent a fault in this error case.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.2K Code, 11.6K Data,  89.8K Total
     Debug Version:     163.7K Code, 69.3K Data, 233.0K Total
   Current Release:
     Non-Debug Version:  78.1K Code, 11.6K Data,  89.7K Total
     Debug Version:     164.0K Code, 69.3K Data, 233.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support to allow Type 1 and Type 2 ASL operators to appear at 
 the module level (not within a control method.) These operators will be 
 executed once at the time the table is loaded. This type of code was legal 
 up until the release of ACPI 2.0B (2002) and is now supported by the iASL 
 compiler in order to provide backwards compatibility with earlier BIOS ASL 
 code.
 
 The ACPI integer width (specified via the table revision ID or the -r 
 override, 32 or 64 bits) is now used internally during compile-time 
 constant 
 folding to ensure that constants are truncated to 32 bits if necessary. 
 Previously, the revision ID value was only emitted in the AML table 
 header.
 
 An error message is now generated for the Mutex and Method operators if 
 the 
 SyncLevel parameter is outside the legal range of 0 through 15.
 
 Fixed a problem with the Method operator ParameterTypes list handling 
 (ACPI 
 3.0). Previously, more than 2 types or 2 arguments generated a syntax 
 error.  
 The actual underlying implementation of method argument typechecking is 
 still under development, however.
 
 ----------------------------------------
 13 May 2005.  Summary of changes for version 20050513:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for PCI Express root bridges -- added support for 
 device 
 PNP0A08 in the root bridge search within AcpiEvPciConfigRegionSetup.
 
 The interpreter now automatically truncates incoming 64-bit constants to 
 32 
 bits if currently executing out of a 32-bit ACPI table (Revision < 2). 
 This 
 also affects the iASL compiler constant folding. (Note: as per below, the 
 iASL compiler no longer allows 64-bit constants within 32-bit tables.)
 
 Fixed a problem where string and buffer objects with "static" pointers 
 (pointers to initialization data within an ACPI table) were not handled 
 consistently. The internal object copy operation now always copies the 
 data 
 to a newly allocated buffer, regardless of whether the source object is 
 static or not.
 
 Fixed a problem with the FromBCD operator where an implicit result 
 conversion was improperly performed while storing the result to the target 
 operand. Since this is an "explicit conversion" operator, the implicit 
 conversion should never be performed on the output.
 
 Fixed a problem with the CopyObject operator where a copy to an existing 
 named object did not always completely overwrite the existing object 
 stored 
 at name. Specifically, a buffer-to-buffer copy did not delete the existing 
 buffer.
 
 Replaced "InterruptLevel" with "InterruptNumber" in all GPE interfaces and 
 structs for consistency.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.2K Code, 11.6K Data,  89.8K Total
     Debug Version:     163.7K Code, 69.3K Data, 233.0K Total
   Current Release: (Same sizes)
     Non-Debug Version:  78.2K Code, 11.6K Data,  89.8K Total
     Debug Version:     163.7K Code, 69.3K Data, 233.0K Total
 
 
 2) iASL Compiler/Disassembler:
 
 The compiler now emits a warning if an attempt is made to generate a 64-
 bit 
 integer constant from within a 32-bit ACPI table (Revision < 2). The 
 integer 
 is truncated to 32 bits.
 
 Fixed a problem with large package objects: if the static length of the 
 package is greater than 255, the "variable length package" opcode is 
 emitted. Previously, this caused an error. This requires an update to the 
 ACPI spec, since it currently (incorrectly) states that packages larger 
 than 
 255 elements are not allowed.
 
 The disassembler now correctly handles variable length packages and 
 packages 
 larger than 255 elements.
 
 ----------------------------------------
 08 April 2005.  Summary of changes for version 20050408:
 
 1) ACPI CA Core Subsystem:
 
 Fixed three cases in the interpreter where an "index" argument to an ASL 
 function was still (internally) 32 bits instead of the required 64 bits. 
 This was the Index argument to the Index, Mid, and Match operators.
 
 The "strupr" function is now permanently local (AcpiUtStrupr), since this 
 is 
 not a POSIX-defined function and not present in most kernel-level C 
 libraries. All references to the C library strupr function have been 
 removed 
 from the headers.
 
 Completed the deployment of static functions/prototypes. All prototypes 
 with 
 the static attribute have been moved from the headers to the owning C 
 file.
 
 Implemented an extract option (-e) for the AcpiBin utility (AML binary 
 utility). This option allows the utility to extract individual ACPI tables 
 from the output of AcpiDmp. It provides the same functionality of the 
 acpixtract.pl perl script without the worry of setting the correct perl 
 options. AcpiBin runs on Windows and has not yet been generated/validated 
 in 
 the Linux/Unix environment (but should be soon).
  
 Updated and fixed the table dump option for AcpiBin (-d). This option 
 converts a single ACPI table to a hex/ascii file, similar to the output of 
 AcpiDmp.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.0K Code, 11.6K Data,  89.6K Total
     Debug Version:     163.5K Code, 69.3K Data, 232.8K Total
   Current Release:
     Non-Debug Version:  78.2K Code, 11.6K Data,  89.8K Total
     Debug Version:     163.7K Code, 69.3K Data, 233.0K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Disassembler fix: Added a check to ensure that the table length found in 
 the 
 ACPI table header within the input file is not longer than the actual 
 input 
 file size. This indicates some kind of file or table corruption.
 
 ----------------------------------------
 29 March 2005.  Summary of changes for version 20050329:
 
 1) ACPI CA Core Subsystem:
 
 An error is now generated if an attempt is made to create a Buffer Field 
 of 
 length zero (A CreateField with a length operand of zero.)
 
 The interpreter now issues a warning whenever executable code at the 
 module 
 level is detected during ACPI table load. This will give some idea of the 
 prevalence of this type of code.
 
 Implemented support for references to named objects (other than control 
 methods) within package objects.
 
 Enhanced package object output for the debug object. Package objects are 
 now 
 completely dumped, showing all elements.
 
 Enhanced miscellaneous object output for the debug object. Any object can 
 now be written to the debug object (for example, a device object can be 
 written, and the type of the object will be displayed.)
 
 The "static" qualifier has been added to all local functions across both 
 the 
 core subsystem and the iASL compiler.
 
 The number of "long" lines (> 80 chars) within the source has been 
 significantly reduced, by about 1/3.
 
 Cleaned up all header files to ensure that all CA/iASL functions are 
 prototyped (even static functions) and the formatting is consistent.
 
 Two new header files have been added, acopcode.h and acnames.h.
 
 Removed several obsolete functions that were no longer used.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.3K Code, 11.5K Data,  89.8K Total
     Debug Version:     165.4K Code, 69.7K Data, 236.1K Total
   Current Release:
     Non-Debug Version:  78.0K Code, 11.6K Data,  89.6K Total
     Debug Version:     163.5K Code, 69.3K Data, 232.8K Total
 
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with the resource descriptor generation/support. For the 
 ResourceSourceIndex and the ResourceSource fields, both must be present, 
 or 
 both must be not present - can't have one without the other.
 
 The compiler now returns non-zero from the main procedure if any errors 
 have 
 occurred during the compilation.
 
 
 ----------------------------------------
 09 March 2005.  Summary of changes for version 20050309:
 
 1) ACPI CA Core Subsystem:
 
 The string-to-buffer implicit conversion code has been modified again 
 after 
 a change to the ACPI specification.  In order to match the behavior of the 
 other major ACPI implementation, the target buffer is no longer truncated 
 if 
 the source string is smaller than an existing target buffer. This change 
 requires an update to the ACPI spec, and should eliminate the recent 
 AE_AML_BUFFER_LIMIT issues.
 
 The "implicit return" support was rewritten to a new algorithm that solves 
 the general case. Rather than attempt to determine when a method is about 
 to 
 exit, the result of every ASL operator is saved momentarily until the very 
 next ASL operator is executed. Therefore, no matter how the method exits, 
 there will always be a saved implicit return value. This feature is only 
 enabled with the AcpiGbl_EnableInterpreterSlack flag, and should eliminate 
 AE_AML_NO_RETURN_VALUE errors when enabled.
 
 Implemented implicit conversion support for the predicate (operand) of the 
 If, Else, and While operators. String and Buffer arguments are 
 automatically 
 converted to Integers.
 
 Changed the string-to-integer conversion behavior to match the new ACPI 
 errata: "If no integer object exists, a new integer is created. The ASCII 
 string is interpreted as a hexadecimal constant. Each string character is 
 interpreted as a hexadecimal value ('0'-'9', 'A'-'F', 'a', 'f'), starting 
 with the first character as the most significant digit, and ending with 
 the 
 first non-hexadecimal character or end-of-string." This means that the 
 first 
 non-hex character terminates the conversion and this is the code that was 
 changed.
 
 Fixed a problem where the ObjectType operator would fail (fault) when used 
 on an Index of a Package which pointed to a null package element. The 
 operator now properly returns zero (Uninitialized) in this case.
 
 Fixed a problem where the While operator used excessive memory by not 
 properly popping the result stack during execution. There was no memory 
 leak 
 after execution, however. (Code provided by Valery Podrezov.)
 
 Fixed a problem where references to control methods within Package objects 
 caused the method to be invoked, instead of producing a reference object 
 pointing to the method.
 
 Restructured and simplified the pswalk.c module (AcpiPsDeleteParseTree) to 
 improve performance and reduce code size. (Code provided by Alexey 
 Starikovskiy.)
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.3K Code, 11.5K Data,  89.8K Total
     Debug Version:     165.4K Code, 69.6K Data, 236.0K Total
   Current Release:
     Non-Debug Version:  78.3K Code, 11.5K Data,  89.8K Total
     Debug Version:     165.4K Code, 69.7K Data, 236.1K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with the Return operator with no arguments. Since the AML 
 grammar for the byte encoding requires an operand for the Return opcode, 
 the 
 compiler now emits a Return(Zero) for this case.  An ACPI specification 
 update has been written for this case.
 
 For tables other than the DSDT, namepath optimization is automatically 
 disabled. This is because SSDTs can be loaded anywhere in the namespace, 
 the 
 compiler has no knowledge of where, and thus cannot optimize namepaths.
 
 Added "ProcessorObj" to the ObjectTypeKeyword list. This object type was 
 inadvertently omitted from the ACPI specification, and will require an 
 update to the spec.
 
 The source file scan for ASCII characters is now optional (-a). This 
 change 
 was made because some vendors place non-ascii characters within comments. 
 However, the scan is simply a brute-force byte compare to ensure all 
 characters in the file are in the range 0x00 to 0x7F.
 
 Fixed a problem with the CondRefOf operator where the compiler was 
 inappropriately checking for the existence of the target. Since the point 
 of 
 the operator is to check for the existence of the target at run-time, the 
 compiler no longer checks for the target existence.
 
 Fixed a problem where errors generated from the internal AML interpreter 
 during constant folding were not handled properly, causing a fault.
 
 Fixed a problem with overly aggressive range checking for the Stall 
 operator. The valid range (max 255) is now only checked if the operand is 
 of 
 type Integer. All other operand types cannot be statically checked.
 
 Fixed a problem where control method references within the RefOf, DeRefOf, 
 and ObjectType operators were not treated properly. They are now treated 
 as 
 actual references, not method invocations.
 
 Fixed and enhanced the "list namespace" option (-ln). This option was 
 broken 
 a number of releases ago.
 
 Improved error handling for the Field, IndexField, and BankField 
 operators. 
 The compiler now cleanly reports and recovers from errors in the field 
 component (FieldUnit) list.
 
 Fixed a disassembler problem where the optional ResourceDescriptor fields 
 TRS and TTP were not always handled correctly.
 
 Disassembler - Comments in output now use "//" instead of "/*"
 
 ----------------------------------------
 28 February 2005.  Summary of changes for version 20050228:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where the result of an Index() operator (an object 
 reference) must increment the reference count on the target object for the 
 life of the object reference.
 
 Implemented AML Interpreter and Debugger support for the new ACPI 3.0 
 Extended Address (IO, Memory, Space), QwordSpace, DwordSpace, and 
 WordSpace 
 resource descriptors.
 
 Implemented support in the _OSI method for the ACPI 3.0 "Extended Address 
 Space Descriptor" string, indicating interpreter support for the 
 descriptors 
 above.
 
 Implemented header support for the new ACPI 3.0 FADT flag bits.
 
 Implemented header support for the new ACPI 3.0 PCI Express bits for the 
 PM1 
 status/enable registers.
 
 Updated header support for the MADT processor local Apic struct and MADT 
 platform interrupt source struct for new ACPI 3.0 fields.
 
 Implemented header support for the SRAT and SLIT ACPI tables.
 
 Implemented the -s switch in AcpiExec to enable the "InterpreterSlack" 
 flag 
 at runtime.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.2K Code, 11.5K Data,  89.7K Total
     Debug Version:     164.9K Code, 69.2K Data, 234.1K Total
   Current Release:
     Non-Debug Version:  78.3K Code, 11.5K Data,  89.8K Total
     Debug Version:     165.4K Code, 69.6K Data, 236.0K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with the internal 64-bit String-to-integer conversion with 
 strings less than two characters long.
 
 Fixed a problem with constant folding where the result of the Index() 
 operator can not be considered a constant. This means that Index() cannot 
 be 
 a type3 opcode and this will require an update to the ACPI specification.
 
 Disassembler: Implemented support for the TTP, MTP, and TRS resource 
 descriptor fields. These fields were inadvertently ignored and not output 
 in 
 the disassembly of the resource descriptor.
 
 
  ----------------------------------------
 11 February 2005.  Summary of changes for version 20050211:
 
 1) ACPI CA Core Subsystem:
 
 Implemented ACPI 3.0 support for implicit conversion within the Match() 
 operator. MatchObjects can now be of type integer, buffer, or string 
 instead 
 of just type integer.  Package elements are implicitly converted to the 
 type 
 of the MatchObject. This change aligns the behavior of Match() with the 
 behavior of the other logical operators (LLess(), etc.) It also requires 
 an 
 errata change to the ACPI specification as this support was intended for 
 ACPI 3.0, but was inadvertently omitted.
 
 Fixed a problem with the internal implicit "to buffer" conversion. Strings 
 that are converted to buffers will cause buffer truncation if the string 
 is 
 smaller than the target buffer. Integers that are converted to buffers 
 will 
 not cause buffer truncation, only zero extension (both as per the ACPI 
 spec.) The problem was introduced when code was added to truncate the 
 buffer, but this should not be performed in all cases, only the string 
 case.
 
 Fixed a problem with the Buffer and Package operators where the 
 interpreter 
 would get confused if two such operators were used as operands to an ASL 
 operator (such as LLess(Buffer(1){0},Buffer(1){1}). The internal result 
 stack was not being popped after the execution of these operators, 
 resulting 
 in an AE_NO_RETURN_VALUE exception.
 
 Fixed a problem with constructs of the form Store(Index(...),...). The 
 reference object returned from Index was inadvertently resolved to an 
 actual 
 value. This problem was introduced in version 20050114 when the behavior 
 of 
 Store() was modified to restrict the object types that can be used as the 
 source operand (to match the ACPI specification.)
 
 Reduced excessive stack use within the AcpiGetObjectInfo procedure.
 
 Added a fix to aclinux.h to allow generation of AcpiExec on Linux.
 
 Updated the AcpiSrc utility to add the FADT_DESCRIPTOR_REV2_MINUS struct.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.1K Code, 11.5K Data,  89.6K Total
     Debug Version:     164.8K Code, 69.2K Data, 234.0K Total
   Current Release:
     Non-Debug Version:  78.2K Code, 11.5K Data,  89.7K Total
     Debug Version:     164.9K Code, 69.2K Data, 234.1K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a code generation problem in the constant folding optimization code 
 where incorrect code was generated if a constant was reduced to a buffer 
 object (i.e., a reduced type 5 opcode.)
 
 Fixed a typechecking problem for the ToBuffer operator. Caused by an 
 incorrect return type in the internal opcode information table.
 
 ----------------------------------------
 25 January 2005.  Summary of changes for version 20050125:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a recently introduced problem with the Global Lock where the 
 underlying semaphore was not created.  This problem was introduced in 
 version 20050114, and caused an AE_AML_NO_OPERAND exception during an 
 Acquire() operation on _GL.
 
 The local object cache is now optional, and is disabled by default. Both 
 AcpiExec and the iASL compiler enable the cache because they run in user 
 mode and this enhances their performance. #define ACPI_ENABLE_OBJECT_CACHE 
 to enable the local cache.
 
 Fixed an issue in the internal function AcpiUtEvaluateObject concerning 
 the 
 optional "implicit return" support where an error was returned if no 
 return 
 object was expected, but one was implicitly returned. AE_OK is now 
 returned 
 in this case and the implicitly returned object is deleted. 
 AcpiUtEvaluateObject is only occasionally used, and only to execute 
 reserved 
 methods such as _STA and _INI where the return type is known up front.
 
 Fixed a few issues with the internal convert-to-integer code. It now 
 returns 
 an error if an attempt is made to convert a null string, a string of only 
 blanks/tabs, or a zero-length buffer. This affects both implicit 
 conversion 
 and explicit conversion via the ToInteger() operator.
 
 The internal debug code in AcpiUtAcquireMutex has been commented out. It 
 is 
 not needed for normal operation and should increase the performance of the 
 entire subsystem. The code remains in case it is needed for debug purposes 
 again.
 
 The AcpiExec source and makefile are included in the Unix/Linux package 
 for 
 the first time.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.4K Code,  11.5K Data,   89.9K Total
     Debug Version:     165.4K Code,  69.4K Data,  234.8K Total
   Current Release:
     Non-Debug Version:  78.1K Code,  11.5K Data,   89.6K Total
     Debug Version:     164.8K Code,  69.2K Data,  234.0K Total
 
 2) iASL Compiler/Disassembler:
 
 Switch/Case support: A warning is now issued if the type of the Switch 
 value 
 cannot be determined at compile time. For example, Switch(Arg0) will 
 generate the warning, and the type is assumed to be an integer. As per the 
 ACPI spec, use a construct such as Switch(ToInteger(Arg0)) to eliminate 
 the 
 warning.
 
 Switch/Case support: Implemented support for buffer and string objects as 
 the switch value.  This is an ACPI 3.0 feature, now that LEqual supports 
 buffers and strings.
 
 Switch/Case support: The emitted code for the LEqual() comparisons now 
 uses 
 the switch value as the first operand, not the second. The case value is 
 now 
 the second operand, and this allows the case value to be implicitly 
 converted to the type of the switch value, not the other way around.
 
 Switch/Case support: Temporary variables are now emitted immediately 
 within 
 the control method, not at the global level. This means that there are now 
 36 temps available per-method, not 36 temps per-module as was the case 
 with 
 the earlier implementation (_T_0 through _T_9 and _T_A through _T_Z.)
 
 ----------------------------------------
 14 January 2005.  Summary of changes for version 20050114:
 
 Added 2005 copyright to all module headers.  This affects every module in 
 the core subsystem, iASL compiler, and the utilities.
 
 1) ACPI CA Core Subsystem:
 
 Fixed an issue with the String-to-Buffer conversion code where the string 
 null terminator was not included in the buffer after conversion, but there 
 is existing ASL that assumes the string null terminator is included. This 
 is 
 the root of the ACPI_AML_BUFFER_LIMIT regression. This problem was 
 introduced in the previous version when the code was updated to correctly 
 set the converted buffer size as per the ACPI specification. The ACPI spec 
 is ambiguous and will be updated to specify that the null terminator must 
 be 
 included in the converted buffer. This also affects the ToBuffer() ASL 
 operator.
 
 Fixed a problem with the Mid() ASL/AML operator where it did not work 
 correctly on Buffer objects. Newly created sub-buffers were not being 
 marked 
 as initialized.
 
 
 Fixed a problem in AcpiTbFindTable where incorrect string compares were 
 performed on the OemId and OemTableId table header fields.  These fields 
 are 
 not null terminated, so strncmp is now used instead of strcmp.
 
 Implemented a restriction on the Store() ASL/AML operator to align the 
 behavior with the ACPI specification.  Previously, any object could be 
 used 
 as the source operand.  Now, the only objects that may be used are 
 Integers, 
 Buffers, Strings, Packages, Object References, and DDB Handles.  If 
 necessary, the original behavior can be restored by enabling the 
 EnableInterpreterSlack flag.
 
 Enhanced the optional "implicit return" support to allow an implicit 
 return 
 value from methods that are invoked externally via the AcpiEvaluateObject 
 interface.  This enables implicit returns from the _STA and _INI methods, 
 for example.
 
 Changed the Revision() ASL/AML operator to return the current version of 
 the 
 AML interpreter, in the YYYYMMDD format. Previously, it incorrectly 
 returned 
 the supported ACPI version (This is the function of the _REV method).
 
 Updated the _REV predefined method to return the currently supported 
 version 
 of ACPI, now 3.
 
 Implemented batch mode option for the AcpiExec utility (-b).
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.3K Code,  11.5K Data,   89.8K Total
     Debug Version:     165.3K Code,  69.4K Data,  234.7K Total
   Current Release:
     Non-Debug Version:  78.4K Code,  11.5K Data,   89.9K Total
     Debug Version:     165.4K Code,  69.4K Data,  234.8K Total
 
 ----------------------------------------
 10 December 2004.  Summary of changes for version 20041210:
 
 ACPI 3.0 support is nearing completion in both the iASL compiler and the 
 ACPI CA core subsystem.
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem in the ToDecimalString operator where the resulting string 
 length was incorrectly calculated. The length is now calculated exactly, 
 eliminating incorrect AE_STRING_LIMIT exceptions.
 
 Fixed a problem in the ToHexString operator to allow a maximum 200 
 character 
 string to be produced.
 
 Fixed a problem in the internal string-to-buffer and buffer-to-buffer copy 
 routine where the length of the resulting buffer was not truncated to the 
 new size (if the target buffer already existed).
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.3K Code,  11.5K Data,   89.8K Total
     Debug Version:     164.7K Code,  68.5K Data,  233.2K Total
   Current Release:
     Non-Debug Version:  78.3K Code,  11.5K Data,   89.8K Total
     Debug Version:     165.3K Code,  69.4K Data,  234.7K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented the new ACPI 3.0 resource template macros - DWordSpace, 
 ExtendedIO, ExtendedMemory, ExtendedSpace, QWordSpace, and WordSpace. 
 Includes support in the disassembler.
 
 Implemented support for the new (ACPI 3.0) parameter to the Register 
 macro, 
 AccessSize.
 
 Fixed a problem where the _HE resource name for the Interrupt macro was 
 referencing bit 0 instead of bit 1.
 
 Implemented check for maximum 255 interrupts in the Interrupt macro.
 
 Fixed a problem with the predefined resource descriptor names where 
 incorrect AML code was generated if the offset within the resource buffer 
 was 0 or 1.  The optimizer shortened the AML code to a single byte opcode 
 but did not update the surrounding package lengths.
 
 Changes to the Dma macro:  All channels within the channel list must be in 
 the range 0-7.  Maximum 8 channels can be specified. BusMaster operand is 
 optional (default is BusMaster).
 
 Implemented check for maximum 7 data bytes for the VendorShort macro.
 
 The ReadWrite parameter is now optional for the Memory32 and similar 
 macros.
 
 ----------------------------------------
 03 December 2004.  Summary of changes for version 20041203:
 
 1) ACPI CA Core Subsystem:
 
 The low-level field insertion/extraction code (exfldio) has been 
 completely 
 rewritten to eliminate unnecessary complexity, bugs, and boundary 
 conditions.
 
 Fixed a problem in the ToInteger, ToBuffer, ToHexString, and 
 ToDecimalString 
 operators where the input operand could be inadvertently deleted if no 
 conversion was necessary (e.g., if the input to ToInteger was an Integer 
 object.)
 
 Fixed a problem with the ToDecimalString and ToHexString where an 
 incorrect 
 exception code was returned if the resulting string would be > 200 chars.  
 AE_STRING_LIMIT is now returned.
 
 Fixed a problem with the Concatenate operator where AE_OK was always 
 returned, even if the operation failed.
 
 Fixed a problem in oswinxf (used by AcpiExec and iASL) to allow > 128 
 semaphores to be allocated.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.5K Code,  11.5K Data,   90.0K Total
     Debug Version:     165.2K Code,  68.6K Data,  233.8K Total
   Current Release:
     Non-Debug Version:  78.3K Code,  11.5K Data,   89.8K Total
     Debug Version:     164.7K Code,  68.5K Data,  233.2K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed typechecking for the ObjectType and SizeOf operators.  Problem was 
 recently introduced in 20041119.
 
 Fixed a problem with the ToUUID macro where the upper nybble of each 
 buffer 
 byte was inadvertently set to zero.
 
 ----------------------------------------
 19 November 2004.  Summary of changes for version 20041119:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem in the internal ConvertToInteger routine where new 
 integers 
 were not truncated to 32 bits for 32-bit ACPI tables. This routine 
 converts 
 buffers and strings to integers.
 
 Implemented support to store a value to an Index() on a String object. 
 This 
 is an ACPI 2.0 feature that had not yet been implemented.
 
 Implemented new behavior for storing objects to individual package 
 elements 
 (via the Index() operator). The previous behavior was to invoke the 
 implicit 
 conversion rules if an object was already present at the index.  The new 
 behavior is to simply delete any existing object and directly store the 
 new 
 object. Although the ACPI specification seems unclear on this subject, 
 other 
 ACPI implementations behave in this manner.  (This is the root of the 
 AE_BAD_HEX_CONSTANT issue.)
 
 Modified the RSDP memory scan mechanism to support the extended checksum 
 for 
 ACPI 2.0 (and above) RSDPs. Note that the search continues until a valid 
 RSDP signature is found with a valid checksum.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.5K Code,  11.5K Data,   90.0K Total
     Debug Version:     165.2K Code,  68.6K Data,  233.8K Total
   Current Release:
     Non-Debug Version:  78.5K Code,  11.5K Data,   90.0K Total
     Debug Version:     165.2K Code,  68.6K Data,  233.8K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a missing semicolon in the aslcompiler.y file.
 
 ----------------------------------------
 05 November 2004.  Summary of changes for version 20041105:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for FADT revision 2.  This was an interim table 
 (between 
 ACPI 1.0 and ACPI 2.0) that adds support for the FADT reset register.
 
 Implemented optional support to allow uninitialized LocalX and ArgX 
 variables in a control method.  The variables are initialized to an 
 Integer 
 object with a value of zero.  This support is enabled by setting the 
 AcpiGbl_EnableInterpreterSlack flag to TRUE.
 
 Implemented support for Integer objects for the SizeOf operator.  Either 4 
 or 8 is returned, depending on the current integer size (32-bit or 64-bit, 
 depending on the parent table revision).
 
 Fixed a problem in the implementation of the SizeOf and ObjectType 
 operators 
 where the operand was resolved to a value too early, causing incorrect 
 return values for some objects.
 
 Fixed some possible memory leaks during exceptional conditions.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.0K Code,  11.5K Data,   89.5K Total
     Debug Version:     164.8K Code,  68.6K Data,  233.4K Total
   Current Release:
     Non-Debug Version:  78.5K Code,  11.5K Data,   90.0K Total
     Debug Version:     165.2K Code,  68.6K Data,  233.8K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support for all ACPI 3.0 reserved names and methods.
 
 Implemented all ACPI 3.0 grammar elements in the front-end, including 
 support for semicolons.
 
 Implemented the ACPI 3.0 Function() and ToUUID() macros
 
 Fixed a problem in the disassembler where a Scope() operator would not be 
 emitted properly if the target of the scope was in another table.
 
 ----------------------------------------
 15 October 2004.  Summary of changes for version 20041015:
 
 Note:  ACPI CA is currently undergoing an in-depth and complete formal 
 evaluation to test/verify the following areas. Other suggestions are 
 welcome. This will result in an increase in the frequency of releases and 
 the number of bug fixes in the next few months.
   - Functional tests for all ASL/AML operators
   - All implicit/explicit type conversions
   - Bit fields and operation regions
   - 64-bit math support and 32-bit-only "truncated" math support
   - Exceptional conditions, both compiler and interpreter
   - Dynamic object deletion and memory leaks
   - ACPI 3.0 support when implemented
   - External interfaces to the ACPI subsystem
 
 
 1) ACPI CA Core Subsystem:
 
 Fixed two alignment issues on 64-bit platforms - within debug statements 
 in 
 AcpiEvGpeDetect and AcpiEvCreateGpeBlock. Removed references to the 
 Address 
 field within the non-aligned ACPI generic address structure.
 
 Fixed a problem in the Increment and Decrement operators where incorrect 
 operand resolution could result in the inadvertent modification of the 
 original integer when the integer is passed into another method as an 
 argument and the arg is then incremented/decremented.
 
 Fixed a problem in the FromBCD operator where the upper 32-bits of a 64-
 bit 
 BCD number were truncated during conversion.
 
 Fixed a problem in the ToDecimal operator where the length of the 
 resulting 
 string could be set incorrectly too long if the input operand was a Buffer 
 object.
 
 Fixed a problem in the Logical operators (LLess, etc.) where a NULL byte 
 (0) 
 within a buffer would prematurely terminate a compare between buffer 
 objects.
 
 Added a check for string overflow (>200 characters as per the ACPI 
 specification) during the Concatenate operator with two string operands.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.8K Code,  11.5K Data,   89.3K Total
     Debug Version:     164.6K Code,  68.5K Data,  233.1K Total
   Current Release:
     Non-Debug Version:  78.0K Code,  11.5K Data,   89.5K Total
     Debug Version:     164.8K Code,  68.6K Data,  233.4K Total
 
 
 
 2) iASL Compiler/Disassembler:
 
 Allow the use of the ObjectType operator on uninitialized Locals and Args 
 (returns 0 as per the ACPI specification).
 
 Fixed a problem where the compiler would fault if there was a syntax error 
 in the FieldName of all of the various CreateXXXField operators.
 
 Disallow the use of lower case letters within the EISAID macro, as per the 
 ACPI specification.  All EISAID strings must be of the form "UUUNNNN" 
 Where 
 U is an uppercase letter and N is a hex digit.
 
 
 ----------------------------------------
 06 October 2004.  Summary of changes for version 20041006:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for the ACPI 3.0 Timer operator. This ASL function 
 implements a 64-bit timer with 100 nanosecond granularity.
 
 Defined a new OSL interface, AcpiOsGetTimer. This interface is used to 
 implement the ACPI 3.0 Timer operator.  This allows the host OS to 
 implement 
 the timer with the best clock available. Also, it keeps the core subsystem 
 out of the clock handling business, since the host OS (usually) performs 
 this function.
 
 Fixed an alignment issue on 64-bit platforms. The HwLowLevelRead(Write) 
 functions use a 64-bit address which is part of the packed ACPI Generic 
 Address Structure. Since the structure is non-aligned, the alignment 
 macros 
 are now used to extract the address to a local variable before use.
 
 Fixed a problem where the ToInteger operator assumed all input strings 
 were 
 hexadecimal. The operator now handles both decimal strings and hex strings 
 (prefixed with "0x").
 
 Fixed a problem where the string length in the string object created as a 
 result of the internal ConvertToString procedure could be incorrect. This 
 potentially affected all implicit conversions and also the ToDecimalString 
 and ToHexString operators.
 
 Fixed two problems in the ToString operator. If the length parameter was 
 zero, an incorrect string object was created and the value of the input 
 length parameter was inadvertently changed from zero to Ones.
 
 Fixed a problem where the optional ResourceSource string in the 
 ExtendedIRQ 
 resource macro was ignored.
 
 Simplified the interfaces to the internal division functions, reducing 
 code 
 size and complexity.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.9K Code,  11.4K Data,   89.3K Total
     Debug Version:     164.5K Code,  68.3K Data,  232.8K Total
   Current Release:
     Non-Debug Version:  77.8K Code,  11.5K Data,   89.3K Total
     Debug Version:     164.6K Code,  68.5K Data,  233.1K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support for the ACPI 3.0 Timer operator.
 
 Fixed a problem where the Default() operator was inadvertently ignored in 
 a 
 Switch/Case block.  This was a problem in the translation of the Switch 
 statement to If...Else pairs.
 
 Added support to allow a standalone Return operator, with no parentheses 
 (or 
 operands).
 
 Fixed a problem with code generation for the ElseIf operator where the 
 translated Else...If parse tree was improperly constructed leading to the 
 loss of some code.
 
 ----------------------------------------
 22 September 2004.  Summary of changes for version 20040922:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem with the implementation of the LNot() operator where 
 "Ones" 
 was not returned for the TRUE case. Changed the code to return Ones 
 instead 
 of (!Arg) which was usually 1. This change affects iASL constant folding 
 for 
 this operator also.
 
 Fixed a problem in AcpiUtInitializeBuffer where an existing buffer was not 
 initialized properly -- Now zero the entire buffer in this case where the 
 buffer already exists.
 
 Changed the interface to AcpiOsSleep from (UINT32 Seconds, UINT32 
 Milliseconds) to simply (ACPI_INTEGER Milliseconds). This simplifies all 
 related code considerably. This will require changes/updates to all OS 
 interface layers (OSLs.)
 
 Implemented a new external interface, AcpiInstallExceptionHandler, to 
 allow 
 a system exception handler to be installed. This handler is invoked upon 
 any 
 run-time exception that occurs during control method execution.
 
 Added support for the DSDT in AcpiTbFindTable. This allows the 
 DataTableRegion() operator to access the local copy of the DSDT.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below. These are the code and data sizes for the acpica.lib produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code. The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size. 
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.8K Code,  11.4K Data,   89.2K Total
     Debug Version:     164.2K Code,  68.2K Data,  232.4K Total
   Current Release:
     Non-Debug Version:  77.9K Code,  11.4K Data,   89.3K Total
     Debug Version:     164.5K Code,  68.3K Data,  232.8K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem with constant folding and the LNot operator. LNot was 
 returning 1 in the TRUE case, not Ones as per the ACPI specification. This 
 could result in the generation of an incorrect folded/reduced constant.
 
 End-Of-File is now allowed within a "//"-style comment.  A parse error no 
 longer occurs if such a comment is at the very end of the input ASL source 
 file.
 
 Implemented the "-r" option to override the Revision in the table header. 
 The initial use of this option will be to simplify the evaluation of the 
 AML 
 interpreter by allowing a single ASL source module to be compiled for 
 either 
 32-bit or 64-bit integers.
 
 
 ----------------------------------------
 27 August 2004.  Summary of changes for version 20040827:
 
 1) ACPI CA Core Subsystem:
 
 - Implemented support for implicit object conversion in the non-numeric 
 logical operators (LEqual, LGreater, LGreaterEqual, LLess, LLessEqual, and 
 LNotEqual.)  Any combination of Integers/Strings/Buffers may now be used; 
 the second operand is implicitly converted on the fly to match the type of 
 the first operand.  For example:
 
     LEqual (Source1, Source2)
 
 Source1 and Source2 must each evaluate to an integer, a string, or a 
 buffer. 
 The data type of Source1 dictates the required type of Source2. Source2 is 
 implicitly converted if necessary to match the type of Source1.
 
 - Updated and corrected the behavior of the string conversion support.  
 The 
 rules concerning conversion of buffers to strings (according to the ACPI 
 specification) are as follows:
 
 ToDecimalString - explicit byte-wise conversion of buffer to string of 
 decimal values (0-255) separated by commas. ToHexString - explicit byte-
 wise 
 conversion of buffer to string of hex values (0-FF) separated by commas. 
 ToString - explicit byte-wise conversion of buffer to string.  Byte-by-
 byte 
 copy with no transform except NULL terminated. Any other implicit buffer-
 to-
 string conversion - byte-wise conversion of buffer to string of hex values 
 (0-FF) separated by spaces.
 
 - Fixed typo in definition of AcpiGbl_EnableInterpreterSlack.
 
 - Fixed a problem in AcpiNsGetPathnameLength where the returned length was 
 one byte too short in the case of a node in the root scope.  This could 
 cause a fault during debug output.
 
 - Code and Data Size: Current and previous core subsystem library sizes 
 are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.9K Code,  11.5K Data,   89.4K Total
     Debug Version:     164.1K Code,  68.3K Data,  232.4K Total
   Current Release:
     Non-Debug Version:  77.8K Code,  11.4K Data,   89.2K Total
     Debug Version:     164.2K Code,  68.2K Data,  232.4K Total
 
 
 2) iASL Compiler/Disassembler:
 
 - Fixed a Linux generation error.
 
 
 ----------------------------------------
 16 August 2004.  Summary of changes for version 20040816:
 
 1) ACPI CA Core Subsystem:
 
 Designed and implemented support within the AML interpreter for the so-
 called "implicit return".  This support returns the result of the last ASL 
 operation within a control method, in the absence of an explicit Return() 
 operator.  A few machines depend on this behavior, even though it is not 
 explicitly supported by the ASL language.  It is optional support that can 
 be enabled at runtime via the AcpiGbl_EnableInterpreterSlack flag.
 
 Removed support for the PCI_Config address space from the internal low 
 level 
 hardware interfaces (AcpiHwLowLevelRead and AcpiHwLowLevelWrite).  This 
 support was not used internally, and would not work correctly anyway 
 because 
 the PCI bus number and segment number were not supported.  There are 
 separate interfaces for PCI configuration space access because of the 
 unique 
 interface.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  78.0K Code,  11.5K Data,   89.5K Total
     Debug Version:     164.1K Code,  68.2K Data,  232.3K Total
   Current Release:
     Non-Debug Version:  77.9K Code,  11.5K Data,   89.4K Total
     Debug Version:     164.1K Code,  68.3K Data,  232.4K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a problem where constants in ASL expressions at the root level (not 
 within a control method) could be inadvertently truncated during code 
 generation.  This problem was introduced in the 20040715 release.
 
 
 ----------------------------------------
 15 July 2004.  Summary of changes for version 20040715:
 
 1) ACPI CA Core Subsystem:
 
 Restructured the internal HW GPE interfaces to pass/track the current 
 state 
 of interrupts (enabled/disabled) in order to avoid possible deadlock and 
 increase flexibility of the interfaces.
 
 Implemented a "lexicographical compare" for String and Buffer objects 
 within 
 the logical operators -- LGreater, LLess, LGreaterEqual, and LLessEqual -- 
 as per further clarification to the ACPI specification.  Behavior is 
 similar 
 to C library "strcmp".
 
 Completed a major reduction in CPU stack use for the AcpiGetFirmwareTable 
 external function.  In the 32-bit non-debug case, the stack use has been 
 reduced from 168 bytes to 32 bytes.
 
 Deployed a new run-time configuration flag, 
 AcpiGbl_EnableInterpreterSlack, 
 whose purpose is to allow the AML interpreter to forgive certain bad AML 
 constructs.  Default setting is FALSE.
 
 Implemented the first use of AcpiGbl_EnableInterpreterSlack in the Field 
 IO 
 support code.  If enabled, it allows field access to go beyond the end of 
 a 
 region definition if the field is within the region length rounded up to 
 the 
 next access width boundary (a common coding error.)
 
 Renamed OSD_HANDLER to ACPI_OSD_HANDLER, and OSD_EXECUTION_CALLBACK to 
 ACPI_OSD_EXEC_CALLBACK for consistency with other ACPI symbols.  Also, 
 these 
 symbols are lowercased by the latest version of the AcpiSrc tool.
 
 The prototypes for the PCI interfaces in acpiosxf.h have been updated to 
 rename "Register" to simply "Reg" to prevent certain compilers from 
 complaining.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.8K Code,  11.5K Data,   89.3K Total
     Debug Version:     163.8K Code,  68.2K Data,  232.0K Total
   Current Release:
     Non-Debug Version:  78.0K Code,  11.5K Data,   89.5K Total
     Debug Version:     164.1K Code,  68.2K Data,  232.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented full support for Package objects within the Case() operator.  
 Note: The Break() operator is currently not supported within Case blocks 
 (TermLists) as there is some question about backward compatibility with 
 ACPI 
 1.0 interpreters.
 
 
 Fixed a problem where complex terms were not supported properly within the 
 Switch() operator.
 
 Eliminated extraneous warning for compiler-emitted reserved names of the 
 form "_T_x".  (Used in Switch/Case operators.)
 
 Eliminated optimization messages for "_T_x" objects and small constants 
 within the DefinitionBlock operator.
 
 
 ----------------------------------------
 15 June 2004.  Summary of changes for version 20040615:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for Buffer and String objects (as per ACPI 2.0) for 
 the 
 following ASL operators:  LEqual, LGreater, LLess, LGreaterEqual, and 
 LLessEqual.
 
 All directory names in the entire source package are lower case, as they 
 were in earlier releases.
 
 Implemented "Disassemble" command in the AML debugger that will 
 disassemble 
 a single control method.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.7K Code,  11.5K Data,   89.2K Total
     Debug Version:     163.3K Code,  67.2K Data,  230.5K Total
 
   Current Release:
     Non-Debug Version:  77.8K Code,  11.5K Data,   89.3K Total
     Debug Version:     163.8K Code,  68.2K Data,  232.0K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Implemented support for Buffer and String objects (as per ACPI 2.0) for 
 the 
 following ASL operators:  LEqual, LGreater, LLess, LGreaterEqual, and 
 LLessEqual.
 
 All directory names in the entire source package are lower case, as they 
 were in earlier releases.
 
 Fixed a fault when using the -g or -d options if the FADT was 
 not found.
 
 Fixed an issue with the Windows version of the compiler where later 
 versions 
 of Windows place the FADT in the registry under the name "FADT" and not 
 "FACP" as earlier versions did.  This applies when using the -g or -
 d options.  The compiler now looks for both strings as 
 necessary.
 
 Fixed a problem with compiler namepath optimization where a namepath 
 within 
 the Scope() operator could not be optimized if the namepath was a subpath 
 of 
 the current scope path.
 
 ----------------------------------------
 27 May 2004.  Summary of changes for version 20040527:
 
 1) ACPI CA Core Subsystem:
 
 Completed a new design and implementation for EBDA (Extended BIOS Data 
 Area) 
 support in the RSDP scan code.  The original code improperly scanned for 
 the 
 EBDA by simply scanning from memory location 0 to 0x400.  The correct 
 method 
 is to first obtain the EBDA pointer from within the BIOS data area, then 
 scan 1K of memory starting at the EBDA pointer.  There appear to be few if 
 any machines that place the RSDP in the EBDA, however.
 
 Integrated a fix for a possible fault during evaluation of BufferField 
 arguments.  Obsolete code that was causing the problem was removed.
 
 Found and fixed a problem in the Field Support Code where data could be 
 corrupted on a bit field read that starts on an aligned boundary but does 
 not end on an aligned boundary.  Merged the read/write "datum length" 
 calculation code into a common procedure.
 
 Rolled in a couple of changes to the FreeBSD-specific header.
 
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.6K Code,  11.5K Data,   89.1K Total
     Debug Version:     163.2K Code,  67.2K Data,  230.4K Total
   Current Release:
     Non-Debug Version:  77.7K Code,  11.5K Data,   89.2K Total
     Debug Version:     163.3K Code,  67.2K Data,  230.5K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Fixed a generation warning produced by some overly-verbose compilers for a 
 64-bit constant.
 
 ----------------------------------------
 14 May 2004.  Summary of changes for version 20040514:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where hardware GPE enable bits sometimes not set properly 
 during and after GPE method execution.  Result of 04/27 changes.
 
 Removed extra "clear all GPEs" when sleeping/waking.
 
 Removed AcpiHwEnableGpe and AcpiHwDisableGpe, replaced by the single 
 AcpiHwWriteGpeEnableReg. Changed a couple of calls to the functions above 
 to 
 the new AcpiEv* calls as appropriate.
 
 ACPI_OS_NAME was removed from the OS-specific headers.  The default name 
 is 
 now "Microsoft Windows NT" for maximum compatibility.  However this can be 
 changed by modifying the acconfig.h file.
 
 Allow a single invocation of AcpiInstallNotifyHandler for a handler that 
 traps both types of notifies (System, Device).  Use ACPI_ALL_NOTIFY flag. 
 
 Run _INI methods on ThermalZone objects.  This is against the ACPI 
 specification, but there is apparently ASL code in the field that has 
 these 
 _INI methods, and apparently "other" AML interpreters execute them.
 
 Performed a full 16/32/64 bit lint that resulted in some small changes.
 
 Added a sleep simulation command to the AML debugger to test sleep code. 
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.6K Code,  11.5K Data,   89.1K Total
     Debug Version:     162.9K Code,  67.0K Data,  229.9K Total
   Current Release:
     Non-Debug Version:  77.6K Code,  11.5K Data,   89.1K Total
     Debug Version:     163.2K Code,  67.2K Data,  230.4K Total
 
 ----------------------------------------
 27 April 2004.  Summary of changes for version 20040427:
 
 1) ACPI CA Core Subsystem:
 
 Completed a major overhaul of the GPE handling within ACPI CA.  There are 
 now three types of GPEs:  wake-only, runtime-only, and combination 
 wake/run.  
 The only GPEs allowed to be combination wake/run are for button-style 
 devices such as a control-method power button, control-method sleep 
 button, 
 or a notebook lid switch.  GPEs that have an _Lxx or _Exx method and are 
 not 
 referenced by any _PRW methods are marked for "runtime" and hardware 
 enabled.  Any GPE that is referenced by a _PRW method is marked for "wake" 
 (and disabled at runtime).  However, at sleep time, only those GPEs that 
 have been specifically enabled for wake via the AcpiEnableGpe interface 
 will 
 actually be hardware enabled.
 
 A new external interface has been added, AcpiSetGpeType(), that is meant 
 to 
 be used by device drivers to force a GPE to a particular type.  It will be 
 especially useful for the drivers for the button devices mentioned above.
 
 Completed restructuring of the ACPI CA initialization sequence so that 
 default operation region handlers are installed before GPEs are 
 initialized 
 and the _PRW methods are executed.  This will prevent errors when the _PRW 
 methods attempt to access system memory or I/O space.
 
 GPE enable/disable no longer reads the GPE enable register.  We now keep 
 the 
 enable info for runtime and wake separate and in the GPE_EVENT_INFO.  We 
 thus no longer depend on the hardware to maintain these bits.
 
 Always clear the wake status and fixed/GPE status bits before sleep, even 
 for state S5.
 
 Improved the AML debugger output for displaying the GPE blocks and their 
 current status.
 
 Added new strings for the _OSI method, of the form "Windows 2001 SPx" 
 where 
 x = 0,1,2,3,4.
 
 Fixed a problem where the physical address was incorrectly calculated when 
 the Load() operator was used to directly load from an Operation Region 
 (vs. 
 loading from a Field object.)  Also added check for minimum table length 
 for 
 this case.
 
 Fix for multiple mutex acquisition.  Restore original thread SyncLevel on 
 mutex release.
 
 Added ACPI_VALID_SXDS flag to the AcpiGetObjectInfo interface for 
 consistency with the other fields returned.
 
 Shrunk the ACPI_GPE_EVENT_INFO structure by 40%.  There is one such 
 structure for each GPE in the system, so the size of this structure is 
 important.
 
 CPU stack requirement reduction:  Cleaned up the method execution and 
 object 
 evaluation paths so that now a parameter structure is passed, instead of 
 copying the various method parameters over and over again.
 
 In evregion.c:  Correctly exit and reenter the interpreter region if and 
 only if dispatching an operation region request to a user-installed 
 handler.  
 Do not exit/reenter when dispatching to a default handler (e.g., default 
 system memory or I/O handlers)
 
 
 Notes for updating drivers for the new GPE support.  The following changes 
 must be made to ACPI-related device drivers that are attached to one or 
 more 
 GPEs: (This information will be added to the ACPI CA Programmer 
 Reference.)
 
 1) AcpiInstallGpeHandler no longer automatically enables the GPE, you must 
 explicitly call AcpiEnableGpe.
 2) There is a new interface called AcpiSetGpeType. This should be called 
 before enabling the GPE.  Also, this interface will automatically disable 
 the GPE if it is currently enabled.
 3) AcpiEnableGpe no longer supports a GPE type flag.
 
 Specific drivers that must be changed:
 1) EC driver:
     AcpiInstallGpeHandler (NULL, GpeNum, ACPI_GPE_EDGE_TRIGGERED, 
 AeGpeHandler, NULL);
     AcpiSetGpeType (NULL, GpeNum, ACPI_GPE_TYPE_RUNTIME);
     AcpiEnableGpe (NULL, GpeNum, ACPI_NOT_ISR);
 
 2) Button Drivers (Power, Lid, Sleep):
 Run _PRW method under parent device
 If _PRW exists: /* This is a control-method button */
     Extract GPE number and possibly GpeDevice
     AcpiSetGpeType (GpeDevice, GpeNum, ACPI_GPE_TYPE_WAKE_RUN);
     AcpiEnableGpe (GpeDevice, GpeNum, ACPI_NOT_ISR);
 
 For all other devices that have _PRWs, we automatically set the GPE type 
 to 
 ACPI_GPE_TYPE_WAKE, but the GPE is NOT automatically (wake) enabled.  This 
 must be done on a selective basis, usually requiring some kind of user app 
 to allow the user to pick the wake devices.
 
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  77.0K Code,  11.4K Data,   88.4K Total
     Debug Version:     161.0K Code,  66.3K Data,  227.3K Total
   Current Release:
 
     Non-Debug Version:  77.6K Code,  11.5K Data,   89.1K Total
     Debug Version:     162.9K Code,  67.0K Data,  229.9K Total
 
 
 
 ----------------------------------------
 02 April 2004.  Summary of changes for version 20040402:
 
 1) ACPI CA Core Subsystem:
 
 Fixed an interpreter problem where an indirect store through an ArgX 
 parameter was incorrectly applying the "implicit conversion rules" during 
 the store.  From the ACPI specification: "If the target is a method local 
 or 
 argument (LocalX or ArgX), no conversion is performed and the result is 
 stored directly to the target".  The new behavior is to disable implicit 
 conversion during ALL stores to an ArgX.
 
 Changed the behavior of the _PRW method scan to ignore any and all errors 
 returned by a given _PRW.  This prevents the scan from aborting from the 
 failure of any single _PRW.
 
 Moved the runtime configuration parameters from the global init procedure 
 to 
 static variables in acglobal.h.  This will allow the host to override the 
 default values easily.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  76.9K Code,  11.4K Data,   88.3K Total
     Debug Version:     160.8K Code,  66.1K Data,  226.9K Total
   Current Release:
     Non-Debug Version:  77.0K Code,  11.4K Data,   88.4K Total
     Debug Version:     161.0K Code,  66.3K Data,  227.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 iASL now fully disassembles SSDTs.  However, External() statements are not 
 generated automatically for unresolved symbols at this time.  This is a 
 planned feature for future implementation.
 
 Fixed a scoping problem in the disassembler that occurs when the type of 
 the 
 target of a Scope() operator is overridden.  This problem caused an 
 incorrectly nested internal namespace to be constructed.
 
 Any warnings or errors that are emitted during disassembly are now 
 commented 
 out automatically so that the resulting file can be recompiled without any 
 hand editing.
 
 ----------------------------------------
 26 March 2004.  Summary of changes for version 20040326:
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for "wake" GPEs via interaction between GPEs and the 
 _PRW methods.  Every GPE that is pointed to by one or more _PRWs is 
 identified as a WAKE GPE and by default will no longer be enabled at 
 runtime.  Previously, we were blindly enabling all GPEs with a 
 corresponding 
 _Lxx or _Exx method - but most of these turn out to be WAKE GPEs anyway.  
 We 
 believe this has been the cause of thousands of "spurious" GPEs on some 
 systems.
 
 This new GPE behavior is can be reverted to the original behavior (enable 
 ALL GPEs at runtime) via a runtime flag.
 
 Fixed a problem where aliased control methods could not access objects 
 properly.  The proper scope within the namespace was not initialized 
 (transferred to the target of the aliased method) before executing the 
 target method.
 
 Fixed a potential race condition on internal object deletion on the return 
 object in AcpiEvaluateObject. 
 
 Integrated a fix for resource descriptors where both _MEM and _MTP were 
 being extracted instead of just _MEM.  (i.e. bitmask was incorrectly too 
 wide, 0x0F instead of 0x03.)
 
 Added a special case for ACPI_ROOT_OBJECT in AcpiUtGetNodeName, preventing 
 a 
 fault in some cases.
 
 Updated Notify() values for debug statements in evmisc.c
 
 Return proper status from AcpiUtMutexInitialize, not just simply AE_OK.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
 
     Non-Debug Version:  76.5K Code,  11.3K Data,   87.8K Total
     Debug Version:     160.3K Code,  66.0K Data,  226.3K Total
   Current Release:
     Non-Debug Version:  76.9K Code,  11.4K Data,   88.3K Total
     Debug Version:     160.8K Code,  66.1K Data,  226.9K Total
 
 ----------------------------------------
 11 March 2004.  Summary of changes for version 20040311:
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where errors occurring during the parse phase of control 
 method execution did not abort cleanly.  For example, objects created and 
 installed in the namespace were not deleted.  This caused all subsequent 
 invocations of the method to return the AE_ALREADY_EXISTS exception.
 
 Implemented a mechanism to force a control method to "Serialized" 
 execution 
 if the method attempts to create namespace objects. (The root of the 
 AE_ALREADY_EXISTS problem.)
 
 Implemented support for the predefined _OSI "internal" control method.  
 Initial supported strings are "Linux", "Windows 2000", "Windows 2001", and 
 "Windows 2001.1", and can be easily upgraded for new strings as necessary.  
 This feature will allow "other" operating systems to execute the fully 
 tested, "Windows" code path through the ASL code
 
 Global Lock Support:  Now allows multiple acquires and releases with any 
 internal thread.  Removed concept of "owning thread" for this special 
 mutex.
 
 Fixed two functions that were inappropriately declaring large objects on 
 the 
 CPU stack:  PsParseLoop, NsEvaluateRelative.  Reduces the stack usage 
 during 
 method execution considerably.
 
 Fixed a problem in the ACPI 2.0 FACS descriptor (actbl2.h) where the 
 S4Bios_f field was incorrectly defined as UINT32 instead of UINT32_BIT.
 
 Fixed a problem where AcpiEvGpeDetect would fault if there were no GPEs 
 defined on the machine.
 
 Implemented two runtime options:  One to force all control method 
 execution 
 to "Serialized" to mimic Windows behavior, another to disable _OSI support 
 if it causes problems on a given machine.
 
 Code and Data Size: Current and previous core subsystem library sizes are 
 shown below.  These are the code and data sizes for the acpica.lib 
 produced 
 by the Microsoft Visual C++ 6.0 compiler, and these values do not include 
 any ACPI driver or OSPM code.  The debug version of the code includes the 
 debug output trace mechanism and has a much larger code and data size.  
 Note 
 that these values will vary depending on the efficiency of the compiler 
 and 
 the compiler options used during generation.
 
   Previous Release:
     Non-Debug Version:  74.8K Code,  10.1K Data,   84.9K Total
     Debug Version:     158.7K Code,  65.1K Data,  223.8K Total
   Current Release:
     Non-Debug Version:  76.5K Code,  11.3K Data,   87.8K Total
     Debug Version:     160.3K Code,  66.0K Data,  226.3K Total
 
 2) iASL Compiler/Disassembler:
 
 Fixed an array size problem for FreeBSD that would cause the compiler to 
 fault.
 
 ----------------------------------------
 20 February 2004.  Summary of changes for version 20040220:
 
 
 1) ACPI CA Core Subsystem:
 
 Implemented execution of _SxD methods for Device objects in the 
 GetObjectInfo interface.
 
 Fixed calls to _SST method to pass the correct arguments.
 
 Added a call to _SST on wake to restore to "working" state.
 
 Check for End-Of-Buffer failure case in the WalkResources interface.
 
 Integrated fix for 64-bit alignment issue in acglobal.h by moving two 
 structures to the beginning of the file.
 
 After wake, clear GPE status register(s) before enabling GPEs.
 
 After wake, clear/enable power button.  (Perhaps we should clear/enable 
 all 
 fixed events upon wake.)
 
 Fixed a couple of possible memory leaks in the Namespace manager.
 
 Integrated latest acnetbsd.h file.
 
 ----------------------------------------
 11 February 2004.  Summary of changes for version 20040211:
 
 
 1) ACPI CA Core Subsystem:
 
 Completed investigation and implementation of the call-by-reference 
 mechanism for control method arguments.
 
 Fixed a problem where a store of an object into an indexed package could 
 fail if the store occurs within a different method than the method that 
 created the package.
 
 Fixed a problem where the ToDecimal operator could return incorrect 
 results.
 
 Fixed a problem where the CopyObject operator could fail on some of the 
 more 
 obscure objects (e.g., Reference objects.)
 
 Improved the output of the Debug object to display buffer, package, and 
 index objects.
 
 Fixed a problem where constructs of the form "RefOf (ArgX)" did not return 
 the expected result.
 
 Added permanent ACPI_REPORT_ERROR macros for all instances of the 
 ACPI_AML_INTERNAL exception.
 
 Integrated latest version of acfreebsd.h
 
 ----------------------------------------
 16 January 2004.  Summary of changes for version 20040116:
 
 The purpose of this release is primarily to update the copyright years in 
 each module, thus causing a huge number of diffs.  There are a few small 
 functional changes, however.
 
 1) ACPI CA Core Subsystem:
 
 Improved error messages when there is a problem finding one or more of the 
 required base ACPI tables
 
 Reintroduced the definition of APIC_HEADER in actbl.h
 
 Changed definition of MADT_ADDRESS_OVERRIDE to 64 bits (actbl.h)
 
 Removed extraneous reference to NewObj in dsmthdat.c
 
 2) iASL compiler
 
 Fixed a problem introduced in December that disabled the correct 
 disassembly 
 of Resource Templates
 
 
 ----------------------------------------
 03 December 2003.  Summary of changes for version 20031203:
 
 1) ACPI CA Core Subsystem:
 
 Changed the initialization of Operation Regions during subsystem
 init to perform two entire walks of the ACPI namespace; The first
 to initialize the regions themselves, the second to execute the
 _REG methods.  This fixed some interdependencies across _REG
 methods found on some machines.
 
 Fixed a problem where a Store(Local0, Local1) could simply update
 the object reference count, and not create a new copy of the
 object if the Local1 is uninitialized.
 
 Implemented support for the _SST reserved method during sleep
 transitions.
 
 Implemented support to clear the SLP_TYP and SLP_EN bits when
 waking up, this is apparently required by some machines.
 
 When sleeping, clear the wake status only if SleepState is not S5.
 
 Fixed a problem in AcpiRsExtendedIrqResource() where an incorrect
 pointer arithmetic advanced a string pointer too far.
 
 Fixed a problem in AcpiTbGetTablePtr() where a garbage pointer
 could be returned if the requested table has not been loaded.
 
 Within the support for IRQ resources, restructured the handling of
 the active and edge/level bits.
 
 Fixed a few problems in AcpiPsxExecute() where memory could be
 leaked under certain error conditions.
 
 Improved error messages for the cases where the ACPI mode could
 not be entered.
 
 Code and Data Size: Current and previous core subsystem library
 sizes are shown below.  These are the code and data sizes for the
 acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and
 these values do not include any ACPI driver or OSPM code.  The
 debug version of the code includes the debug output trace
 mechanism and has a much larger code and data size.  Note that
 these values will vary depending on the efficiency of the compiler
 and the compiler options used during generation.
 
   Previous Release (20031029):
     Non-Debug Version:  74.4K Code,  10.1K Data,   84.5K Total
     Debug Version:     158.3K Code,  65.0K Data,  223.3K Total
   Current Release:
     Non-Debug Version:  74.8K Code,  10.1K Data,   84.9K Total
     Debug Version:     158.7K Code,  65.1K Data,  223.8K Total
 
 2) iASL Compiler/Disassembler:
 
 Implemented a fix for the iASL disassembler where a bad index was
 generated.  This was most noticeable on 64-bit platforms
 
 
 ----------------------------------------
 29 October 2003.  Summary of changes for version 20031029:
 
 1) ACPI CA Core Subsystem:
 
 
 Fixed a problem where a level-triggered GPE with an associated
 _Lxx control method was incorrectly cleared twice.
 
 Fixed a problem with the Field support code where an access can
 occur beyond the end-of-region if the field is non-aligned but
 extends to the very end of the parent region (resulted in an
 AE_AML_REGION_LIMIT exception.)
 
 Fixed a problem with ACPI Fixed Events where an RT Clock handler
 would not get invoked on an RTC event.  The RTC event bitmasks for
 the PM1 registers were not being initialized properly.
 
 Implemented support for executing _STA and _INI methods for
 Processor objects.  Although this is currently not part of the
 ACPI specification, there is existing ASL code that depends on the
 init-time execution of these methods.
 
 Implemented and deployed a GetDescriptorName function to decode
 the various types of internal descriptors.  Guards against null
 descriptors during debug output also.
 
 Implemented and deployed a GetNodeName function to extract the 4-
 character namespace node name.  This function simplifies the debug
 and error output, as well as guarding against null pointers during
 output.
 
 Implemented and deployed the ACPI_FORMAT_UINT64 helper macro to
 simplify the debug and error output of 64-bit integers.  This
 macro replaces the HIDWORD and LODWORD macros for dumping these
 integers.
 
 Updated the implementation of the Stall() operator to only call
 AcpiOsStall(), and also return an error if the operand is larger
 than 255.  This preserves the required behavior of not
 relinquishing the processor, as would happen if AcpiOsSleep() was
 called for "long stalls".
 
 Constructs of the form "Store(LocalX,LocalX)" where LocalX is not
 initialized are now treated as NOOPs.
 
 Cleaned up a handful of warnings during 64-bit generation.
 
 Fixed a reported error where and incorrect GPE number was passed
 to the GPE dispatch handler.  This value is only used for error
 output, however.  Used this opportunity to clean up and streamline
 the GPE dispatch code.
 
 Code and Data Size: Current and previous core subsystem library
 sizes are shown below.  These are the code and data sizes for the
 acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and
 these values do not include any ACPI driver or OSPM code.  The
 
 debug version of the code includes the debug output trace
 mechanism and has a much larger code and data size.  Note that
 these values will vary depending on the efficiency of the compiler
 and the compiler options used during generation.
 
   Previous Release (20031002):
     Non-Debug Version:  74.1K Code,   9.7K Data,   83.8K Total
     Debug Version:     157.9K Code,  64.8K Data,  222.7K Total
   Current Release:
     Non-Debug Version:  74.4K Code,  10.1K Data,   84.5K Total
     Debug Version:     158.3K Code,  65.0K Data,  223.3K Total
 
 
 2) iASL Compiler/Disassembler:
 
 Updated the iASL compiler to return an error if the operand to the
 Stall() operator is larger than 255.
 
 
 ----------------------------------------
 02 October 2003.  Summary of changes for version 20031002:
 
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem with Index Fields where the index was not
 incremented for fields that require multiple writes to the
 index/data registers (Fields that are wider than the data
 register.)
 
 Fixed a problem with all Field objects where a write could go
 beyond the end-of-field if the field was larger than the access
 granularity and therefore required multiple writes to complete the
 request.  An extra write beyond the end of the field could happen
 inadvertently.
 
 Fixed a problem with Index Fields where a BUFFER_OVERFLOW error
 would incorrectly be returned if the width of the Data Register
 was larger than the specified field access width.
 
 Completed fixes for LoadTable() and Unload() and verified their
 operation.  Implemented full support for the "DdbHandle" object
 throughout the ACPI CA subsystem.
 
 Implemented full support for the MADT and ECDT tables in the ACPI
 CA header files.  Even though these tables are not directly
 consumed by ACPI CA, the header definitions are useful for ACPI
 device drivers.
 
 Integrated resource descriptor fixes posted to the Linux ACPI
 list.  This included checks for minimum descriptor length, and
 support for trailing NULL strings within descriptors that have
 optional string elements.
 
 Code and Data Size: Current and previous core subsystem library
 sizes are shown below.  These are the code and data sizes for the
 acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and
 these values do not include any ACPI driver or OSPM code.  The
 debug version of the code includes the debug output trace
 mechanism and has a much larger code and data size.  Note that
 these values will vary depending on the efficiency of the compiler
 and the compiler options used during generation.
 
   Previous Release (20030918):
     Non-Debug Version:  73.9K Code,   9.7K Data,   83.6K Total
     Debug Version:     157.3K Code,  64.5K Data,  221.8K Total
   Current Release:
     Non-Debug Version:  74.1K Code,   9.7K Data,   83.8K Total
     Debug Version:     157.9K Code,  64.8K Data,  222.7K Total
 
 
 2) iASL Compiler:
 
 Implemented detection of non-ASCII characters within the input
 source ASL file.  This catches attempts to compile binary (AML)
 files early in the compile, with an informative error message.
 
 Fixed a problem where the disassembler would fault if the output
 filename could not be generated or if the output file could not be
 opened.
 
 ----------------------------------------
 18 September 2003.  Summary of changes for version 20030918:
 
 
 1) ACPI CA Core Subsystem:
 
 Found and fixed a longstanding problem with the late execution of
 the various deferred AML opcodes (such as Operation Regions,
 Buffer Fields, Buffers, and Packages).  If the name string
 specified for the name of the new object placed the object in a
 scope other than the current scope, the initialization/execution
 of the opcode failed.  The solution to this problem was to
 implement a mechanism where the late execution of such opcodes
 does not attempt to lookup/create the name a second time in an
 incorrect scope.  This fixes the "region size computed
 incorrectly" problem.
 
 Fixed a call to AcpiHwRegisterWrite in hwregs.c that was causing a
 Global Lock AE_BAD_PARAMETER error.
 
 Fixed several 64-bit issues with prototypes, casting and data
 types.
 
 Removed duplicate prototype from acdisasm.h
 
 Fixed an issue involving EC Operation Region Detach (Shaohua Li)
 
 Code and Data Size: Current and previous core subsystem library
 sizes are shown below.  These are the code and data sizes for the
 acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and
 these values do not include any ACPI driver or OSPM code.  The
 debug version of the code includes the debug output trace
 mechanism and has a much larger code and data size.  Note that
 these values will vary depending on the efficiency of the compiler
 and the compiler options used during generation.
 
   Previous Release:
 
     Non-Debug Version:  73.7K Code,   9.7K Data,   83.4K Total
     Debug Version:     156.9K Code,  64.2K Data,  221.1K Total
   Current Release:
     Non-Debug Version:  73.9K Code,   9.7K Data,   83.6K Total
     Debug Version:     157.3K Code,  64.5K Data,  221.8K Total
 
 
 2) Linux:
 
 Fixed the AcpiOsSleep implementation in osunixxf.c to pass the
 correct sleep time in seconds.
 
 ----------------------------------------
 14 July 2003.  Summary of changes for version 20030619:
 
 1) ACPI CA Core Subsystem:
 
 Parse SSDTs in order discovered, as opposed to reverse order
 (Hrvoje Habjanic)
 
 Fixes from FreeBSD and NetBSD. (Frank van der Linden, Thomas
 Klausner,
    Nate Lawson)
 
 
 2) Linux:
 
 Dynamically allocate SDT list (suggested by Andi Kleen)
 
 proc function return value cleanups (Andi Kleen)
 
 Correctly handle NMI watchdog during long stalls (Andrew Morton)
 
 Make it so acpismp=force works (reported by Andrew Morton)
 
 
 ----------------------------------------
 19 June 2003.  Summary of changes for version 20030619:
 
 1) ACPI CA Core Subsystem:
 
 Fix To/FromBCD, eliminating the need for an arch-specific #define.
 
 Do not acquire a semaphore in the S5 shutdown path.
 
 Fix ex_digits_needed for 0. (Takayoshi Kochi)
 
 Fix sleep/stall code reversal. (Andi Kleen)
 
 Revert a change having to do with control method calling
 semantics.
 
 2) Linux:
 
 acpiphp update (Takayoshi Kochi)
 
 Export acpi_disabled for sonypi (Stelian Pop)
 
 Mention acpismp=force in config help
 
 Re-add acpitable.c and acpismp=force. This improves backwards
 
 compatibility and also cleans up the code to a significant degree.
 
 Add ASUS Value-add driver (Karol Kozimor and Julien Lerouge)
 
 ----------------------------------------
 22 May 2003.  Summary of changes for version 20030522:
 
 1) ACPI CA Core Subsystem:
 
 Found and fixed a reported problem where an AE_NOT_FOUND error
 occurred occasionally during _BST evaluation.  This turned out to
 be an Owner ID allocation issue where a called method did not get
 a new ID assigned to it.  Eventually, (after 64k calls), the Owner
 ID UINT16 would wraparound so that the ID would be the same as the
 caller's and the called method would delete the caller's
 namespace.
 
 Implemented extended error reporting for control methods that are
 aborted due to a run-time exception.  Output includes the exact
 AML instruction that caused the method abort, a dump of the method
 locals and arguments at the time of the abort, and a trace of all
 nested control method calls.
 
 Modified the interpreter to allow the creation of buffers of zero
 length from the AML code. Implemented new code to ensure that no
 attempt is made to actually allocate a memory buffer (of length
 zero) - instead, a simple buffer object with a NULL buffer pointer
 and length zero is created.  A warning is no longer issued when
 the AML attempts to create a zero-length buffer.
 
 Implemented a workaround for the "leading asterisk issue" in
 _HIDs, _UIDs, and _CIDs in the AML interpreter.  One leading
 asterisk is automatically removed if present in any HID, UID, or
 CID strings.  The iASL compiler will still flag this asterisk as
 an error, however.
 
 Implemented full support for _CID methods that return a package of
 multiple CIDs (Compatible IDs).  The AcpiGetObjectInfo() interface
 now additionally returns a device _CID list if present.  This
 required a change to the external interface in order to pass an
 ACPI_BUFFER object as a parameter since the _CID list is of
 variable length.
 
 Fixed a problem with the new AE_SAME_HANDLER exception where
 handler initialization code did not know about this exception.
 
 Code and Data Size: Current and previous core subsystem library
 sizes are shown below.  These are the code and data sizes for the
 acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and
 these values do not include any ACPI driver or OSPM code.  The
 debug version of the code includes the debug output trace
 mechanism and has a much larger code and data size.  Note that
 these values will vary depending on the efficiency of the compiler
 and the compiler options used during generation.
 
   Previous Release (20030509):
     Non-Debug Version:  73.4K Code,   9.7K Data,   83.1K Total
     Debug Version:     156.1K Code,  63.9K Data,  220.0K Total
   Current Release:
     Non-Debug Version:  73.7K Code,   9.7K Data,   83.4K Total
     Debug Version:     156.9K Code,  64.2K Data,  221.1K Total
 
 
 2) Linux:
 
 Fixed a bug in which we would reinitialize the ACPI interrupt
 after it was already working, thus disabling all ACPI and the IRQs
 for any other device sharing the interrupt. (Thanks to Stian
 Jordet)
 
 Toshiba driver update (John Belmonte)
 
 Return only 0 or 1 for our interrupt handler status (Andrew
 Morton)
 
 
 3) iASL Compiler:
 
 Fixed a reported problem where multiple (nested) ElseIf()
 statements were not handled correctly by the compiler, resulting
 in incorrect warnings and incorrect AML code.  This was a problem
 in both the ASL parser and the code generator.
 
 
 4) Documentation:
 
 Added changes to existing interfaces, new exception codes, and new
 text concerning reference count object management versus garbage
 collection.
 
 ----------------------------------------
 09 May 2003.  Summary of changes for version 20030509.
 
 
 1) ACPI CA Core Subsystem:
 
 Changed the subsystem initialization sequence to hold off
 installation of address space handlers until the hardware has been
 initialized and the system has entered ACPI mode.  This is because
 the installation of space handlers can cause _REG methods to be
 run.  Previously, the _REG methods could potentially be run before
 ACPI mode was enabled.
 
 Fixed some memory leak issues related to address space handler and
 notify handler installation.  There were some problems with the
 reference count mechanism caused by the fact that the handler
 objects are shared across several namespace objects.
 
 Fixed a reported problem where reference counts within the
 namespace were not properly updated when named objects created by
 method execution were deleted.
 
 Fixed a reported problem where multiple SSDTs caused a deletion
 issue during subsystem termination.  Restructured the table data
 structures to simplify the linked lists and the related code.
 
 Fixed a problem where the table ID associated with secondary
 tables (SSDTs) was not being propagated into the namespace objects
 created by those tables.  This would only present a problem for
 tables that are unloaded at run-time, however.
 
 Updated AcpiOsReadable and AcpiOsWritable to use the ACPI_SIZE
 type as the length parameter (instead of UINT32).
 
 Solved a long-standing problem where an ALREADY_EXISTS error
 appears on various systems.  This problem could happen when there
 are multiple PCI_Config operation regions under a single PCI root
 bus.  This doesn't happen very frequently, but there are some
 systems that do this in the ASL.
 
 Fixed a reported problem where the internal DeleteNode function
 was incorrectly handling the case where a namespace node was the
 first in the parent's child list, and had additional peers (not
 the only child, but first in the list of children.)
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  73.7K Code,   9.5K Data,   83.2K Total
     Debug Version:     156.1K Code,  63.6K Data,  219.7K Total
   Current Release:
     Non-Debug Version:  73.4K Code,   9.7K Data,   83.1K Total
     Debug Version:     156.1K Code,  63.9K Data,  220.0K Total
 
 
 2) Linux:
 
 Allow ":" in OS override string (Ducrot Bruno)
 
 Kobject fix (Greg KH)
 
 
 3 iASL Compiler/Disassembler:
 
 Fixed a problem in the generation of the C source code files (AML
 is emitted in C source statements for BIOS inclusion) where the
 Ascii dump that appears within a C comment at the end of each line
 could cause a compile time error if the AML sequence happens to
 have an open comment or close comment sequence embedded.
 
 
 ----------------------------------------
 24 April 2003.  Summary of changes for version 20030424.
 
 
 1) ACPI CA Core Subsystem:
 
 Support for big-endian systems has been implemented.  Most of the
 support has been invisibly added behind big-endian versions of the
 ACPI_MOVE_* macros.
 
 Fixed a problem in AcpiHwDisableGpeBlock() and
 AcpiHwClearGpeBlock() where an incorrect offset was passed to the
 low level hardware write routine.  The offset parameter was
 actually eliminated from the low level read/write routines because
 they had become obsolete.
 
 Fixed a problem where a handler object was deleted twice during
 the removal of a fixed event handler.
 
 
 2) Linux:
 
 A fix for SMP systems with link devices was contributed by
 
 Compaq's Dan Zink.
 
 (2.5) Return whether we handled the interrupt in our IRQ handler.
 (Linux ISRs no longer return void, so we can propagate the handler
 return value from the ACPI CA core back to the OS.)
 
 
 
 3) Documentation:
 
 The ACPI CA Programmer Reference has been updated to reflect new
 interfaces and changes to existing interfaces.
 
 ----------------------------------------
 28 March 2003.  Summary of changes for version 20030328.
 
 1) ACPI CA Core Subsystem:
 
 The GPE Block Device support has been completed.  New interfaces
 are AcpiInstallGpeBlock and AcpiRemoveGpeBlock.  The Event
 interfaces (enable, disable, clear, getstatus) have been split
 into separate interfaces for Fixed Events and General Purpose
 Events (GPEs) in order to support GPE Block Devices properly.
 
 Fixed a problem where the error message "Failed to acquire
 semaphore" would appear during operations on the embedded
 controller (EC).
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  72.3K Code,   9.5K Data,   81.8K Total
     Debug Version:     154.0K Code,  63.4K Data,  217.4K Total
   Current Release:
     Non-Debug Version:  73.7K Code,   9.5K Data,   83.2K Total
     Debug Version:     156.1K Code,  63.6K Data,  219.7K Total
 
 
 ----------------------------------------
 28 February 2003.  Summary of changes for version 20030228.
 
 
 1) ACPI CA Core Subsystem:
 
 The GPE handling and dispatch code has been completely overhauled
 in preparation for support of GPE Block Devices (ID ACPI0006).
 This affects internal data structures and code only; there should
 be no differences visible externally.  One new file has been
 added, evgpeblk.c
 
 The FADT fields GPE0_BLK_LEN and GPE1_BLK_LEN are now the only
 fields that are used to determine the GPE block lengths.  The
 REGISTER_BIT_WIDTH field of the X_GPEx_BLK extended address
 structures are ignored.  This is per the ACPI specification but it
 isn't very clear.  The full 256 Block 0/1 GPEs are now supported
 (the use of REGISTER_BIT_WIDTH limited the number of GPEs to 128).
 
 In the SCI interrupt handler, removed the read of the PM1_CONTROL
 register to look at the SCI_EN bit.  On some machines, this read
 causes an SMI event and greatly slows down SCI events.  (This may
 in fact be the cause of slow battery status response on some
 systems.)
 
 Fixed a problem where a store of a NULL string to a package object
 could cause the premature deletion of the object.  This was seen
 during execution of the battery _BIF method on some systems,
 resulting in no battery data being returned.
 
 Added AcpiWalkResources interface to simplify parsing of resource
 lists.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  72.0K Code,   9.5K Data,   81.5K Total
     Debug Version:     153.0K Code,  62.9K Data,  215.9K Total
   Current Release:
     Non-Debug Version:  72.3K Code,   9.5K Data,   81.8K Total
     Debug Version:     154.0K Code,  63.4K Data,  217.4K Total
 
 
 2) Linux
 
 S3 fixes (Ole Rohne)
 
 Update ACPI PHP driver with to use new acpi_walk_resource API
 (Bjorn Helgaas)
 
 Add S4BIOS support (Pavel Machek)
 
 Map in entire table before performing checksum (John Stultz)
 
 Expand the mem= cmdline to allow the specification of reserved and
 ACPI DATA blocks (Pavel Machek)
 
 Never use ACPI on VISWS
 
 Fix derive_pci_id (Ducrot Bruno, Alvaro Lopez)
 
 Revert a change that allowed P_BLK lengths to be 4 or 5. This is
 causing us to think that some systems support C2 when they really
 don't.
 
 Do not count processor objects for non-present CPUs (Thanks to
 Dominik Brodowski)
 
 
 3) iASL Compiler:
 
 Fixed a problem where ASL include files could not be found and
 opened.
 
 Added support for the _PDC reserved name.
 
 
 ----------------------------------------
 22 January 2003.  Summary of changes for version 20030122.
 
 
 1) ACPI CA Core Subsystem:
 
 Added a check for constructs of the form:  Store (Local0, Local0)
 where Local0 is not initialized.  Apparently, some BIOS
 programmers believe that this is a NOOP.  Since this store doesn't
 do anything anyway, the new prototype behavior will ignore this
 error.  This is a case where we can relax the strict checking in
 the interpreter in the name of compatibility.
 
 
 2) Linux
 
 The AcpiSrc Source Conversion Utility has been released with the
 Linux package for the first time.  This is the utility that is
 used to convert the ACPI CA base source code to the Linux version.
 
 (Both) Handle P_BLK lengths shorter than 6 more gracefully
 
 (Both) Move more headers to include/acpi, and delete an unused
 header.
 
 (Both) Move drivers/acpi/include directory to include/acpi
 
 (Both) Boot functions don't use cmdline, so don't pass it around
 
 (Both) Remove include of unused header (Adrian Bunk)
 
 (Both) acpiphp.h includes both linux/acpi.h and acpi_bus.h. Since
 the
 former now also includes the latter, acpiphp.h only needs the one,
 now.
 
 (2.5) Make it possible to select method of bios restoring after S3
 resume. [=> no more ugly ifdefs] (Pavel Machek)
 
 (2.5) Make proc write interfaces work (Pavel Machek)
 
 (2.5) Properly init/clean up in cpufreq/acpi (Dominik Brodowski)
 
 (2.5) Break out ACPI Perf code into its own module, under cpufreq
 (Dominik Brodowski)
 
 (2.4) S4BIOS support (Ducrot Bruno)
 
 (2.4) Fix acpiphp_glue.c for latest ACPI struct changes (Sergio
 Visinoni)
 
 
 3) iASL Compiler:
 
 Added support to disassemble SSDT and PSDTs.
 
 Implemented support to obtain SSDTs from the Windows registry if
 available.
 
 
 ----------------------------------------
 09 January 2003.  Summary of changes for version 20030109.
 
 1) ACPI CA Core Subsystem:
 
 Changed the behavior of the internal Buffer-to-String conversion
 function.  The current ACPI specification states that the contents
 of the buffer are "converted to a string of two-character
 hexadecimal numbers, each separated by a space".  Unfortunately,
 this definition is not backwards compatible with existing ACPI 1.0
 implementations (although the behavior was not defined in the ACPI
 1.0 specification).  The new behavior simply copies data from the
 buffer to the string until a null character is found or the end of
 the buffer is reached.  The new String object is always null
 terminated.  This problem was seen during the generation of _BIF
 battery data where incorrect strings were returned for battery
 type, etc.  This will also require an errata to the ACPI
 specification.
 
 Renamed all instances of NATIVE_UINT and NATIVE_INT to
 ACPI_NATIVE_UINT and ACPI_NATIVE_INT, respectively.
 
 Copyright in all module headers (both Linux and non-Linux) has be
 updated to 2003.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  72.0K Code,   9.5K Data,   81.5K Total
     Debug Version:     153.0K Code,  62.9K Data,  215.9K Total
   Current Release:
     Non-Debug Version:  72.0K Code,   9.5K Data,   81.5K Total
     Debug Version:     153.0K Code,  62.9K Data,  215.9K Total
 
 
 2) Linux
 
 Fixed an oops on module insertion/removal (Matthew Tippett)
 
 (2.4) Fix to handle dynamic size of mp_irqs (Joerg Prante)
 
 (2.5) Replace pr_debug (Randy Dunlap)
 
 (2.5) Remove usage of CPUFREQ_ALL_CPUS (Dominik Brodowski)
 
 (Both) Eliminate spawning of thread from timer callback, in favor
 of schedule_work()
 
 (Both) Show Lid status in /proc (Zdenek OGAR Skalak)
 
 (Both) Added define for Fixed Function HW region (Matthew Wilcox)
 
 (Both) Add missing statics to button.c (Pavel Machek)
 
 Several changes have been made to the source code translation
 utility that generates the Linux Code in order to make the code
 more "Linux-like":
 
 All typedefs on structs and unions have been removed in keeping
 with the Linux coding style.
 
 Removed the non-Linux SourceSafe module revision number from each
 module header.
 
 Completed major overhaul of symbols to be lowercased for linux.
 Doubled the number of symbols that are lowercased.
 
 Fixed a problem where identifiers within procedure headers and
 within quotes were not fully lower cased (they were left with a
 starting capital.)
 
 Some C macros whose only purpose is to allow the generation of 16-
 bit code are now completely removed in the Linux code, increasing
 readability and maintainability.
 
 ----------------------------------------
 
 12 December 2002.  Summary of changes for version 20021212.
 
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where the creation of a zero-length AML Buffer
 would cause a fault.
 
 Fixed a problem where a Buffer object that pointed to a static AML
 buffer (in an ACPI table) could inadvertently be deleted, causing
 memory corruption.
 
 Fixed a problem where a user buffer (passed in to the external
 ACPI CA interfaces) could be overwritten if the buffer was too
 small to complete the operation, causing memory corruption.
 
 Fixed a problem in the Buffer-to-String conversion code where a
 string of length one was always returned, regardless of the size
 of the input Buffer object.
 
 Removed the NATIVE_CHAR data type across the entire source due to
 lack of need and lack of consistent use.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  72.1K Code,   9.5K Data,   81.6K Total
     Debug Version:     152.7K Code,  62.7K Data,  215.4K Total
   Current Release:
     Non-Debug Version:  72.0K Code,   9.5K Data,   81.5K Total
     Debug Version:     153.0K Code,  62.9K Data,  215.9K Total
 
 
 ----------------------------------------
 05 December 2002.  Summary of changes for version 20021205.
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where a store to a String or Buffer object could
 cause corruption of the DSDT if the object type being stored was
 the same as the target object type and the length of the object
 being stored was equal to or smaller than the original (existing)
 target object.  This was seen to cause corruption of battery _BIF
 buffers if the _BIF method modified the buffer on the fly.
 
 Fixed a problem where an internal error was generated if a control
 method invocation was used in an OperationRegion, Buffer, or
 Package declaration.  This was caused by the deferred parsing of
 the control method and thus the deferred creation of the internal
 method object.  The solution to this problem was to create the
 internal method object at the moment the method is encountered in
 the first pass - so that subsequent references to the method will
 able to obtain the required parameter count and thus properly
 parse the method invocation.  This problem presented itself as an
 AE_AML_INTERNAL during the pass 1 parse phase during table load.
 
 Fixed a problem where the internal String object copy routine did
 not always allocate sufficient memory for the target String object
 and caused memory corruption.  This problem was seen to cause
 "Allocation already present in list!" errors as memory allocation
 became corrupted.
 
 Implemented a new function for the evaluation of namespace objects
 that allows the specification of the allowable return object
 types.  This simplifies a lot of code that checks for a return
 object of one or more specific objects returned from the
 evaluation (such as _STA, etc.)  This may become and external
 function if it would be useful to ACPI-related drivers.
 
 Completed another round of prefixing #defines with "ACPI_" for
 clarity.
 
 Completed additional code restructuring to allow more modular
 linking for iASL compiler and AcpiExec.  Several files were split
 creating new files.  New files:  nsparse.c dsinit.c evgpe.c
 
 Implemented an abort mechanism to terminate an executing control
 method via the AML debugger.  This feature is useful for debugging
 control methods that depend (wait) for specific hardware
 responses.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  71.4K Code,   9.0K Data,   80.4K Total
     Debug Version:     152.9K Code,  63.3K Data,  216.2K Total
   Current Release:
     Non-Debug Version:  72.1K Code,   9.5K Data,   81.6K Total
     Debug Version:     152.7K Code,  62.7K Data,  215.4K Total
 
 
 2) iASL Compiler/Disassembler
 
 Fixed a compiler code generation problem for "Interrupt" Resource
 Descriptors.  If specified in the ASL, the optional "Resource
 Source Index" and "Resource Source" fields were not inserted into
 the correct location within the AML resource descriptor, creating
 an invalid descriptor.
 
 Fixed a disassembler problem for "Interrupt" resource descriptors.
 The optional "Resource Source Index" and "Resource Source" fields
 were ignored.
 
 
 ----------------------------------------
 22 November 2002.  Summary of changes for version 20021122.
 
 
 1) ACPI CA Core Subsystem:
 
 Fixed a reported problem where an object stored to a Method Local
 or Arg was not copied to a new object during the store - the
 object pointer was simply copied to the Local/Arg.  This caused
 all subsequent operations on the Local/Arg to also affect the
 original source of the store operation.
 
 Fixed a problem where a store operation to a Method Local or Arg
 was not completed properly if the Local/Arg contained a reference
 (from RefOf) to a named field.  The general-purpose store-to-
 namespace-node code is now used so that this case is handled
 automatically.
 
 Fixed a problem where the internal object copy routine would cause
 a protection fault if the object being copied was a Package and
 contained either 1) a NULL package element or 2) a nested sub-
 package.
 
 Fixed a problem with the GPE initialization that resulted from an
 ambiguity in the ACPI specification.  One section of the
 specification states that both the address and length of the GPE
 block must be zero if the block is not supported.  Another section
 implies that only the address need be zero if the block is not
 supported.  The code has been changed so that both the address and
 the length must be non-zero to indicate a valid GPE block (i.e.,
 if either the address or the length is zero, the GPE block is
 invalid.)
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  71.3K Code,   9.0K Data,   80.3K Total
     Debug Version:     152.7K Code,  63.2K Data,  215.5K Total
   Current Release:
     Non-Debug Version:  71.4K Code,   9.0K Data,   80.4K Total
     Debug Version:     152.9K Code,  63.3K Data,  216.2K Total
 
 
 2) Linux
 
 Cleaned up EC driver. Exported an external EC read/write
 interface. By going through this, other drivers (most notably
 sonypi) will be able to serialize access to the EC.
 
 
 3) iASL Compiler/Disassembler
 
 Implemented support to optionally generate include files for both
 ASM and C (the -i switch).  This simplifies BIOS development by
 automatically creating include files that contain external
 declarations for the symbols that are created within the
 
 (optionally generated) ASM and C AML source files.
 
 
 ----------------------------------------
 15 November 2002.  Summary of changes for version 20021115.
 
 1) ACPI CA Core Subsystem:
 
 Fixed a memory leak problem where an error during resolution of
 
 method arguments during a method invocation from another method
 failed to cleanup properly by deleting all successfully resolved
 argument objects.
 
 Fixed a problem where the target of the Index() operator was not
 correctly constructed if the source object was a package.  This
 problem has not been detected because the use of a target operand
 with Index() is very rare.
 
 Fixed a problem with the Index() operator where an attempt was
 made to delete the operand objects twice.
 
 Fixed a problem where an attempt was made to delete an operand
 twice during execution of the CondRefOf() operator if the target
 did not exist.
 
 Implemented the first of perhaps several internal create object
 functions that create and initialize a specific object type.  This
 consolidates duplicated code wherever the object is created, thus
 shrinking the size of the subsystem.
 
 Implemented improved debug/error messages for errors that occur
 during nested method invocations.  All executing method pathnames
 are displayed (with the error) as the call stack is unwound - thus
 simplifying debug.
 
 Fixed a problem introduced in the 10/02 release that caused
 premature deletion of a buffer object if a buffer was used as an
 ASL operand where an integer operand is required (Thus causing an
 implicit object conversion from Buffer to Integer.)  The change in
 the 10/02 release was attempting to fix a memory leak (albeit
 incorrectly.)
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  71.9K Code,   9.1K Data,   81.0K Total
     Debug Version:     153.1K Code,  63.3K Data,  216.4K Total
   Current Release:
     Non-Debug Version:  71.3K Code,   9.0K Data,   80.3K Total
     Debug Version:     152.7K Code,  63.2K Data,  215.5K Total
 
 
 2) Linux
 
 Changed the implementation of the ACPI semaphores to use down()
 instead of down_interruptable().  It is important that the
 execution of ACPI control methods not be interrupted by signals.
 Methods must run to completion, or the system may be left in an
 unknown/unstable state.
 
 Fixed a compilation error when CONFIG_SOFTWARE_SUSPEND is not set.
 (Shawn Starr)
 
 
 3) iASL Compiler/Disassembler
 
 
 Changed the default location of output files.  All output files
 are now placed in the current directory by default instead of in
 the directory of the source file.  This change may affect some
 existing makefiles, but it brings the behavior of the compiler in
 line with other similar tools.  The location of the output files
 can be overridden with the -p command line switch.
 
 
 ----------------------------------------
 11 November 2002.  Summary of changes for version 20021111.
 
 
 0) ACPI Specification 2.0B is released and is now available at:
 http://www.acpi.info/index.html
 
 
 1) ACPI CA Core Subsystem:
 
 Implemented support for the ACPI 2.0 SMBus Operation Regions.
 This includes the early detection and handoff of the request to
 the SMBus region handler (avoiding all of the complex field
 support code), and support for the bidirectional return packet
 from an SMBus write operation.  This paves the way for the
 development of SMBus drivers in each host operating system.
 
 Fixed a problem where the semaphore WAIT_FOREVER constant was
 defined as 32 bits, but must be 16 bits according to the ACPI
 specification.  This had the side effect of causing ASL
 Mutex/Event timeouts even though the ASL code requested a wait
 forever.  Changed all internal references to the ACPI timeout
 parameter to 16 bits to prevent future problems.  Changed the name
 of WAIT_FOREVER to ACPI_WAIT_FOREVER.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  71.4K Code,   9.0K Data,   80.4K Total
     Debug Version:     152.3K Code,  63.0K Data,  215.3K Total
   Current Release:
     Non-Debug Version:  71.9K Code,   9.1K Data,   81.0K Total
     Debug Version:     153.1K Code,  63.3K Data,  216.4K Total
 
 
 2) Linux
 
 Module loading/unloading fixes (John Cagle)
 
 
 3) iASL Compiler/Disassembler
 
 Added support for the SMBBlockProcessCall keyword (ACPI 2.0)
 
 Implemented support for the disassembly of all SMBus protocol
 keywords (SMBQuick, SMBWord, etc.)
 
 ----------------------------------------
 01 November 2002.  Summary of changes for version 20021101.
 
 
 1) ACPI CA Core Subsystem:
 
 Fixed a problem where platforms that have a GPE1 block but no GPE0
 block were not handled correctly.  This resulted in a "GPE
 overlap" error message.  GPE0 is no longer required.
 
 Removed code added in the previous release that inserted nodes
 into the namespace in alphabetical order.  This caused some side-
 effects on various machines.  The root cause of the problem is
 still under investigation since in theory, the internal ordering
 of the namespace nodes should not matter.
 
 
 Enhanced error reporting for the case where a named object is not
 found during control method execution.  The full ACPI namepath
 (name reference) of the object that was not found is displayed in
 this case.
 
 Note: as a result of the overhaul of the namespace object types in
 the previous release, the namespace nodes for the predefined
 scopes (_TZ, _PR, etc.) are now of the type ACPI_TYPE_LOCAL_SCOPE
 instead of ACPI_TYPE_ANY.  This simplifies the namespace
 management code but may affect code that walks the namespace tree
 looking for specific object types.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a much larger code and data size.  Note that these values will
 vary depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  70.7K Code,   8.6K Data,   79.3K Total
     Debug Version:     151.7K Code,  62.4K Data,  214.1K Total
   Current Release:
     Non-Debug Version:  71.4K Code,   9.0K Data,   80.4K Total
     Debug Version:     152.3K Code,  63.0K Data,  215.3K Total
 
 
 2) Linux
 
 Fixed a problem introduced in the previous release where the
 Processor and Thermal objects were not recognized and installed in
 /proc.  This was related to the scope type change described above.
 
 
 3) iASL Compiler/Disassembler
 
 Implemented the -g option to get all of the required ACPI tables
 from the registry and save them to files (Windows version of the
 compiler only.)  The required tables are the FADT, FACS, and DSDT.
 
 Added ACPI table checksum validation during table disassembly in
 order to catch corrupted tables.
 
 
 ----------------------------------------
 22 October 2002.  Summary of changes for version 20021022.
 
 1) ACPI CA Core Subsystem:
 
 Implemented a restriction on the Scope operator that the target
 must already exist in the namespace at the time the operator is
 encountered (during table load or method execution).  In other
 words, forward references are not allowed and Scope() cannot
 create a new object. This changes the previous behavior where the
 interpreter would create the name if not found.  This new behavior
 correctly enables the search-to-root algorithm during namespace
 lookup of the target name.  Because of this upsearch, this fixes
 the known Compaq _SB_.OKEC problem and makes both the AML
 interpreter and iASL compiler compatible with other ACPI
 implementations.
 
 Completed a major overhaul of the internal ACPI object types for
 the ACPI Namespace and the associated operand objects.  Many of
 these types had become obsolete with the introduction of the two-
 pass namespace load.  This cleanup simplifies the code and makes
 the entire namespace load mechanism much clearer and easier to
 understand.
 
 Improved debug output for tracking scope opening/closing to help
 diagnose scoping issues.  The old scope name as well as the new
 scope name are displayed.  Also improved error messages for
 problems with ASL Mutex objects and error messages for GPE
 problems.
 
 Cleaned up the namespace dump code, removed obsolete code.
 
 All string output (for all namespace/object dumps) now uses the
 common ACPI string output procedure which handles escapes properly
 and does not emit non-printable characters.
 
 Fixed some issues with constants in the 64-bit version of the
 local C library (utclib.c)
 
 
 2) Linux
 
 EC Driver:  No longer attempts to acquire the Global Lock at
 interrupt level.
 
 
 3) iASL Compiler/Disassembler
 
 Implemented ACPI 2.0B grammar change that disallows all Type 1 and
 2 opcodes outside of a control method.  This means that the
 "executable" operators (versus the "namespace" operators) cannot
 be used at the table level; they can only be used within a control
 method.
 
 Implemented the restriction on the Scope() operator where the
 target must already exist in the namespace at the time the
 operator is encountered (during ASL compilation). In other words,
 forward references are not allowed and Scope() cannot create a new
 object.  This makes the iASL compiler compatible with other ACPI
 implementations and makes the Scope() implementation adhere to the
 ACPI specification.
 
 Fixed a problem where namepath optimization for the Alias operator
 was optimizing the wrong path (of the two namepaths.)  This caused
 a "Missing alias link" error message.
 
 Fixed a problem where an "unknown reserved name" warning could be
 incorrectly generated for names like "_SB" when the trailing
 underscore is not used in the original ASL.
 
 Fixed a problem where the reserved name check did not handle
 NamePaths with multiple NameSegs correctly.  The first nameseg of
 the NamePath was examined instead of the last NameSeg.
 
 
 ----------------------------------------
 
 02 October 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem version 20021002:
 
 Fixed a problem where a store/copy of a string to an existing
 string did not always set the string length properly in the String
 object.
 
 Fixed a reported problem with the ToString operator where the
 behavior was identical to the ToHexString operator instead of just
 simply converting a raw buffer to a string data type.
 
 Fixed a problem where CopyObject and the other "explicit"
 conversion operators were not updating the internal namespace node
 type as part of the store operation.
 
 Fixed a memory leak during implicit source operand conversion
 where the original object was not deleted if it was converted to a
 new object of a different type.
 
 Enhanced error messages for all problems associated with namespace
 lookups.  Common procedure generates and prints the lookup name as
 well as the formatted status.
 
 Completed implementation of a new design for the Alias support
 within the namespace.  The existing design did not handle the case
 where a new object was assigned to one of the two names due to the
 use of an explicit conversion operator, resulting in the two names
 pointing to two different objects.  The new design simply points
 the Alias name to the original name node - not to the object.
 This results in a level of indirection that must be handled in the
 name resolution mechanism.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  69.6K Code,   8.3K Data,   77.9K Total
     Debug Version:     150.0K Code,  61.7K Data,  211.7K Total
   Current Release:
     Non-Debug Version:  70.7K Code,   8.6K Data,   79.3K Total
     Debug Version:     151.7K Code,  62.4K Data,  214.1K Total
 
 
 2) Linux
 
 Initialize thermal driver's timer before it is used. (Knut
 Neumann)
 
 Allow handling negative celsius values. (Kochi Takayoshi)
 
 Fix thermal management and make trip points. R/W (Pavel Machek)
 
 Fix /proc/acpi/sleep. (P. Christeas)
 
 IA64 fixes. (David Mosberger)
 
 Fix reversed logic in blacklist code. (Sergio Monteiro Basto)
 
 Replace ACPI_DEBUG define with ACPI_DEBUG_OUTPUT. (Dominik
 Brodowski)
 
 
 3) iASL Compiler/Disassembler
 
 Clarified some warning/error messages.
 
 
 ----------------------------------------
 18 September 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem version 20020918:
 
 Fixed a reported problem with reference chaining (via the Index()
 and RefOf() operators) in the ObjectType() and SizeOf() operators.
 The definition of these operators includes the dereferencing of
 all chained references to return information on the base object.
 
 Fixed a problem with stores to indexed package elements - the
 existing code would not complete the store if an "implicit
 conversion" was not performed.  In other words, if the existing
 object (package element) was to be replaced completely, the code
 didn't handle this case.
 
 Relaxed typechecking on the ASL "Scope" operator to allow the
 target name to refer to an object of type Integer, String, or
 Buffer, in addition to the scoping object types (Device,
 predefined Scopes, Processor, PowerResource, and ThermalZone.)
 This allows existing AML code that has workarounds for a bug in
 Windows to function properly.  A warning is issued, however.  This
 affects both the AML interpreter and the iASL compiler. Below is
 an example of this type of ASL code:
 
       Name(DEB,0x00)
       Scope(DEB)
       {
 
 Fixed some reported problems with 64-bit integer support in the
 local implementation of C library functions (clib.c)
 
 
 2) Linux
 
 Use ACPI fix map region instead of IOAPIC region, since it is
 undefined in non-SMP.
 
 Ensure that the SCI has the proper polarity and trigger, even on
 systems that do not have an interrupt override entry in the MADT.
 
 2.5 big driver reorganization (Pat Mochel)
 
 Use early table mapping code from acpitable.c (Andi Kleen)
 
 New blacklist entries (Andi Kleen)
 
 Blacklist improvements. Split blacklist code out into a separate
 file. Move checking the blacklist to very early. Previously, we
 would use ACPI tables, and then halfway through init, check the
 blacklist -- too late. Now, it's early enough to completely fall-
 back to non-ACPI.
 
 
 3) iASL Compiler/Disassembler version 20020918:
 
 Fixed a problem where the typechecking code didn't know that an
 alias could point to a method.  In other words, aliases were not
 being dereferenced during typechecking.
 
 
 ----------------------------------------
 29 August 2002.  Summary of changes for this release.
 
 1) ACPI CA Core Subsystem Version 20020829:
 
 If the target of a Scope() operator already exists, it must be an
 object type that actually opens a scope -- such as a Device,
 Method, Scope, etc.  This is a fatal runtime error.  Similar error
 check has been added to the iASL compiler also.
 
 Tightened up the namespace load to disallow multiple names in the
 same scope.  This previously was allowed if both objects were of
 the same type.  (i.e., a lookup was the same as entering a new
 name).
 
 
 2) Linux
 
 Ensure that the ACPI interrupt has the proper trigger and
 polarity.
 
 local_irq_disable is extraneous. (Matthew Wilcox)
 
 Make "acpi=off" actually do what it says, and not use the ACPI
 interpreter *or* the tables.
 
 Added arch-neutral support for parsing SLIT and SRAT tables (Kochi
 Takayoshi)
 
 
 3) iASL Compiler/Disassembler  Version 20020829:
 
 Implemented namepath optimization for name declarations.  For
 example, a declaration like "Method (\_SB_.ABCD)" would get
 optimized to "Method (ABCD)" if the declaration is within the
 \_SB_ scope.  This optimization is in addition to the named
 reference path optimization first released in the previous
 version. This would seem to complete all possible optimizations
 for namepaths within the ASL/AML.
 
 If the target of a Scope() operator already exists, it must be an
 object type that actually opens a scope -- such as a Device,
 Method, Scope, etc.
 
 Implemented a check and warning for unreachable code in the same
 block below a Return() statement.
 
 Fixed a problem where the listing file was not generated if the
 compiler aborted if the maximum error count was exceeded (200).
 
 Fixed a problem where the typechecking of method return values was
 broken.  This includes the check for a return value when the
 method is invoked as a TermArg (a return value is expected.)
 
 Fixed a reported problem where EOF conditions during a quoted
 string or comment caused a fault.
 
 
 ----------------------------------------
 15 August 2002.  Summary of changes for this release.
 
 1) ACPI CA Core Subsystem Version 20020815:
 
 Fixed a reported problem where a Store to a method argument that
 contains a reference did not perform the indirect store correctly.
 This problem was created during the conversion to the new
 reference object model - the indirect store to a method argument
 code was not updated to reflect the new model.
 
 Reworked the ACPI mode change code to better conform to ACPI 2.0,
 handle corner cases, and improve code legibility (Kochi Takayoshi)
 
 Fixed a problem with the pathname parsing for the carat (^)
 prefix.  The heavy use of the carat operator by the new namepath
 optimization in the iASL compiler uncovered a problem with the AML
 interpreter handling of this prefix.  In the case where one or
 more carats precede a single nameseg, the nameseg was treated as
 standalone and the search rule (to root) was inadvertently
 applied.  This could cause both the iASL compiler and the
 interpreter to find the wrong object or to miss the error that
 should occur if the object does not exist at that exact pathname.
 
 Found and fixed the problem where the HP Pavilion DSDT would not
 load.  This was a relatively minor tweak to the table loading code
 (a problem caused by the unexpected encounter with a method
 invocation not within a control method), but it does not solve the
 overall issue of the execution of AML code at the table level.
 This investigation is still ongoing.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  69.1K Code,   8.2K Data,   77.3K Total
     Debug Version:     149.4K Code,  61.6K Data,  211.0K Total
   Current Release:
     Non-Debug Version:  69.6K Code,   8.3K Data,   77.9K Total
     Debug Version:     150.0K Code,  61.7K Data,  211.7K Total
 
 
 2) Linux
 
 Remove redundant slab.h include (Brad Hards)
 
 Fix several bugs in thermal.c (Herbert Nachtnebel)
 
 Make CONFIG_ACPI_BOOT work properly (Pavel Machek)
 
 Change acpi_system_suspend to use updated irq functions (Pavel
 Machek)
 
 Export acpi_get_firmware_table (Matthew Wilcox)
 
 Use proper root proc entry for ACPI (Kochi Takayoshi)
 
 Fix early-boot table parsing (Bjorn Helgaas)
 
 
 3) iASL Compiler/Disassembler
 
 Reworked the compiler options to make them more consistent and to
 use two-letter options where appropriate.  We were running out of
 sensible letters.   This may break some makefiles, so check the
 current options list by invoking the compiler with no parameters.
 
 Completed the design and implementation of the ASL namepath
 optimization option for the compiler.  This option optimizes all
 references to named objects to the shortest possible path.  The
 first attempt tries to utilize a single nameseg (4 characters) and
 the "search-to-root" algorithm used by the interpreter.  If that
 cannot be used (because either the name is not in the search path
 or there is a conflict with another object with the same name),
 the pathname is optimized using the carat prefix (usually a
 shorter string than specifying the entire path from the root.)
 
 Implemented support to obtain the DSDT from the Windows registry
 (when the disassembly option is specified with no input file).
 Added this code as the implementation for AcpiOsTableOverride in
 the Windows OSL.  Migrated the 16-bit code (used in the AcpiDump
 utility) to scan memory for the DSDT to the AcpiOsTableOverride
 function in the DOS OSL to make the disassembler truly OS
 independent.
 
 Implemented a new option to disassemble and compile in one step.
 When used without an input filename, this option will grab the
 DSDT from the local machine, disassemble it, and compile it in one
 step.
 
 Added a warning message for invalid escapes (a backslash followed
 by any character other than the allowable escapes).  This catches
 the quoted string error "\_SB_" (which should be "\\_SB_" ).
 
 Also, there are numerous instances in the ACPI specification where
 this error occurs.
 
 Added a compiler option to disable all optimizations.  This is
 basically the "compatibility mode" because by using this option,
 the AML code will come out exactly the same as other ASL
 compilers.
 
 Added error messages for incorrectly ordered dependent resource
 functions.  This includes: missing EndDependentFn macro at end of
 dependent resource list, nested dependent function macros (both
 start and end), and missing StartDependentFn macro.  These are
 common errors that should be caught at compile time.
 
 Implemented _OSI support for the disassembler and compiler.  _OSI
 must be included in the namespace for proper disassembly (because
 the disassembler must know the number of arguments.)
 
 Added an "optimization" message type that is optional (off by
 default).  This message is used for all optimizations - including
 constant folding, integer optimization, and namepath optimization.
 
 ----------------------------------------
 25 July 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem Version 20020725:
 
 The AML Disassembler has been enhanced to produce compilable ASL
 code and has been integrated into the iASL compiler (see below) as
 well as the single-step disassembly for the AML debugger and the
 disassembler for the AcpiDump utility.  All ACPI 2.0A opcodes,
 resource templates and macros are fully supported.  The
 disassembler has been tested on over 30 different AML files,
 producing identical AML when the resulting disassembled ASL file
 is recompiled with the same ASL compiler.
 
 Modified the Resource Manager to allow zero interrupts and zero
 dma channels during the GetCurrentResources call.  This was
 causing problems on some platforms.
 
 Added the AcpiOsRedirectOutput interface to the OSL to simplify
 output redirection for the AcpiOsPrintf and AcpiOsVprintf
 interfaces.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  68.7K Code,   7.4K Data,   76.1K Total
     Debug Version:     142.9K Code,  58.7K Data,  201.6K Total
   Current Release:
     Non-Debug Version:  69.1K Code,   8.2K Data,   77.3K Total
     Debug Version:     149.4K Code,  61.6K Data,  211.0K Total
 
 
 2) Linux
 
 Fixed a panic in the EC driver (Dominik Brodowski)
 
 Implemented checksum of the R/XSDT itself during Linux table scan
 (Richard Schaal)
 
 
 3) iASL compiler
 
 The AML disassembler is integrated into the compiler.  The "-d"
 option invokes the disassembler  to completely disassemble an
 input AML file, producing as output a text ASL file with the
 extension ".dsl" (to avoid name collisions with existing .asl
 source files.)  A future enhancement will allow the disassembler
 to obtain the BIOS DSDT from the registry under Windows.
 
 Fixed a problem with the VendorShort and VendorLong resource
 descriptors where an invalid AML sequence was created.
 
 Implemented a fix for BufferData term in the ASL parser.  It was
 inadvertently defined twice, allowing invalid syntax to pass and
 causing reduction conflicts.
 
 Fixed a problem where the Ones opcode could get converted to a
 value of zero if "Ones" was used where a byte, word or dword value
 was expected.  The 64-bit value is now truncated to the correct
 size with the correct value.
 
 
 
 ----------------------------------------
 02 July 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem Version 20020702:
 
 The Table Manager code has been restructured to add several new
 features.  Tables that are not required by the core subsystem
 (other than the FADT, DSDT, FACS, PSDTs, etc.) are no longer
 validated in any way and are returned from AcpiGetFirmwareTable if
 requested.  The AcpiOsTableOverride interface is now called for
 each table that is loaded by the subsystem in order to allow the
 host to override any table it chooses.  Previously, only the DSDT
 could be overridden.  Added one new files, tbrsdt.c and
 tbgetall.c.
 
 Fixed a problem with the conversion of internal package objects to
 external objects (when a package is returned from a control
 method.)  The return buffer length was set to zero instead of the
 proper length of the package object.
 
 Fixed a reported problem with the use of the RefOf and DeRefOf
 operators when passing reference arguments to control methods.  A
 new type of Reference object is used internally for references
 produced by the RefOf operator.
 
 Added additional error messages in the Resource Manager to explain
 AE_BAD_DATA errors when they occur during resource parsing.
 
 Split the AcpiEnableSubsystem into two primitives to enable a
 finer granularity initialization sequence.  These two calls should
 be called in this order: AcpiEnableSubsystem (flags),
 AcpiInitializeObjects (flags).  The flags parameter remains the
 same.
 
 
 2) Linux
 
 Updated the ACPI utilities module to understand the new style of
 fully resolved package objects that are now returned from the core
 subsystem.  This eliminates errors of the form:
 
     ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.PPB_._PRT]
     acpi_utils-0430 [145] acpi_evaluate_reference:
         Invalid element in package (not a device reference)
 
 The method evaluation utility uses the new buffer allocation
 scheme instead of calling AcpiEvaluate Object twice.
 
 Added support for ECDT. This allows the use of the Embedded
 
 Controller before the namespace has been fully initialized, which
 is necessary for ACPI 2.0 support, and for some laptops to
 initialize properly. (Laptops using ECDT are still rare, so only
 limited testing was performed of the added functionality.)
 
 Fixed memory leaks in the EC driver.
 
 Eliminated a brittle code structure in acpi_bus_init().
 
 Eliminated the acpi_evaluate() helper function in utils.c. It is
 no longer needed since acpi_evaluate_object can optionally
 allocate memory for the return object.
 
 Implemented fix for keyboard hang when getting battery readings on
 some systems (Stephen White)
 
 PCI IRQ routing update (Dominik Brodowski)
 
 Fix an ifdef to allow compilation on UP with LAPIC but no IOAPIC
 support
 
 ----------------------------------------
 11 June 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem Version 20020611:
 
 Fixed a reported problem where constants such as Zero and One
 appearing within _PRT packages were not handled correctly within
 the resource manager code.  Originally reported against the ASL
 compiler because the code generator now optimizes integers to
 their minimal AML representation (i.e. AML constants if possible.)
 The _PRT code now handles all AML constant opcodes correctly
 (Zero, One, Ones, Revision).
 
 Fixed a problem with the Concatenate operator in the AML
 interpreter where a buffer result object was incorrectly marked as
 not fully evaluated, causing a run-time error of AE_AML_INTERNAL.
 
 All package sub-objects are now fully resolved before they are
 returned from the external ACPI interfaces.  This means that name
 strings are resolved to object handles, and constant operators
 (Zero, One, Ones, Revision) are resolved to Integers.
 
 Implemented immediate resolution of the AML Constant opcodes
 (Zero, One, Ones, Revision) to Integer objects upon detection
 within the AML stream. This has simplified and reduced the
 generated code size of the subsystem by eliminating about 10
 switch statements for these constants (which previously were
 contained in Reference objects.)  The complicating issues are that
 the Zero opcode is used as a "placeholder" for unspecified
 optional target operands and stores to constants are defined to be
 no-ops.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below. These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  69.3K Code,   7.4K Data,   76.7K Total
     Debug Version:     143.8K Code,  58.8K Data,  202.6K Total
   Current Release:
     Non-Debug Version:  68.7K Code,   7.4K Data,   76.1K Total
     Debug Version:     142.9K Code,  58.7K Data,  201.6K Total
 
 
 2) Linux
 
 
 Added preliminary support for obtaining _TRA data for PCI root
 bridges (Bjorn Helgaas).
 
 
 3) iASL Compiler Version X2046:
 
 Fixed a problem where the "_DDN" reserved name was defined to be a
 control method with one argument.  There are no arguments, and
 _DDN does not have to be a control method.
 
 Fixed a problem with the Linux version of the compiler where the
 source lines printed with error messages were the wrong lines.
 This turned out to be the "LF versus CR/LF" difference between
 Windows and Unix.  This appears to be the longstanding issue
 concerning listing output and error messages.
 
 Fixed a problem with the Linux version of compiler where opcode
 names within error messages were wrong.  This was caused by a
 slight difference in the output of the Flex tool on Linux versus
 Windows.
 
 Fixed a problem with the Linux compiler where the hex output files
 contained some garbage data caused by an internal buffer overrun.
 
 
 ----------------------------------------
 17 May 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem Version 20020517:
 
 Implemented a workaround to an BIOS bug discovered on the HP
 OmniBook where the FADT revision number and the table size are
 inconsistent (ACPI 2.0 revision vs. ACPI 1.0 table size).  The new
 behavior is to fallback to using only the ACPI 1.0 fields of the
 FADT if the table is too small to be a ACPI 2.0 table as claimed
 by the revision number.  Although this is a BIOS bug, this is a
 case where the workaround is simple enough and with no side
 effects, so it seemed prudent to add it.  A warning message is
 issued, however.
 
 Implemented minimum size checks for the fixed-length ACPI tables -
 - the FADT and FACS, as well as consistency checks between the
 revision number and the table size.
 
 Fixed a reported problem in the table override support where the
 new table pointer was incorrectly treated as a physical address
 instead of a logical address.
 
 Eliminated the use of the AE_AML_ERROR exception and replaced it
 with more descriptive codes.
 
 Fixed a problem where an exception would occur if an ASL Field was
 defined with no named Field Units underneath it (used by some
 index fields).
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  68.8K Code,   7.1K Data,   75.9K Total
     Debug Version:     142.9K Code,  58.4K Data,  201.3K Total
   Current Release:
     Non-Debug Version:  69.3K Code,   7.4K Data,   76.7K Total
     Debug Version:     143.8K Code,  58.8K Data,  202.6K Total
 
 
 
 2) Linux
 
 Much work done on ACPI init (MADT and PCI IRQ routing support).
 (Paul D. and Dominik Brodowski)
 
 Fix PCI IRQ-related panic on boot (Sam Revitch)
 
 Set BM_ARB_DIS when entering a sleep state (Ducrot Bruno)
 
 Fix "MHz" typo (Dominik Brodowski)
 
 Fix RTC year 2000 issue (Dominik Brodowski)
 
 Preclude multiple button proc entries (Eric Brunet)
 
 Moved arch-specific code out of include/platform/aclinux.h
 
 3) iASL Compiler Version X2044:
 
 Implemented error checking for the string used in the EISAID macro
 (Usually used in the definition of the _HID object.)  The code now
 strictly enforces the PnP format - exactly 7 characters, 3
 uppercase letters and 4 hex digits.
 
 If a raw string is used in the definition of the _HID object
 (instead of the EISAID macro), the string must contain all
 alphanumeric characters (e.g., "*PNP0011" is not allowed because
 of the asterisk.)
 
 Implemented checking for invalid use of ACPI reserved names for
 most of the name creation operators (Name, Device, Event, Mutex,
 OperationRegion, PowerResource, Processor, and ThermalZone.)
 Previously, this check was only performed for control methods.
 
 Implemented an additional check on the Name operator to emit an
 error if a reserved name that must be implemented in ASL as a
 control method is used.  We know that a reserved name must be a
 method if it is defined with input arguments.
 
 The warning emitted when a namespace object reference is not found
 during the cross reference phase has been changed into an error.
 The "External" directive should be used for names defined in other
 modules.
 
 
 4) Tools and Utilities
 
 The 16-bit tools (adump16 and aexec16) have been regenerated and
 tested.
 
 Fixed a problem with the output of both acpidump and adump16 where
 the indentation of closing parentheses and brackets was not
 
 aligned properly with the parent block.
 
 
 ----------------------------------------
 03 May 2002.  Summary of changes for this release.
 
 
 1) ACPI CA Core Subsystem Version 20020503:
 
 Added support a new OSL interface that allows the host operating
 
 system software to override the DSDT found in the firmware -
 AcpiOsTableOverride.  With this interface, the OSL can examine the
 version of the firmware DSDT and replace it with a different one
 if desired.
 
 Added new external interfaces for accessing ACPI registers from
 device drivers and other system software - AcpiGetRegister and
 AcpiSetRegister.  This was simply an externalization of the
 existing AcpiHwBitRegister interfaces.
 
 Fixed a regression introduced in the previous build where the
 ASL/AML CreateField operator always returned an error,
 "destination must be a NS Node".
 
 Extended the maximum time (before failure) to successfully enable
 ACPI mode to 3 seconds.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  68.5K Code,   7.0K Data,   75.5K Total
     Debug Version:     142.4K Code,  58.3K Data,  200.7K Total
   Current Release:
     Non-Debug Version:  68.8K Code,   7.1K Data,   75.9K Total
     Debug Version:     142.9K Code,  58.4K Data,  201.3K Total
 
 
 2) Linux
 
 Enhanced ACPI init code for SMP. We are now fully MPS and $PIR-
 free. While 3 out of 4 of our in-house systems work fine, the last
 one still hangs when testing the LAPIC timer.
 
 Renamed many files in 2.5 kernel release to omit "acpi_" from the
 name.
 
 Added warning on boot for Presario 711FR.
 
 Sleep improvements (Pavel Machek)
 
 ACPI can now be built without CONFIG_PCI enabled.
 
 IA64: Fixed memory map functions (JI Lee)
 
 
 3) iASL Compiler Version X2043:
 
 Added support to allow the compiler to be integrated into the MS
 VC++ development environment for one-button compilation of single
 files or entire projects -- with error-to-source-line mapping.
 
 Implemented support for compile-time constant folding for the
 Type3, Type4, and Type5 opcodes first defined in the ACPI 2.0
 specification.  This allows the ASL writer to use expressions
 instead of Integer/Buffer/String constants in terms that must
 evaluate to constants at compile time and will also simplify the
 emitted AML in any such sub-expressions that can be folded
 (evaluated at compile-time.)  This increases the size of the
 compiler significantly because a portion of the ACPI CA AML
 interpreter is included within the compiler in order to pre-
 evaluate constant expressions.
 
 
 Fixed a problem with the "Unicode" ASL macro that caused the
 compiler to fault.  (This macro is used in conjunction with the
 _STR reserved name.)
 
 Implemented an AML opcode optimization to use the Zero, One, and
 Ones opcodes where possible to further reduce the size of integer
 constants and thus reduce the overall size of the generated AML
 code.
 
 Implemented error checking for new reserved terms for ACPI version
 2.0A.
 
 Implemented the -qr option to display the current list of ACPI
 reserved names known to the compiler.
 
 Implemented the -qc option to display the current list of ASL
 operators that are allowed within constant expressions and can
 therefore be folded at compile time if the operands are constants.
 
 
 4) Documentation
 
 Updated the Programmer's Reference for new interfaces, data types,
 and memory allocation model options.
 
 Updated the iASL Compiler User Reference to apply new format and
 add information about new features and options.
 
 ----------------------------------------
 19 April 2002.  Summary of changes for this release.
 
 1) ACPI CA Core Subsystem Version 20020419:
 
 The source code base for the Core Subsystem has been completely
 cleaned with PC-lint (FlexLint) for both 32-bit and 64-bit
 versions.  The Lint option files used are included in the
 /acpi/generate/lint directory.
 
 Implemented enhanced status/error checking across the entire
 Hardware manager subsystem.  Any hardware errors (reported from
 the OSL) are now bubbled up and will abort a running control
 method.
 
 
 Fixed a problem where the per-ACPI-table integer width (32 or 64)
 was stored only with control method nodes, causing a fault when
 non-control method code was executed during table loading.  The
 solution implemented uses a global variable to indicate table
 width across the entire ACPI subsystem.  Therefore, ACPI CA does
 not support mixed integer widths across different ACPI tables
 (DSDT, SSDT).
 
 Fixed a problem where NULL extended fields (X fields) in an ACPI
 2.0 ACPI FADT caused the table load to fail.  Although the
 existing ACPI specification is a bit fuzzy on this topic, the new
 behavior is to fall back on a ACPI 1.0 field if the corresponding
 ACPI 2.0 X field is zero (even though the table revision indicates
 a full ACPI 2.0 table.)  The ACPI specification will be updated to
 clarify this issue.
 
 Fixed a problem with the SystemMemory operation region handler
 where memory was always accessed byte-wise even if the AML-
 specified access width was larger than a byte.  This caused
 problems on systems with memory-mapped I/O.  Memory is now
 accessed with the width specified.  On systems that do not support
 non-aligned transfers, a check is made to guarantee proper address
 alignment before proceeding in order to avoid an AML-caused
 alignment fault within the kernel.
 
 
 Fixed a problem with the ExtendedIrq resource where only one byte
 of the 4-byte Irq field was extracted.
 
 Fixed the AcpiExDigitsNeeded() procedure to support _UID.  This
 function was out of date and required a rewrite.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  66.6K Code,   6.5K Data,   73.1K Total
     Debug Version:     139.8K Code,  57.4K Data,  197.2K Total
   Current Release:
     Non-Debug Version:  68.5K Code,   7.0K Data,   75.5K Total
     Debug Version:     142.4K Code,  58.3K Data,  200.7K Total
 
 
 2) Linux
 
 PCI IRQ routing fixes (Dominik Brodowski)
 
 
 3) iASL Compiler Version X2042:
 
 Implemented an additional compile-time error check for a field
 unit whose size + minimum access width would cause a run-time
 access beyond the end-of-region.  Previously, only the field size
 itself was checked.
 
 The Core subsystem and iASL compiler now share a common parse
 object in preparation for compile-time evaluation of the type
 3/4/5 ASL operators.
 
 
 ----------------------------------------
 Summary of changes for this release: 03_29_02
 
 1) ACPI CA Core Subsystem Version 20020329:
 
 Implemented support for late evaluation of TermArg operands to
 Buffer and Package objects.  This allows complex expressions to be
 used in the declarations of these object types.
 
 Fixed an ACPI 1.0 compatibility issue when reading Fields. In ACPI
 1.0, if the field was larger than 32 bits, it was returned as a
 buffer - otherwise it was returned as an integer.  In ACPI 2.0,
 the field is returned as a buffer only if the field is larger than
 64 bits.  The TableRevision is now considered when making this
 conversion to avoid incompatibility with existing ASL code.
 
 Implemented logical addressing for AcpiOsGetRootPointer.  This
 allows an RSDP with either a logical or physical address.  With
 this support, the host OS can now override all ACPI tables with
 one logical RSDP.  Includes implementation of  "typed" pointer
 support to allow a common data type for both physical and logical
 pointers internally.  This required a change to the
 AcpiOsGetRootPointer interface.
 
 Implemented the use of ACPI 2.0 Generic Address Structures for all
 GPE, Fixed Event, and PM Timer I/O.  This allows the use of memory
 mapped I/O for these ACPI features.
 
 Initialization now ignores not only non-required tables (All
 tables other than the FADT, FACS, DSDT, and SSDTs), but also does
 not validate the table headers of unrecognized tables.
 
 Fixed a problem where a notify handler could only be
 installed/removed on an object of type Device.  All "notify"
 
 objects are now supported -- Devices, Processor, Power, and
 Thermal.
 
 Removed most verbosity from the ACPI_DB_INFO debug level.  Only
 critical information is returned when this debug level is enabled.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release
     Non-Debug Version:  65.4K Code,   6.2K Data,   71.6K Total
     Debug Version:     138.0K Code,  56.6K Data,  194.6K Total
   Current Release:
     Non-Debug Version:  66.6K Code,   6.5K Data,   73.1K Total
     Debug Version:     139.8K Code,  57.4K Data,  197.2K Total
 
 
 2) Linux:
 
 The processor driver (acpi_processor.c) now fully supports ACPI
 2.0-based processor performance control (e.g. Intel(R)
 SpeedStep(TM) technology) Note that older laptops that only have
 the Intel "applet" interface are not supported through this.  The
 'limit' and 'performance' interface (/proc) are fully functional.
 [Note that basic policy for controlling performance state
 transitions will be included in the next version of ospmd.]  The
 idle handler was modified to more aggressively use C2, and PIIX4
 errata handling underwent a complete overhaul (big thanks to
 Dominik Brodowski).
 
 Added support for ACPI-PCI device binding (acpi_pci_root.c). _ADR-
 based devices in the ACPI namespace are now dynamically bound
 (associated) with their PCI counterparts (e.g. PCI1->01:00.0).
 This allows, among other things, ACPI to resolve bus numbers for
 subordinate PCI bridges.
 
 Enhanced PCI IRQ routing to get the proper bus number for _PRT
 entries defined underneath PCI bridges.
 
 Added IBM 600E to bad bios list due to invalid _ADR value for
 PIIX4 PCI-ISA bridge, resulting in improper PCI IRQ routing.
 
 In the process of adding full MADT support (e.g. IOAPIC) for IA32
 (acpi.c, mpparse.c) -- stay tuned.
 
 Added back visual differentiation between fixed-feature and
 control-method buttons in dmesg.  Buttons are also subtyped (e.g.
 button/power/PWRF) to simplify button identification.
 
 We no longer use -Wno-unused when compiling debug. Please ignore
 any "_THIS_MODULE defined but not used" messages.
 
 Can now shut down the system using "magic sysrq" key.
 
 
 3) iASL Compiler version 2041:
 
 Fixed a problem where conversion errors for hex/octal/decimal
 constants were not reported.
 
 Implemented a fix for the General Register template Address field.
 This field was 8 bits when it should be 64.
 
 Fixed a problem where errors/warnings were no longer being emitted
 within the listing output file.
 
 Implemented the ACPI 2.0A restriction on ACPI Table Signatures to
 exactly 4 characters, alphanumeric only.
 
 
 
 
 ----------------------------------------
 Summary of changes for this release: 03_08_02
 
 
 1) ACPI CA Core Subsystem Version 20020308:
 
 Fixed a problem with AML Fields where the use of the "AccessAny"
 keyword could cause an interpreter error due to attempting to read
 or write beyond the end of the parent Operation Region.
 
 Fixed a problem in the SystemMemory Operation Region handler where
 an attempt was made to map memory beyond the end of the region.
 This was the root cause of the "AE_ERROR" and "AE_NO_MEMORY"
 errors on some Linux systems.
 
 Fixed a problem where the interpreter/namespace "search to root"
 algorithm was not functioning for some object types.  Relaxed the
 internal restriction on the search to allow upsearches for all
 external object types as well as most internal types.
 
 
 2) Linux:
 
 We now use safe_halt() macro versus individual calls to sti | hlt.
 
 Writing to the processor limit interface should now work. "echo 1"
 will increase the limit, 2 will decrease, and 0 will reset to the
 
 default.
 
 
 3) ASL compiler:
 
 Fixed segfault on Linux version.
 
 
 ----------------------------------------
 Summary of changes for this release: 02_25_02
 
 1) ACPI CA Core Subsystem:
 
 
 Fixed a problem where the GPE bit masks were not initialized
 properly, causing erratic GPE behavior.
 
 Implemented limited support for multiple calling conventions.  The
 code can be generated with either the VPL (variable parameter
 list, or "C") convention, or the FPL (fixed parameter list, or
 "Pascal") convention.  The core subsystem is about 3.4% smaller
 when generated with FPL.
 
 
 2) Linux
 
 Re-add some /proc/acpi/event functionality that was lost during
 the rewrite
 
 Resolved issue with /proc events for fixed-feature buttons showing
 up as the system device.
 
 Fixed checks on C2/C3 latencies to be inclusive of maximum values.
 
 Replaced AE_ERRORs in acpi_osl.c with more specific error codes.
 
 Changed ACPI PRT option from "pci=noacpi-routing" to "pci=noacpi"
 
 Fixed limit interface & usage to fix bugs with passive cooling
 hysterisis.
 
 Restructured PRT support.
 
 
 ----------------------------------------
 Summary of changes for this label: 02_14_02
 
 
 1) ACPI CA Core Subsystem:
 
 Implemented support in AcpiLoadTable to allow loading of FACS and
 FADT tables.
 
 Suport for the now-obsolete interim 0.71 64-bit ACPI tables has
 been removed.  All 64-bit platforms should be migrated to the ACPI
 2.0 tables.  The actbl71.h header has been removed from the source
 tree.
 
 All C macros defined within the subsystem have been prefixed with
 "ACPI_" to avoid collision with other system include files.
 
 Removed the return value for the two AcpiOsPrint interfaces, since
 it is never used and causes lint warnings for ignoring the return
 value.
 
 Added error checking to all internal mutex acquire and release
 calls.  Although a failure from one of these interfaces is
 probably a fatal system error, these checks will cause the
 immediate abort of the currently executing method or interface.
 
 Fixed a problem where the AcpiSetCurrentResources interface could
 fault.  This was a side effect of the deployment of the new memory
 allocation model.
 
 Fixed a couple of problems with the Global Lock support introduced
 in the last major build.  The "common" (1.0/2.0) internal FACS was
 being overwritten with the FACS signature and clobbering the
 Global Lock pointer.  Also, the actual firmware FACS was being
 unmapped after construction of the "common" FACS, preventing
 access to the actual Global Lock field within it.  The "common"
 internal FACS is no longer installed as an actual ACPI table; it
 is used simply as a global.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below.  These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release (02_07_01)
     Non-Debug Version:  65.2K Code,   6.2K Data,   71.4K Total
     Debug Version:     136.9K Code,  56.4K Data,  193.3K Total
   Current Release:
     Non-Debug Version:  65.4K Code,   6.2K Data,   71.6K Total
     Debug Version:     138.0K Code,  56.6K Data,  194.6K Total
 
 
 2) Linux
 
 Updated Linux-specific code for core macro and OSL interface
 changes described above.
 
 Improved /proc/acpi/event. It now can be opened only once and has
 proper poll functionality.
 
 Fixed and restructured power management (acpi_bus).
 
 Only create /proc "view by type" when devices of that class exist.
 
 Fixed "charging/discharging" bug (and others) in acpi_battery.
 
 Improved thermal zone code.
 
 
 3) ASL Compiler, version X2039:
 
 
 Implemented the new compiler restriction on ASL String hex/octal
 escapes to non-null, ASCII values.  An error results if an invalid
 value is used.  (This will require an ACPI 2.0 specification
 change.)
 
 AML object labels that are output to the optional C and ASM source
 are now prefixed with both the ACPI table signature and table ID
 to help guarantee uniqueness within a large BIOS project.
 
 
 ----------------------------------------
 Summary of changes for this label: 02_01_02
 
 1) ACPI CA Core Subsystem:
 
 ACPI 2.0 support is complete in the entire Core Subsystem and the
 ASL compiler. All new ACPI 2.0 operators are implemented and all
 other changes for ACPI 2.0 support are complete.  With
 simultaneous code and data optimizations throughout the subsystem,
 ACPI 2.0 support has been implemented with almost no additional
 cost in terms of code and data size.
 
 Implemented a new mechanism for allocation of return buffers.  If
 the buffer length is set to ACPI_ALLOCATE_BUFFER, the buffer will
 be allocated on behalf of the caller.  Consolidated all return
 buffer validation and allocation to a common procedure.  Return
 buffers will be allocated via the primary OSL allocation interface
 since it appears that a separate pool is not needed by most users.
 If a separate pool is required for these buffers, the caller can
 still use the original mechanism and pre-allocate the buffer(s).
 
 Implemented support for string operands within the DerefOf
 operator.
 
 Restructured the Hardware and Event managers to be table driven,
 simplifying the source code and reducing the amount of generated
 code.
 
 Split the common read/write low-level ACPI register bitfield
 procedure into a separate read and write, simplifying the code
 considerably.
 
 Obsoleted the AcpiOsCallocate OSL interface.  This interface was
 used only a handful of times and didn't have enough critical mass
 for a separate interface.  Replaced with a common calloc procedure
 in the core.
 
 Fixed a reported problem with the GPE number mapping mechanism
 that allows GPE1 numbers to be non-contiguous with GPE0.
 Reorganized the GPE information and shrunk a large array that was
 originally large enough to hold info for all possible GPEs (256)
 to simply large enough to hold all GPEs up to the largest GPE
 number on the machine.
 
 Fixed a reported problem with resource structure alignment on 64-
 bit platforms.
 
 Changed the AcpiEnableEvent and AcpiDisableEvent external
 interfaces to not require any flags for the common case of
 enabling/disabling a GPE.
 
 Implemented support to allow a "Notify" on a Processor object.
 
 Most TBDs in comments within the source code have been resolved
 and eliminated.
 
 
 Fixed a problem in the interpreter where a standalone parent
 prefix (^) was not handled correctly in the interpreter and
 debugger.
 
 Removed obsolete and unnecessary GPE save/restore code.
 
 Implemented Field support in the ASL Load operator.  This allows a
 table to be loaded from a named field, in addition to loading a
 table directly from an Operation Region.
 
 Implemented timeout and handle support in the external Global Lock
 interfaces.
 
 Fixed a problem in the AcpiDump utility where pathnames were no
 longer being generated correctly during the dump of named objects.
 
 Modified the AML debugger to give a full display of if/while
 predicates instead of just one AML opcode at a time.  (The
 predicate can have several nested ASL statements.)  The old method
 was confusing during single stepping.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below. These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release (12_18_01)
      Non-Debug Version:  66.1K Code,   5.5K Data,   71.6K Total
      Debug Version:     138.3K Code,  55.9K Data,  194.2K Total
    Current Release:
      Non-Debug Version:  65.2K Code,   6.2K Data,   71.4K Total
      Debug Version:     136.9K Code,  56.4K Data,  193.3K Total
 
 2) Linux
 
  Implemented fix for PIIX reverse throttling errata (Processor
 driver)
 
 Added new Limit interface (Processor and Thermal drivers)
 
 New thermal policy (Thermal driver)
 
 Many updates to /proc
 
 Battery "low" event support (Battery driver)
 
 Supports ACPI PCI IRQ routing (PCI Link and PCI root drivers)
 
 IA32 - IA64 initialization unification, no longer experimental
 
 Menuconfig options redesigned
 
 3) ASL Compiler, version X2037:
 
 Implemented several new output features to simplify integration of
 AML code into  firmware: 1) Output the AML in C source code with
 labels for each named ASL object.  The    original ASL source code
 is interleaved as C comments. 2) Output the AML in ASM source code
 with labels and interleaved ASL    source. 3) Output the AML in
 raw hex table form, in either C or ASM.
 
 Implemented support for optional string parameters to the
 LoadTable operator.
 
 Completed support for embedded escape sequences within string
 literals.  The compiler now supports all single character escapes
 as well as the Octal and Hex escapes.  Note: the insertion of a
 null byte into a string literal (via the hex/octal escape) causes
 the string to be immediately terminated.  A warning is issued.
 
 Fixed a problem where incorrect AML was generated for the case
 where an ASL namepath consists of a single parent prefix (
 
 ) with no trailing name segments.
 
 The compiler has been successfully generated with a 64-bit C
 compiler.
 
 
 
 
 ----------------------------------------
 Summary of changes for this label: 12_18_01
 
 1) Linux
 
 Enhanced blacklist with reason and severity fields. Any table's
 signature may now be used to identify a blacklisted system.
 
 Call _PIC control method to inform the firmware which interrupt
 model the OS is using. Turn on any disabled link devices.
 
 Cleaned up busmgr /proc error handling (Andreas Dilger)
 
  2) ACPI CA Core Subsystem:
 
 Implemented ACPI 2.0 semantics for the "Break" operator (Exit from
 while loop)
 
 Completed implementation of the ACPI 2.0 "Continue",
 "ConcatenateResTemplate", "DataTableRegion", and "LoadTable"
 operators.  All new ACPI 2.0 operators are now implemented in both
 the ASL compiler and the AML interpreter.  The only remaining ACPI
 2.0 task is support for the String data type in the DerefOf
 operator.  Fixed a problem with AcquireMutex where the status code
 was lost if the caller had to actually wait for the mutex.
 
 Increased the maximum ASL Field size from 64K bits to 4G bits.
 
 Completed implementation of the external Global Lock interfaces --
 AcpiAcquireGlobalLock and AcpiReleaseGlobalLock.  The Timeout and
 Handler parameters were added.
 
 Completed another pass at removing warnings and issues when
 compiling with 64-bit compilers.  The code now compiles cleanly
 with the Intel 64-bit C/C++ compiler.  Most notably, the pointer
 add and subtract (diff) macros have changed considerably.
 
 
 Created and deployed a new ACPI_SIZE type that is 64-bits wide on
 64-bit platforms, 32-bits on all others.  This type is used
 wherever memory allocation and/or the C sizeof() operator is used,
 and affects the OSL memory allocation interfaces AcpiOsAllocate
 and AcpiOsCallocate.
 
 Implemented sticky user breakpoints in the AML debugger.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below. These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size. Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release (12_05_01)
      Non-Debug Version:  64.7K Code,   5.3K Data,   70.0K Total
      Debug Version:     136.2K Code,  55.6K Data,  191.8K Total
    Current Release:
      Non-Debug Version:  66.1K Code,   5.5K Data,   71.6K Total
      Debug Version:     138.3K Code,  55.9K Data,  194.2K Total
 
  3) ASL Compiler, version X2034:
 
 Now checks for (and generates an error if detected) the use of a
 Break or Continue statement without an enclosing While statement.
 
 
 Successfully generated the compiler with the Intel 64-bit C
 compiler.
 
  ----------------------------------------
 Summary of changes for this label: 12_05_01
 
  1) ACPI CA Core Subsystem:
 
 The ACPI 2.0 CopyObject operator is fully implemented.  This
 operator creates a new copy of an object (and is also used to
 bypass the "implicit conversion" mechanism of the Store operator.)
 
 The ACPI 2.0 semantics for the SizeOf operator are fully
 implemented.  The change is that performing a SizeOf on a
 reference object causes an automatic dereference of the object to
 tha actual value before the size is evaluated. This behavior was
 undefined in ACPI 1.0.
 
 The ACPI 2.0 semantics for the Extended IRQ resource descriptor
 have been implemented.  The interrupt polarity and mode are now
 independently set.
 
 Fixed a problem where ASL Constants (Zero, One, Ones, Revision)
 appearing in Package objects were not properly converted to
 integers when the internal Package was converted to an external
 object (via the AcpiEvaluateObject interface.)
 
 Fixed a problem with the namespace object deletion mechanism for
 objects created by control methods.  There were two parts to this
 problem: 1) Objects created during the initialization phase method
 parse were not being deleted, and 2) The object owner ID mechanism
 to track objects was broken.
 
 Fixed a problem where the use of the ASL Scope operator within a
 control method would result in an invalid opcode exception.
 
 Fixed a problem introduced in the previous label where the buffer
 length required for the _PRT structure was not being returned
 correctly.
 
 Code and Data Size: Current core subsystem library sizes are shown
 below. These are the code and data sizes for the acpica.lib
 produced by the Microsoft Visual C++ 6.0 compiler, and these
 values do not include any ACPI driver or OSPM code.  The debug
 version of the code includes the debug output trace mechanism and
 has a larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Previous Release (11_20_01)
      Non-Debug Version:  64.1K Code,   5.3K Data,   69.4K Total
      Debug Version:     135.1K Code,  55.4K Data,  190.5K Total
 
   Current Release:
      Non-Debug Version:  64.7K Code,   5.3K Data,   70.0K Total
      Debug Version:     136.2K Code,  55.6K Data,  191.8K Total
 
  2) Linux:
 
 Updated all files to apply cleanly against 2.4.16.
 
 Added basic PCI Interrupt Routing Table (PRT) support for IA32
 (acpi_pci.c), and unified the PRT code for IA32 and IA64.  This
 version supports both static and dyanmic PRT entries, but dynamic
 entries are treated as if they were static (not yet
 reconfigurable).  Architecture- specific code to use this data is
 absent on IA32 but should be available shortly.
 
 Changed the initialization sequence to start the ACPI interpreter
 (acpi_init) prior to initialization of the PCI driver (pci_init)
 in init/main.c.  This ordering is required to support PRT and
 facilitate other (future) enhancement.  A side effect is that the
 ACPI bus driver and certain device drivers can no longer be loaded
 as modules.
 
 Modified the 'make menuconfig' options to allow PCI Interrupt
 Routing support to be included without the ACPI Bus and other
 device drivers.
 
  3) ASL Compiler, version X2033:
 
 Fixed some issues with the use of the new CopyObject and
 DataTableRegion operators.  Both are fully functional.
 
  ----------------------------------------
 Summary of changes for this label: 11_20_01
 
  20 November 2001.  Summary of changes for this release.
 
  1) ACPI CA Core Subsystem:
 
 Updated Index support to match ACPI 2.0 semantics.  Storing a
 Integer, String, or Buffer to an Index of a Buffer will store only
 the least-significant byte of the source to the Indexed buffer
 byte.  Multiple writes are not performed.
 
 Fixed a problem where the access type used in an AccessAs ASL
 operator was not recorded correctly into the field object.
 
 Fixed a problem where ASL Event objects were created in a
 signalled state. Events are now created in an unsignalled state.
 
 The internal object cache is now purged after table loading and
 initialization to reduce the use of dynamic kernel memory -- on
 the assumption that object use is greatest during the parse phase
 of the entire table (versus the run-time use of individual control
 methods.)
 
 ACPI 2.0 variable-length packages are now fully operational.
 
 Code and Data Size: Code and Data optimizations have permitted new
 feature development with an actual reduction in the library size.
 Current core subsystem library sizes are shown below.  These are
 the code and data sizes for the acpica.lib produced by the
 Microsoft Visual C++ 6.0 compiler, and these values do not include
 any ACPI driver or OSPM code.  The debug version of the code
 includes the debug output trace mechanism and has a larger code
 and data size.  Note that these values will vary depending on the
 efficiency of the compiler and the compiler options used during
 generation.
 
   Previous Release (11_09_01):
      Non-Debug Version:  63.7K Code,   5.2K Data,   68.9K Total
      Debug Version:     134.5K Code,  55.4K Data,  189.9K Total
 
   Current Release:
      Non-Debug Version:  64.1K Code,   5.3K Data,   69.4K Total
      Debug Version:     135.1K Code,  55.4K Data,  190.5K Total
 
  2) Linux:
 
 Enhanced the ACPI boot-time initialization code to allow the use
 of Local APIC tables for processor enumeration on IA-32, and to
 pave the way for a fully MPS-free boot (on SMP systems) in the
 near future.  This functionality replaces
 arch/i386/kernel/acpitables.c, which was introduced in an earlier
 2.4.15-preX release.  To enable this feature you must add
 "acpi_boot=on" to the kernel command line -- see the help entry
 for CONFIG_ACPI_BOOT for more information.  An IA-64 release is in
 the works...
 
 Restructured the configuration options to allow boot-time table
 parsing support without inclusion of the ACPI Interpreter (and
 other) code.
 
 NOTE: This release does not include fixes for the reported events,
 power-down, and thermal passive cooling issues (coming soon).
 
  3) ASL Compiler:
 
 Added additional typechecking for Fields within restricted access
 Operation Regions.  All fields within EC and CMOS regions must be
 declared with ByteAcc. All fields withing SMBus regions must be
 declared with the BufferAcc access type.
 
 Fixed a problem where the listing file output of control methods
 no longer interleaved the actual AML code with the ASL source
 code.
 
 
 
 
 ----------------------------------------
 Summary of changes for this label: 11_09_01
 
 1) ACPI CA Core Subsystem:
 
 Implemented ACPI 2.0-defined support for writes to fields with a
 Buffer, String, or Integer source operand that is smaller than the
 target field. In these cases, the source operand is zero-extended
 to fill the target field.
 
 Fixed a problem where a Field starting bit offset (within the
 parent operation region) was calculated incorrectly if the
 
 alignment of the field differed from the access width.  This
 affected CreateWordField, CreateDwordField, CreateQwordField, and
 possibly other fields that use the "AccessAny" keyword.
 
 Fixed a problem introduced in the 11_02_01 release where indirect
 stores through method arguments did not operate correctly.
 
 2) Linux:
 
 Implemented boot-time ACPI table parsing support
 (CONFIG_ACPI_BOOT) for IA32 and IA64 UP/SMP systems.  This code
 facilitates the use of ACPI tables (e.g. MADT, SRAT) rather than
 legacy BIOS interfaces (e.g. MPS) for the configuration of system
 processors, memory, and interrupts during setup_arch().  Note that
 this patch does not include the required architecture-specific
 changes required to apply this information -- subsequent patches
 will be posted for both IA32 and IA64 to achieve this.
 
 Added low-level sleep support for IA32 platforms, courtesy of Pat
 Mochel. This allows IA32 systems to transition to/from various
 sleeping states (e.g. S1, S3), although the lack of a centralized
 driver model and power-manageable drivers will prevent its
 (successful) use on most systems.
 
 Revamped the ACPI 'menuconfig' layout: created new "ACPI Support"
 submenu, unified IA32 and IA64 options, added new "Boot using ACPI
 tables" option, etc.
 
 Increased the default timeout for the EC driver from 1ms to 10ms
 (1000 cycles of 10us) to try to address AE_TIME errors during EC
 transactions.
 
  ----------------------------------------
 Summary of changes for this label: 11_02_01
 
 1) ACPI CA Core Subsystem:
 
 ACPI 2.0 Support: Implemented ACPI 2.0 64-bit Field access
 (QWordAcc keyword). All ACPI 2.0 64-bit support is now
 implemented.
 
 OSL Interfaces: Several of the OSL (AcpiOs*) interfaces required
 changes to support ACPI 2.0 Qword field access.  Read/Write
 PciConfiguration(), Read/Write Memory(), and Read/Write Port() now
 accept an ACPI_INTEGER (64 bits) as the value parameter.  Also,
 the value parameter for the address space handler interface is now
 an ACPI_INTEGER.  OSL implementations of these interfaces must now
 handle the case where the Width parameter is 64.
 
 Index Fields: Fixed a problem where unaligned bit assembly and
 disassembly for IndexFields was not supported correctly.
 
 Index and Bank Fields:  Nested Index and Bank Fields are now
 supported. During field access, a check is performed to ensure
 that the value written to an Index or Bank register is not out of
 the range of the register.  The Index (or Bank) register is
 written before each access to the field data. Future support will
 include allowing individual IndexFields to be wider than the
 DataRegister width.
 
 Fields: Fixed a problem where the AML interpreter was incorrectly
 attempting to write beyond the end of a Field/OpRegion.  This was
 a boundary case that occurred when a DWORD field was written to a
 BYTE access OpRegion, forcing multiple writes and causing the
 interpreter to write one datum too many.
 
 Fields: Fixed a problem with Field/OpRegion access where the
 starting bit address of a field was incorrectly calculated if the
 current access type was wider than a byte (WordAcc, DwordAcc, or
 QwordAcc).
 
 Fields: Fixed a problem where forward references to individual
 FieldUnits (individual Field names within a Field definition) were
 not resolved during the AML table load.
 
 Fields: Fixed a problem where forward references from a Field
 definition to the parent Operation Region definition were not
 resolved during the AML table load.
 
 Fields: Duplicate FieldUnit names within a scope are now detected
 during AML table load.
 
 Acpi Interfaces: Fixed a problem where the AcpiGetName() interface
 returned an incorrect name for the root node.
 
 Code and Data Size: Code and Data optimizations have permitted new
 feature development with an actual reduction in the library size.
 Current core subsystem library sizes are shown below.  These are
 the code and data sizes for the acpica.lib produced by the
 Microsoft Visual C++ 6.0 compiler, and these values do not include
 any ACPI driver or OSPM code.  The debug version of the code
 includes the debug output trace mechanism and has a larger code
 and data size.  Note that these values will vary depending on the
 efficiency of the compiler and the compiler options used during
 generation.
 
   Previous Release (10_18_01):
      Non-Debug Version:  63.9K Code,   5.1K Data,   69.0K Total
      Debug Version:     136.7K Code,  57.4K Data,  194.2K Total
 
   Current Release:
      Non-Debug Version:  63.7K Code,   5.2K Data,   68.9K Total
      Debug Version:     134.5K Code,  55.4K Data,  189.9K Total
 
  2) Linux:
 
 Improved /proc processor output (Pavel Machek) Re-added
 MODULE_LICENSE("GPL") to all modules.
 
  3) ASL Compiler version X2030:
 
 Duplicate FieldUnit names within a scope are now detected and
 flagged as errors.
 
  4) Documentation:
 
 Programmer Reference updated to reflect OSL and address space
 handler interface changes described above.
 
 ----------------------------------------
 Summary of changes for this label: 10_18_01
 
 ACPI CA Core Subsystem:
 
 Fixed a problem with the internal object reference count mechanism
 that occasionally caused premature object deletion. This resolves
 all of the outstanding problem reports where an object is deleted
 in the middle of an interpreter evaluation.  Although this problem
 only showed up in rather obscure cases, the solution to the
 problem involved an adjustment of all reference counts involving
 objects attached to namespace nodes.
 
 Fixed a problem with Field support in the interpreter where
 writing to an aligned field whose length is an exact multiple (2
 or greater) of the field access granularity would cause an attempt
 to write beyond the end of the field.
 
 The top level AML opcode execution functions within the
 interpreter have been renamed with a more meaningful and
 consistent naming convention.  The modules exmonad.c and
 exdyadic.c were eliminated.  New modules are exoparg1.c,
 exoparg2.c, exoparg3.c, and exoparg6.c.
 
 Support for the ACPI 2.0 "Mid" ASL operator has been implemented.
 
 Fixed a problem where the AML debugger was causing some internal
 objects to not be deleted during subsystem termination.
 
 Fixed a problem with the external AcpiEvaluateObject interface
 where the subsystem would fault if the named object to be
 evaluated refered to a constant such as Zero, Ones, etc.
 
 Fixed a problem with IndexFields and BankFields where the
 subsystem would fault if the index, data, or bank registers were
 not defined in the same scope as the field itself.
 
 Added printf format string checking for compilers that support
 this feature.  Corrected more than 50 instances of issues with
 format specifiers within invocations of ACPI_DEBUG_PRINT
 throughout the core subsystem code.
 
 The ASL "Revision" operator now returns the ACPI support level
 implemented in the core - the value "2" since the ACPI 2.0 support
 is more than 50% implemented.
 
 Enhanced the output of the AML debugger "dump namespace" command
 to output in a more human-readable form.
 
 Current core subsystem library code sizes are shown below.  These
 
 are the code and data sizes for the acpica.lib produced by the
 Microsoft Visual C++ 6.0 compiler, and these values do not include
 any ACPI driver or OSPM code.  The debug version of the code
 includes the full debug trace mechanism -- leading to a much
 
 larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
      Previous Label (09_20_01):
      Non-Debug Version:    65K Code,     5K Data,     70K Total
      Debug Version:       138K Code,    58K Data,    196K Total
 
      This Label:
 
      Non-Debug Version:  63.9K Code,   5.1K Data,   69.0K Total
      Debug Version:     136.7K Code,  57.4K Data,  194.2K Total
 
 Linux:
 
 Implemented a "Bad BIOS Blacklist" to track machines that have
 known ASL/AML problems.
 
 Enhanced the /proc interface for the thermal zone driver and added
 support for _HOT (the critical suspend trip point).  The 'info'
 file now includes threshold/policy information, and allows setting
 of _SCP (cooling preference) and _TZP (polling frequency) values
 to the 'info' file. Examples: "echo tzp=5 > info" sets the polling
 frequency to 5 seconds, and "echo scp=1 > info" sets the cooling
 preference to the passive/quiet mode (if supported by the ASL).
 
 Implemented a workaround for a gcc bug that resuted in an OOPs
 when loading the control method battery driver.
 
  ----------------------------------------
 Summary of changes for this label: 09_20_01
 
  ACPI CA Core Subsystem:
 
 The AcpiEnableEvent and AcpiDisableEvent interfaces have been
 modified to allow individual GPE levels to be flagged as wake-
 enabled (i.e., these GPEs are to remain enabled when the platform
 sleeps.)
 
 The AcpiEnterSleepState and AcpiLeaveSleepState interfaces now
 support wake-enabled GPEs.  This means that upon entering the
 sleep state, all GPEs that are not wake-enabled are disabled.
 When leaving the sleep state, these GPEs are reenabled.
 
 A local double-precision divide/modulo module has been added to
 enhance portability to OS kernels where a 64-bit math library is
 not available.  The new module is "utmath.c".
 
 Several optimizations have been made to reduce the use of CPU
 stack.  Originally over 2K, the maximum stack usage is now below
 2K at 1860  bytes (1.82k)
 
 Fixed a problem with the AcpiGetFirmwareTable interface where the
 root table pointer was not mapped into a logical address properly.
 
 Fixed a problem where a NULL pointer was being dereferenced in the
 interpreter code for the ASL Notify operator.
 
 Fixed a problem where the use of the ASL Revision operator
 returned an error. This operator now returns the current version
 of the ACPI CA core subsystem.
 
 Fixed a problem where objects passed as control method parameters
 to AcpiEvaluateObject were always deleted at method termination.
 However, these objects may end up being stored into the namespace
 by the called method.  The object reference count mechanism was
 applied to these objects instead of a force delete.
 
 Fixed a problem where static strings or buffers (contained in the
 AML code) that are declared as package elements within the ASL
 code could cause a fault because the interpreter would attempt to
 delete them.  These objects are now marked with the "static
 object" flag to prevent any attempt to delete them.
 
 Implemented an interpreter optimization to use operands directly
 from the state object instead of extracting the operands to local
 variables.  This reduces stack use and code size, and improves
 performance.
 
 The module exxface.c was eliminated as it was an unnecessary extra
 layer of code.
 
 Current core subsystem library code sizes are shown below.  These
 are the code and data sizes for the acpica.lib produced by the
 Microsoft Visual C++ 6.0 compiler, and these values do not include
 any ACPI driver or OSPM code.  The debug version of the code
 includes the full debug trace mechanism -- leading to a much
 larger code and data size.  Note that these values will vary
 depending on the efficiency of the compiler and the compiler
 options used during generation.
 
   Non-Debug Version:  65K Code,   5K Data,   70K Total
 (Previously 69K)   Debug Version:     138K Code,  58K Data,  196K
 Total  (Previously 195K)
 
 Linux:
 
 Support for ACPI 2.0 64-bit integers has been added.   All ACPI
 Integer objects are now 64 bits wide
 
 All Acpi data types and structures are now in lower case.  Only
 Acpi macros are upper case for differentiation.
 
  Documentation:
 
 Changes to the external interfaces as described above.
 
  ----------------------------------------
 Summary of changes for this label: 08_31_01
 
  ACPI CA Core Subsystem:
 
 A bug with interpreter implementation of the ASL Divide operator
 was found and fixed.  The implicit function return value (not the
 explicit store operands) was returning the remainder instead of
 the quotient.  This was a longstanding bug and it fixes several
 known outstanding issues on various platforms.
 
 The ACPI_DEBUG_PRINT and function trace entry/exit macros have
 been further optimized for size.  There are 700 invocations of the
 DEBUG_PRINT macro alone, so each optimization reduces the size of
 the debug version of the subsystem significantly.
 
 A stack trace mechanism has been implemented.  The maximum stack
 usage is about 2K on 32-bit platforms.  The debugger command "stat
 stack" will display the current maximum stack usage.
 
 All public symbols and global variables within the subsystem are
 now prefixed with the string "Acpi".  This keeps all of the
 symbols grouped together in a kernel map, and avoids conflicts
 with other kernel subsystems.
 
 Most of the internal fixed lookup tables have been moved into the
 code segment via the const operator.
 
 Several enhancements have been made to the interpreter to both
 reduce the code size and improve performance.
 
 Current core subsystem library code sizes are shown below.  These
 are the code and data sizes for the acpica.lib produced by the
 Microsoft Visual C++ 6.0 compiler, and these values do not include
 any ACPI driver or OSPM code.  The debug version of the code
 includes the full debug trace mechanism which contains over 700
 invocations of the DEBUG_PRINT macro, 500 function entry macro
 invocations, and over 900 function exit macro invocations --
 leading to a much larger code and data size.  Note that these
 values will vary depending on the efficiency of the compiler and
 the compiler options used during generation.
 
         Non-Debug Version:  64K Code,   5K Data,   69K Total
 Debug Version:     137K Code,  58K Data,  195K Total
 
  Linux:
 
 Implemented wbinvd() macro, pending a kernel-wide definition.
 
 Fixed /proc/acpi/event to handle poll() and short reads.
 
  ASL Compiler, version X2026:
 
 Fixed a problem introduced in the previous label where the AML
 
 code emitted for package objects produced packages with zero
 length.
 
  ----------------------------------------
 Summary of changes for this label: 08_16_01
 
 ACPI CA Core Subsystem:
 
 The following ACPI 2.0 ASL operators have been implemented in the
 AML interpreter (These are already supported by the Intel ASL
 compiler):  ToDecimalString, ToHexString, ToString, ToInteger, and
 ToBuffer.  Support for 64-bit AML constants is implemented in the
 AML parser, debugger, and disassembler.
 
 The internal memory tracking mechanism (leak detection code) has
 been upgraded to reduce the memory overhead (a separate tracking
 block is no longer allocated for each memory allocation), and now
 supports all of the internal object caches.
 
 The data structures and code for the internal object caches have
 been coelesced and optimized so that there is a single cache and
 memory list data structure and a single group of functions that
 implement generic cache management.  This has reduced the code
 size in both the debug and release versions of the subsystem.
 
 The DEBUG_PRINT macro(s) have been optimized for size and replaced
 by ACPI_DEBUG_PRINT.  The syntax for this macro is slightly
 different, because it generates a single call to an internal
 function.  This results in a savings of about 90 bytes per
 invocation, resulting in an overall code and data savings of about
 16% in the debug version of the subsystem.
 
  Linux:
 
 Fixed C3 disk corruption problems and re-enabled C3 on supporting
 machines.
 
 Integrated low-level sleep code by Patrick Mochel.
 
 Further tweaked source code Linuxization.
 
 Other minor fixes.
 
  ASL Compiler:
 
 Support for ACPI 2.0 variable length packages is fixed/completed.
 
 Fixed a problem where the optional length parameter for the ACPI
 2.0 ToString operator.
 
 Fixed multiple extraneous error messages when a syntax error is
 detected within the declaration line of a control method.
 
  ----------------------------------------
 Summary of changes for this label: 07_17_01
 
 ACPI CA Core Subsystem:
 
 Added a new interface named AcpiGetFirmwareTable to obtain any
 ACPI table via the ACPI signature.  The interface can be called at
 any time during kernel initialization, even before the kernel
 virtual memory manager is initialized and paging is enabled.  This
 allows kernel subsystems to obtain ACPI tables very early, even
 before the ACPI CA subsystem is initialized.
 
 Fixed a problem where Fields defined with the AnyAcc attribute
 could be resolved to the incorrect address under the following
 conditions: 1) the field width is larger than 8 bits and 2) the
 parent operation region is not defined on a DWORD boundary.
 
 Fixed a problem where the interpreter is not being locked during
 namespace initialization (during execution of the _INI control
 methods), causing an error when an attempt is made to release it
 later.
 
 ACPI 2.0 support in the AML Interpreter has begun and will be
 ongoing throughout the rest of this year.  In this label, The Mod
 operator is implemented.
 
 Added a new data type to contain full PCI addresses named
 ACPI_PCI_ID. This structure contains the PCI Segment, Bus, Device,
 and Function values.
 
  Linux:
 
 Enhanced the Linux version of the source code to change most
 capitalized ACPI type names to lowercase. For example, all
 instances of ACPI_STATUS are changed to acpi_status.  This will
 result in a large diff, but the change is strictly cosmetic and
 aligns the CA code closer to the Linux coding standard.
 
 OSL Interfaces:
 
 The interfaces to the PCI configuration space have been changed to
 add the PCI Segment number and to split the single 32-bit combined
 DeviceFunction field into two 16-bit fields.  This was
 accomplished by moving the four values that define an address in
 PCI configuration space (segment, bus, device, and function) to
 the new ACPI_PCI_ID structure.
 
 The changes to the PCI configuration space interfaces led to a
 reexamination of the complete set of address space access
 interfaces for PCI, I/O, and Memory.  The previously existing 18
 interfaces have proven difficult to maintain (any small change
 must be propagated across at least 6 interfaces) and do not easily
 allow for future expansion to 64 bits if necessary.  Also, on some
 systems, it would not be appropriate to demultiplex the access
 width (8, 16, 32,or 64) before calling the OSL if the
 corresponding native OS interfaces contain a similar access width
 parameter.  For these reasons, the 18 address space interfaces
 have been replaced by these 6 new ones:
 
 AcpiOsReadPciConfiguration
 AcpiOsWritePciConfiguration
 AcpiOsReadMemory
 AcpiOsWriteMemory
 AcpiOsReadPort
 AcpiOsWritePort
 
 Added a new interface named AcpiOsGetRootPointer to allow the OSL
 to perform the platform and/or OS-specific actions necessary to
 obtain the ACPI RSDP table pointer.  On IA-32 platforms, this
 interface will simply call down to the CA core to perform the low-
 memory search for the table.  On IA-64, the RSDP is obtained from
 EFI.  Migrating this interface to the OSL allows the CA core to
 
 remain OS and platform independent.
 
 Added a new interface named AcpiOsSignal to provide a generic
 "function code and pointer" interface for various miscellaneous
 signals and notifications that must be made to the host OS.   The
 first such signals are intended to support the ASL Fatal and
 Breakpoint operators.  In the latter case, the AcpiOsBreakpoint
 interface has been obsoleted.
 
 The definition of the AcpiFormatException interface has been
 changed to simplify its use.  The caller no longer must supply a
 buffer to the call; A pointer to a const string is now returned
 directly.  This allows the call to be easily used in printf
 statements, etc. since the caller does not have to manage a local
 buffer.
 
 
  ASL Compiler, Version X2025:
 
 The ACPI 2.0 Switch/Case/Default operators have been implemented
 and are fully functional.  They will work with all ACPI 1.0
 interpreters, since the operators are simply translated to If/Else
 pairs.
 
 The ACPI 2.0 ElseIf operator is implemented and will also work
 with 1.0 interpreters, for the same reason.
 
 Implemented support for ACPI 2.0 variable-length packages.  These
 packages have a separate opcode, and their size is determined by
 the interpreter at run-time.
 
 Documentation The ACPI CA Programmer Reference has been updated to
 reflect the new interfaces and changes to existing interfaces.
 
  ------------------------------------------
 Summary of changes for this label: 06_15_01
 
  ACPI CA Core Subsystem:
 
 Fixed a problem where a DWORD-accessed field within a Buffer
 object would get its byte address inadvertently rounded down to
 the nearest DWORD.  Buffers are always Byte-accessible.
 
  ASL Compiler, version X2024:
 
 Fixed a problem where the Switch() operator would either fault or
 hang the compiler.  Note however, that the AML code for this ACPI
 2.0 operator is not yet implemented.
 
 Compiler uses the new AcpiOsGetTimer interface to obtain compile
 timings.
 
 Implementation of the CreateField operator automatically converts
 a reference to a named field within a resource descriptor from a
 byte offset to a bit offset if required.
 
 Added some missing named fields from the resource descriptor
 support. These are the names that are automatically created by the
 compiler to reference fields within a descriptor.  They are only
 valid at compile time and are not passed through to the AML
 interpreter.
 
 Resource descriptor named fields are now typed as Integers and
 subject to compile-time typechecking when used in expressions.
 
  ------------------------------------------
 Summary of changes for this label: 05_18_01
 
  ACPI CA Core Subsystem:
 
 Fixed a couple of problems in the Field support code where bits
 from adjacent fields could be returned along with the proper field
 bits. Restructured the field support code to improve performance,
 readability and maintainability.
 
 New DEBUG_PRINTP macro automatically inserts the procedure name
 into the output, saving hundreds of copies of procedure name
 strings within the source, shrinking the memory footprint of the
 debug version of the core subsystem.
 
  Source Code Structure:
 
 The source code directory tree was restructured to reflect the
 current organization of the component architecture.  Some files
 and directories have been moved and/or renamed.
 
  Linux:
 
 Fixed leaking kacpidpc processes.
 
 Fixed queueing event data even when /proc/acpi/event is not
 opened.
 
  ASL Compiler, version X2020:
 
 Memory allocation performance enhancement - over 24X compile time
 improvement on large ASL files.  Parse nodes and namestring
 buffers are now allocated from a large internal compiler buffer.
 
 The temporary .SRC file is deleted unless the "-s" option is
 specified
 
 The "-d" debug output option now sends all output to the .DBG file
 instead of the console.
 
 "External" second parameter is now optional
 
 "ElseIf" syntax now properly allows the predicate
 
 Last operand to "Load" now recognized as a Target operand
 
 Debug object can now be used anywhere as a normal object.
 
 ResourceTemplate now returns an object of type BUFFER
 
 EISAID now returns an object of type INTEGER
 
 "Index" now works with a STRING operand
 
 "LoadTable" now accepts optional parameters
 
 "ToString" length parameter is now optional
 
 "Interrupt (ResourceType," parse error fixed.
 
 "Register" with a user-defined region space parse error fixed
 
 Escaped backslash at the end of a string ("\\") scan/parse error
 fixed
 
 "Revision" is now an object of type INTEGER.
 
 
 
 ------------------------------------------
 Summary of changes for this label: 05_02_01
 
 Linux:
 
 /proc/acpi/event now blocks properly.
 
 Removed /proc/sys/acpi. You can still dump your DSDT from
 /proc/acpi/dsdt.
 
  ACPI CA Core Subsystem:
 
 Fixed a problem introduced in the previous label where some of the
 "small" resource descriptor types were not recognized.
 
 Improved error messages for the case where an ASL Field is outside
 the range of the parent operation region.
 
  ASL Compiler, version X2018:
 
 
 Added error detection for ASL Fields that extend beyond the length
 of the parent operation region (only if the length of the region
 is known at compile time.)  This includes fields that have a
 minimum access width that is smaller than the parent region, and
 individual field units that are partially or entirely beyond the
 extent of the parent.
 
 
 
 ------------------------------------------
 Summary of changes for this label: 04_27_01
 
  ACPI CA Core Subsystem:
 
 Fixed a problem where the namespace mutex could be released at the
 wrong time during execution of AcpiRemoveAddressSpaceHandler.
 
 Added optional thread ID output for debug traces, to simplify
 debugging of multiple threads.  Added context switch notification
 when the debug code realizes that a different thread is now
 executing ACPI code.
 
 Some additional external data types have been prefixed with the
 string "ACPI_" for consistency.  This may effect existing code.
 The data types affected are the external callback typedefs - e.g.,
 
 WALK_CALLBACK becomes ACPI_WALK_CALLBACK.
 
  Linux:
 
 Fixed an issue with the OSL semaphore implementation where a
 thread was waking up with an error from receiving a SIGCHLD
 signal.
 
 Linux version of ACPI CA now uses the system C library for string
 manipulation routines instead of a local implementation.
 
 Cleaned up comments and removed TBDs.
 
  ASL Compiler, version X2017:
 
 Enhanced error detection and reporting for all file I/O
 operations.
 
  Documentation:
 
 Programmer Reference updated to version 1.06.
 
 
 
 ------------------------------------------
 Summary of changes for this label: 04_13_01
 
  ACPI CA Core Subsystem:
 
 Restructured support for BufferFields and RegionFields.
 BankFields support is now fully operational.  All known 32-bit
 limitations on field sizes have been removed.  Both BufferFields
 and (Operation) RegionFields are now supported by the same field
 management code.
 
 Resource support now supports QWORD address and IO resources. The
 16/32/64 bit address structures and the Extended IRQ structure
 have been changed to properly handle Source Resource strings.
 
 A ThreadId of -1 is now used to indicate a "mutex not acquired"
 condition internally and must never be returned by AcpiOsThreadId.
 This reserved value was changed from 0 since Unix systems allow a
 thread ID of 0.
 
 Linux:
 
 Driver code reorganized to enhance portability
 
 Added a kernel configuration option to control ACPI_DEBUG
 
 Fixed the EC driver to honor _GLK.
 
 ASL Compiler, version X2016:
 
 Fixed support for the "FixedHw" keyword.  Previously, the FixedHw
 address space was set to 0, not 0x7f as it should be.
 
  ------------------------------------------
 Summary of changes for this label: 03_13_01
 
  ACPI CA Core Subsystem:
 
 During ACPI initialization, the _SB_._INI method is now run if
 present.
 
 Notify handler fix - notifies are deferred until the parent method
 completes execution.  This fixes the "mutex already acquired"
 issue seen occasionally.
 
 Part of the "implicit conversion" rules in ACPI 2.0 have been
 found to cause compatibility problems with existing ASL/AML.  The
 convert "result-to-target-type" implementation has been removed
 for stores to method Args and Locals.  Source operand conversion
 is still fully implemented.  Possible changes to ACPI 2.0
 specification pending.
 
 Fix to AcpiRsCalculatePciRoutingTableLength to return correct
 length.
 
 Fix for compiler warnings for 64-bit compiles.
 
  Linux:
 
 /proc output aligned for easier parsing.
 
 Release-version compile problem fixed.
 
 New kernel configuration options documented in Configure.help.
 
 IBM 600E - Fixed Sleep button may generate "Invalid 
 context" message.
 
  OSPM:
 
 Power resource driver integrated with bus manager.
 
 Fixed kernel fault during active cooling for thermal zones.
 
 Source Code:
 
 The source code tree has been restructured.
 
 
 
 ------------------------------------------
 Summary of changes for this label: 03_02_01
 
  Linux OS Services Layer (OSL):
 
 Major revision of all Linux-specific code.
 
 Modularized all ACPI-specific drivers.
 
 Added new thermal zone and power resource drivers.
 
 Revamped /proc interface (new functionality is under /proc/acpi).
 
 New kernel configuration options.
 
  Linux known issues:
 
 New kernel configuration options not documented in Configure.help
 yet.
 
 
 Module dependencies not currently implemented. If used, they
 should be loaded in this order: busmgr, power, ec, system,
 processor, battery, ac_adapter, button, thermal.
 
 Modules will not load if CONFIG_MODVERSION is set.
 
 IBM 600E - entering S5 may reboot instead of shutting down.
 
 IBM 600E - Sleep button may generate "Invalid  context"
 message.
 
 Some systems may fail with "execution mutex already acquired"
 message.
 
  ACPI CA Core Subsystem:
 
 Added a new OSL Interface, AcpiOsGetThreadId.  This was required
 for the  deadlock detection code. Defined to return a non-zero, 32-
 bit thread ID for the currently executing thread.  May be a non-
 zero constant integer on single-thread systems.
 
 Implemented deadlock detection for internal subsystem mutexes.  We
 may add conditional compilation for this code (debug only) later.
 
 ASL/AML Mutex object semantics are now fully supported.  This
 includes multiple acquires/releases by owner and support for the
 
 Mutex SyncLevel parameter.
 
 A new "Force Release" mechanism automatically frees all ASL
 Mutexes that have been acquired but not released when a thread
 exits the interpreter.  This forces conformance to the ACPI spec
 ("All mutexes must be released when an invocation exits") and
 prevents deadlocked ASL threads.  This mechanism can be expanded
 (later) to monitor other resource acquisitions if OEM ASL code
 continues to misbehave (which it will).
 
 Several new ACPI exception codes have been added for the Mutex
 support.
 
 Recursive method calls are now allowed and supported (the ACPI
 spec does in fact allow recursive method calls.)  The number of
 recursive calls is subject to the restrictions imposed by the
 SERIALIZED method keyword and SyncLevel (ACPI 2.0) method
 parameter.
 
 Implemented support for the SyncLevel parameter for control
 methods (ACPI 2.0 feature)
 
 Fixed a deadlock problem when multiple threads attempted to use
 the interpreter.
 
 Fixed a problem where the string length of a String package
 element was not always set in a package returned from
 AcpiEvaluateObject.
 
 Fixed a problem where the length of a String package element was
 not always included in the length of the overall package returned
 from AcpiEvaluateObject.
 
 Added external interfaces (Acpi*) to the ACPI debug memory
 manager.  This manager keeps a list of all outstanding
 allocations, and can therefore detect memory leaks and attempts to
 free memory blocks more than once. Useful for code such as the
 power manager, etc.  May not be appropriate for device drivers.
 Performance with the debug code enabled is slow.
 
 The ACPI Global Lock is now an optional hardware element.
 
  ASL Compiler Version X2015:
 
 Integrated changes to allow the compiler to be generated on
 multiple platforms.
 
 Linux makefile added to generate the compiler on Linux
 
  Source Code:
 
 All platform-specific headers have been moved to their own
 subdirectory, Include/Platform.
 
 New source file added, Interpreter/ammutex.c
 
 New header file, Include/acstruct.h
 
  Documentation:
 
 The programmer reference has been updated for the following new
 interfaces: AcpiOsGetThreadId AcpiAllocate AcpiCallocate AcpiFree
 
  ------------------------------------------
 Summary of changes for this label: 02_08_01
 
 Core ACPI CA Subsystem: Fixed a problem where an error was
 incorrectly returned if the return resource buffer was larger than
 the actual data (in the resource interfaces).
 
 References to named objects within packages are resolved to the
 
 full pathname string before packages are returned directly (via
 the AcpiEvaluateObject interface) or indirectly via the resource
 interfaces.
 
 Linux OS Services Layer (OSL):
 
 Improved /proc battery interface.
 
 
 Added C-state debugging output and other miscellaneous fixes.
 
 ASL Compiler Version X2014:
 
 All defined method arguments can now be used as local variables,
 including the ones that are not actually passed in as parameters.
 The compiler tracks initialization of the arguments and issues an
 exception if they are used without prior assignment (just like
 locals).
 
 The -o option now specifies a filename prefix that is used for all
 output files, including the AML output file.  Otherwise, the
 default behavior is as follows:  1) the AML goes to the file
 specified in the DSDT.  2) all other output files use the input
 source filename as the base.
 
  ------------------------------------------
 Summary of changes for this label: 01_25_01
 
 Core ACPI CA Subsystem: Restructured the implementation of object
 store support within the  interpreter.  This includes support for
 the Store operator as well  as any ASL operators that include a
 target operand.
 
 Partially implemented support for Implicit Result-to-Target
 conversion. This is when a result object is converted on the fly
 to the type of  an existing target object.  Completion of this
 support is pending  further analysis of the ACPI specification
 concerning this matter.
 
 CPU-specific code has been removed from the subsystem (hardware
 directory).
 
 New Power Management Timer functions added
 
 Linux OS Services Layer (OSL): Moved system state transition code
 to the core, fixed it, and modified  Linux OSL accordingly.
 
 Fixed C2 and C3 latency calculations.
 
 
 We no longer use the compilation date for the version message on
 initialization, but retrieve the version from AcpiGetSystemInfo().
 
 Incorporated for fix Sony VAIO machines.
 
 Documentation:  The Programmer Reference has been updated and
 reformatted.
 
 
 ASL Compiler:  Version X2013: Fixed a problem where the line
 numbering and error reporting could get out  of sync in the
 presence of multiple include files.
 
  ------------------------------------------
 Summary of changes for this label: 01_15_01
 
 Core ACPI CA Subsystem:
 
 Implemented support for type conversions in the execution of the
 ASL  Concatenate operator (The second operand is converted to
 match the type  of the first operand before concatenation.)
 
 Support for implicit source operand conversion is partially
 implemented.   The ASL source operand types Integer, Buffer, and
 String are freely  interchangeable for most ASL operators and are
 converted by the interpreter  on the fly as required.  Implicit
 Target operand conversion (where the  result is converted to the
 target type before storing) is not yet implemented.
 
 Support for 32-bit and 64-bit BCD integers is implemented.
 
 Problem fixed where a field read on an aligned field could cause a
 read  past the end of the field.
 
 New exception, AE_AML_NO_RETURN_VALUE, is returned when a method
 does not return a value, but the caller expects one.  (The ASL
 compiler flags this as a warning.)
 
 ASL Compiler:
 
 Version X2011:
 1. Static typechecking of all operands is implemented. This
 prevents the use of invalid objects (such as using a Package where
 an Integer is required) at compile time instead of at interpreter
 run-time.
 2. The ASL source line is printed with ALL errors and warnings.
 3. Bug fix for source EOF without final linefeed.
 4. Debug option is split into a parse trace and a namespace trace.
 5. Namespace output option (-n) includes initial values for
 integers and strings.
 6. Parse-only option added for quick syntax checking.
 7. Compiler checks for duplicate ACPI name declarations
 
 Version X2012:
 1. Relaxed typechecking to allow interchangeability between
 strings, integers, and buffers.  These types are now converted by
 the interpreter at runtime.
 2. Compiler reports time taken by each internal subsystem in the
 debug         output file.
 
 
  ------------------------------------------
 Summary of changes for this label: 12_14_00
 
 ASL Compiler:
 
 This is the first official release of the compiler. Since the
 compiler requires elements of the Core Subsystem, this label
 synchronizes everything.
 
 ------------------------------------------
 Summary of changes for this label: 12_08_00
 
 
 Fixed a problem where named references within the ASL definition
 of both OperationRegions and CreateXXXFields did not work
 properly.  The symptom was an AE_AML_OPERAND_TYPE during
 initialization of the region/field. This is similar (but not
 related internally) to the problem that was fixed in the last
 label.
 
 Implemented both 32-bit and 64-bit support for the BCD ASL
 functions ToBCD and FromBCD.
 
 Updated all legal headers to include "2000" in the copyright
 years.
 
  ------------------------------------------
 Summary of changes for this label: 12_01_00
 
 Fixed a problem where method invocations within the ASL definition
 of both OperationRegions and CreateXXXFields did not work
 properly.  The symptom was an AE_AML_OPERAND_TYPE during
 initialization of the region/field:
 
   nsinit-0209: AE_AML_OPERAND_TYPE while getting region arguments
 [DEBG]   ammonad-0284: Exec_monadic2_r/Not: bad operand(s)
 (0x3005)
 
 Fixed a problem where operators with more than one nested
 subexpression would fail.  The symptoms were varied, by mostly
 AE_AML_OPERAND_TYPE errors.  This was actually a rather serious
 problem that has gone unnoticed until now.
 
   Subtract (Add (1,2), Multiply (3,4))
 
 Fixed a problem where AcpiGetHandle didn't quite get fixed in the
 previous build (The prefix part of a relative path was handled
 incorrectly).
 
 Fixed a problem where Operation Region initialization failed if
 the operation region name was a "namepath" instead of a simple
 "nameseg". Symptom was an AE_NO_OPERAND error.
 
 Fixed a problem where an assignment to a local variable via the
 indirect RefOf mechanism only worked for the first such
 assignment.  Subsequent assignments were ignored.
 
  ------------------------------------------
 Summary of changes for this label: 11_15_00
 
 ACPI 2.0 table support with backwards support for ACPI 1.0 and the
 0.71 extensions.  Note: although we can read ACPI 2.0 BIOS tables,
 the AML  interpreter does NOT have support for the new 2.0 ASL
 grammar terms at this time.
 
 All ACPI hardware access is via the GAS structures in the ACPI 2.0
 FADT.
 
 All physical memory addresses across all platforms are now 64 bits
 wide. Logical address width remains dependent on the platform
 (i.e., "void *").
 
 AcpiOsMapMemory interface changed to a 64-bit physical address.
 
 The AML interpreter integer size is now 64 bits, as per the ACPI
 2.0 specification.
 
 For backwards compatibility with ACPI 1.0, ACPI tables with a
 revision number less than 2 use 32-bit integers only.
 
 Fixed a problem where the evaluation of OpRegion operands did not
 always resolve them to numbers properly.
 
 ------------------------------------------
 Summary of changes for this label: 10_20_00
 
 Fix for CBN_._STA issue.  This fix will allow correct access to
 CBN_ OpRegions when the _STA returns 0x8.
 
 Support to convert ACPI constants (Ones, Zeros, One) to actual
 values before a package object is returned
 
 Fix for method call as predicate to if/while construct causing
 incorrect if/while behavior
 
 Fix for Else block package lengths sometimes calculated wrong (if
 block > 63 bytes)
 
 Fix for Processor object length field, was always zero
 
 Table load abort if FACP sanity check fails
 
 Fix for problem with Scope(name) if name already exists
 
 Warning emitted if a named object referenced cannot be found
 (resolved) during method execution.
 
 
 
 
 
 ------------------------------------------
 Summary of changes for this label: 9_29_00
 
 New table initialization interfaces: AcpiInitializeSubsystem no
 longer has any parameters AcpiFindRootPointer - Find the RSDP (if
 necessary) AcpiLoadTables (RSDP) - load all tables found at RSDP-
 >RSDT Obsolete Interfaces AcpiLoadFirmwareTables - replaced by
 AcpiLoadTables
 
 Note: These interface changes require changes to all existing OSDs
 
 The PCI_Config default address space handler is always installed
 at the root namespace object.
 
 -------------------------------------------
 Summary of changes for this label: 09_15_00
 
 The new initialization architecture is implemented.  New
 interfaces are: AcpiInitializeSubsystem (replaces AcpiInitialize)
 AcpiEnableSubsystem Obsolete Interfaces: AcpiLoadNamespace
 
 (Namespace is automatically loaded when a table is loaded)
 
 The ACPI_OPERAND_OBJECT has been optimized to shrink its size from
 52 bytes to 32 bytes.  There is usually one of these for every
 namespace object, so the memory savings is significant.
 
 Implemented just-in-time evaluation of the CreateField operators.
 
 Bug fixes for IA-64 support have been integrated.
 
 Additional code review comments have been implemented
 
 The so-called "third pass parse" has been replaced by a final walk
 through the namespace to initialize all operation regions (address
 spaces) and fields that have not yet been initialized during the
 execution of the various _INI and REG methods.
 
 New file - namespace/nsinit.c
 
 -------------------------------------------
 Summary of changes for this label: 09_01_00
 
 Namespace manager data structures have been reworked to change the
 primary  object from a table to a single object.  This has
 resulted in dynamic memory  savings of 3X within the namespace and
 2X overall in the ACPI CA subsystem.
 
 Fixed problem where the call to AcpiEvFindPciRootBuses was
 inadvertently left  commented out.
 
 Reduced the warning count when generating the source with the GCC
 compiler.
 
 Revision numbers added to each module header showing the
 SourceSafe version of the file.  Please refer to this version
 number when giving us feedback or comments on individual modules.
 
 The main object types within the subsystem have been renamed to
 clarify their  purpose:
 
 ACPI_INTERNAL_OBJECT -> ACPI_OPERAND_OBJECT
 ACPI_GENERIC_OP -> ACPI_PARSE_OBJECT
 ACPI_NAME_TABLE_ENTRY -> ACPI_NAMESPACE_NODE
 
 NOTE: no changes to the initialization sequence are included in
 this label.
 
 -------------------------------------------
 Summary of changes for this label: 08_23_00
 
 Fixed problem where TerminateControlMethod was being called
 multiple times per  method
 
 Fixed debugger problem where single stepping caused a semaphore to
 be  oversignalled
 
 Improved performance through additional parse object caching -
 added  ACPI_EXTENDED_OP type
 
 -------------------------------------------
 Summary of changes for this label: 08_10_00
 
 Parser/Interpreter integration:  Eliminated the creation of
 complete parse trees  for ACPI tables and control methods.
 Instead, parse subtrees are created and  then deleted as soon as
 they are processed (Either entered into the namespace or  executed
 by the interpreter).  This reduces the use of dynamic kernel
 memory  significantly. (about 10X)
 
 Exception codes broken into classes and renumbered.  Be sure to
 recompile all  code that includes acexcep.h.  Hopefully we won't
 have to renumber the codes  again now that they are split into
 classes (environment, programmer, AML code,  ACPI table, and
 internal).
 
 Fixed some additional alignment issues in the Resource Manager
 subcomponent
 
 Implemented semaphore tracking in the AcpiExec utility, and fixed
 several places  where mutexes/semaphores were being unlocked
 without a corresponding lock  operation.  There are no known
 semaphore or mutex "leaks" at this time.
 
 Fixed the case where an ASL Return operator is used to return an
 unnamed  package.
 
 -------------------------------------------
 Summary of changes for this label: 07_28_00
 
 Fixed a problem with the way addresses were calculated in
 AcpiAmlReadFieldData()  and AcpiAmlWriteFieldData(). This problem
 manifested itself when a Field was  created with WordAccess or
 DwordAccess, but the field unit defined within the  Field was less
 
 than a Word or Dword.
 
 Fixed a problem in AmlDumpOperands() module's loop to pull
 operands off of the  operand stack to display information. The
 problem manifested itself as a TLB  error on 64-bit systems when
 accessing an operand stack with two or more  operands.
 
 Fixed a problem with the PCI configuration space handlers where
 context was  getting confused between accesses. This required a
 change to the generic address  space handler and address space
 setup definitions. Handlers now get both a  global handler context
 (this is the one passed in by the user when executing
 AcpiInstallAddressSpaceHandler() and a specific region context
 that is unique to  each region (For example, the _ADR, _SEG and
 _BBN values associated with a  specific region). The generic
 function definitions have changed to the  following:
 
 typedef ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( UINT32 Function,
 UINT32 Address, UINT32 BitWidth, UINT32 *Value, void
 *HandlerContext, // This used to be void *Context void
 *RegionContext); // This is an additional parameter
 
 typedef ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( ACPI_HANDLE
 RegionHandle, UINT32 Function, void *HandlerContext,  void
 **RegionContext); // This used to be **ReturnContext
 
 -------------------------------------------
 Summary of changes for this label: 07_21_00
 
 Major file consolidation and rename.  All files within the
 interpreter have been  renamed as well as most header files.  This
 was done to prevent collisions with  existing files in the host
 OSs -- filenames such as "config.h" and "global.h"  seem to be
 quite common.  The VC project files have been updated.  All
 makefiles  will require modification.
 
 The parser/interpreter integration continues in Phase 5 with the
 implementation  of a complete 2-pass parse (the AML is parsed
 twice) for each table;  This  avoids the construction of a huge
 parse tree and therefore reduces the amount of  dynamic memory
 required by the subsystem.  Greater use of the parse object cache
 means that performance is unaffected.
 
 Many comments from the two code reviews have been rolled in.
 
 The 64-bit alignment support is complete.
 
 -------------------------------------------
 Summary of changes for this label: 06_30_00
 
 With a nod and a tip of the hat to the technology of yesteryear,
 we've added  support in the source code for 80 column output
 devices.  The code is now mostly  constrained to 80 columns or
 less to support environments and editors that 1)  cannot display
 or print more than 80 characters on a single line, and 2) cannot
 disable line wrapping.
 
 A major restructuring of the namespace data structure has been
 completed.  The  result is 1) cleaner and more
 understandable/maintainable code, and 2) a  significant reduction
 in the dynamic memory requirement for each named ACPI  object
 (almost half).
 
 -------------------------------------------
 Summary of changes for this label: 06_23_00
 
 Linux support has been added.  In order to obtain approval to get
 the ACPI CA  subsystem into the Linux kernel, we've had to make
 quite a few changes to the  base subsystem that will affect all
 users (all the changes are generic and OS- independent).  The
 effects of these global changes have been somewhat far  reaching.
 Files have been merged and/or renamed and interfaces have been
 renamed.   The major changes are described below.
 
 Osd* interfaces renamed to AcpiOs* to eliminate namespace
 pollution/confusion  within our target kernels.  All OSD
 interfaces must be modified to match the new  naming convention.
 
 Files merged across the subsystem.  A number of the smaller source
 and header  files have been merged to reduce the file count and
 increase the density of the  existing files.  There are too many
 to list here.  In general, makefiles that  call out individual
 files will require rebuilding.
 
 Interpreter files renamed.  All interpreter files now have the
 prefix am*  instead of ie* and is*.
 
 Header files renamed:  The acapi.h file is now acpixf.h.  The
 acpiosd.h file is  now acpiosxf.h.  We are removing references to
 the acronym "API" since it is  somewhat windowsy. The new name is
 "external interface" or xface or xf in the  filenames.j
 
 
 All manifest constants have been forced to upper case (some were
 mixed case.)   Also, the string "ACPI_" has been prepended to many
 (not all) of the constants,  typedefs, and structs.
 
 The globals "DebugLevel" and "DebugLayer" have been renamed
 "AcpiDbgLevel" and  "AcpiDbgLayer" respectively.
 
 All other globals within the subsystem are now prefixed with
 "AcpiGbl_" Internal procedures within the subsystem are now
 prefixed with "Acpi" (with only  a few exceptions).  The original
 two-letter abbreviation for the subcomponent  remains after "Acpi"
 - for example, CmCallocate became AcpiCmCallocate.
 
 Added a source code translation/conversion utility.  Used to
 generate the Linux  source code, it can be modified to generate
 other types of source as well. Can  also be used to cleanup
 existing source by removing extraneous spaces and blank  lines.
 Found in tools/acpisrc/*
 
 OsdUnMapMemory was renamed to OsdUnmapMemory and then
 AcpiOsUnmapMemory.  (UnMap  became Unmap).
 
 A "MaxUnits" parameter has been added to AcpiOsCreateSemaphore.
 When set to  one, this indicates that the caller wants to use the
 
 semaphore as a mutex, not a  counting semaphore.  ACPI CA uses
 both types.  However, implementers of this  call may want to use
 different OS primitives depending on the type of semaphore
 requested.  For example, some operating systems provide separate
 
 "mutex" and  "semaphore" interfaces - where the mutex interface is
 much faster because it  doesn't have all the overhead of a full
 semaphore implementation.
 
 Fixed a deadlock problem where a method that accesses the PCI
 address space can  block forever if it is the first access to the
 space.
 
 -------------------------------------------
 Summary of changes for this label: 06_02_00
 
 Support for environments that cannot handle unaligned data
 accesses (e.g.  firmware and OS environments devoid of alignment
 handler technology namely  SAL/EFI and the IA-64 Linux kernel) has
 been added (via configurable macros) in  these three areas: -
 Transfer of data from the raw AML byte stream is done via byte
 moves instead of    word/dword/qword moves. - External objects are
 aligned within the user buffer, including package   elements (sub-
 objects). - Conversion of name strings to UINT32 Acpi Names is now
 done byte-wise.
 
 The Store operator was modified to mimic Microsoft's
 implementation when storing  to a Buffer Field.
 
 Added a check of the BM_STS bit before entering C3.
 
 The methods subdirectory has been obsoleted and removed.  A new
 file, cmeval.c  subsumes the functionality.
 
 A 16-bit (DOS) version of AcpiExec has been developed.  The
 makefile is under  the acpiexec directory.

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/changes.txt
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/changes.txt:r249197-249698
   Merged /vendor-sys/acpica/dist/changes.txt:r249111-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslpredef.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslpredef.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslpredef.c	(revision 249699)
@@ -1,760 +1,761 @@
 /******************************************************************************
  *
  * Module Name: aslpredef - support for ACPI predefined names
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define ACPI_CREATE_PREDEFINED_TABLE
 #define ACPI_CREATE_RESOURCE_TABLE
 
 #include 
 #include "aslcompiler.y.h"
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_COMPILER
         ACPI_MODULE_NAME    ("aslpredef")
 
 
 /* Local prototypes */
 
 static void
 ApCheckForUnexpectedReturnValue (
     ACPI_PARSE_OBJECT       *Op,
     ASL_METHOD_INFO         *MethodInfo);
 
 static UINT32
 ApCheckForSpecialName (
     ACPI_PARSE_OBJECT       *Op,
     char                    *Name);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckForPredefinedMethod
  *
  * PARAMETERS:  Op              - A parse node of type "METHOD".
  *              MethodInfo      - Saved info about this method
  *
  * RETURN:      None
  *
  * DESCRIPTION: If method is a predefined name, check that the number of
  *              arguments and the return type (returns a value or not)
  *              is correct.
  *
  ******************************************************************************/
 
 BOOLEAN
 ApCheckForPredefinedMethod (
     ACPI_PARSE_OBJECT       *Op,
     ASL_METHOD_INFO         *MethodInfo)
 {
     UINT32                      Index;
     UINT32                      RequiredArgCount;
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     /* Check for a match against the predefined name list */
 
     Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
 
     switch (Index)
     {
     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
 
         /* Just return, nothing to do */
         return (FALSE);
 
 
     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
 
         Gbl_ReservedMethods++;
 
         /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */
 
         if (MethodInfo->NumArguments != 0)
         {
             sprintf (MsgBuffer, "%s requires %u", Op->Asl.ExternalName, 0);
 
             AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
                 MsgBuffer);
         }
         break;
 
 
     default:
         /*
-         * Matched a predefined method name
+         * Matched a predefined method name - validate the ASL-defined
+         * argument count against the ACPI specification.
          *
-         * Validate the ASL-defined argument count. Allow two different legal
-         * arg counts.
+         * Some methods are allowed to have a "minimum" number of args
+         * (_SCP) because their definition in ACPI has changed over time.
          */
         Gbl_ReservedMethods++;
         ThisName = &AcpiGbl_PredefinedMethods[Index];
-        RequiredArgCount = ThisName->Info.ArgumentList & METHOD_ARG_MASK;
+        RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList);
 
         if (MethodInfo->NumArguments != RequiredArgCount)
         {
             sprintf (MsgBuffer, "%4.4s requires %u",
                 ThisName->Info.Name, RequiredArgCount);
 
-            if ((MethodInfo->NumArguments > RequiredArgCount) &&
-                !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
+            if (MethodInfo->NumArguments < RequiredArgCount)
             {
-                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
+                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
                     MsgBuffer);
             }
-            else
+            else if ((MethodInfo->NumArguments > RequiredArgCount) &&
+                !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
             {
-                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
+                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
                     MsgBuffer);
             }
         }
 
         /*
          * Check if method returns no value, but the predefined name is
          * required to return a value
          */
         if (MethodInfo->NumReturnNoValue &&
             ThisName->Info.ExpectedBtypes)
         {
             AcpiUtGetExpectedReturnTypes (StringBuffer,
                 ThisName->Info.ExpectedBtypes);
 
             sprintf (MsgBuffer, "%s required for %4.4s",
                 StringBuffer, ThisName->Info.Name);
 
             AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
                 MsgBuffer);
         }
         break;
     }
 
     return (TRUE);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckForUnexpectedReturnValue
  *
  * PARAMETERS:  Op              - A parse node of type "RETURN".
  *              MethodInfo      - Saved info about this method
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check for an unexpected return value from a predefined method.
  *              Invoked for predefined methods that are defined to not return
  *              any value. If there is a return value, issue a remark, since
  *              the ASL writer may be confused as to the method definition
  *              and/or functionality.
  *
  * Note: We ignore all return values of "Zero", since this is what a standalone
  *       Return() statement will always generate -- so we ignore it here --
  *       i.e., there is no difference between Return() and Return(Zero).
  *       Also, a null Return() will be disassembled to return(Zero) -- so, we
  *       don't want to generate extraneous remarks/warnings for a disassembled
  *       ASL file.
  *
  ******************************************************************************/
 
 static void
 ApCheckForUnexpectedReturnValue (
     ACPI_PARSE_OBJECT       *Op,
     ASL_METHOD_INFO         *MethodInfo)
 {
     ACPI_PARSE_OBJECT       *ReturnValueOp;
 
 
     /* Ignore Return() and Return(Zero) (they are the same) */
 
     ReturnValueOp = Op->Asl.Child;
     if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
     {
         return;
     }
 
     /* We have a valid return value, but the reserved name did not expect it */
 
     AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
         Op, MethodInfo->Op->Asl.ExternalName);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckPredefinedReturnValue
  *
  * PARAMETERS:  Op              - A parse node of type "RETURN".
  *              MethodInfo      - Saved info about this method
  *
  * RETURN:      None
  *
  * DESCRIPTION: If method is a predefined name, attempt to validate the return
  *              value. Only "static" types can be validated - a simple return
  *              of an integer/string/buffer/package or a named reference to
  *              a static object. Values such as a Localx or Argx or a control
  *              method invocation are not checked. Issue a warning if there is
  *              a valid return value, but the reserved method defines no
  *              return value.
  *
  ******************************************************************************/
 
 void
 ApCheckPredefinedReturnValue (
     ACPI_PARSE_OBJECT       *Op,
     ASL_METHOD_INFO         *MethodInfo)
 {
     UINT32                      Index;
     ACPI_PARSE_OBJECT           *ReturnValueOp;
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     /* Check parent method for a match against the predefined name list */
 
     Index = ApCheckForPredefinedName (MethodInfo->Op,
                 MethodInfo->Op->Asl.NameSeg);
 
     switch (Index)
     {
     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
 
         /* No return value expected, warn if there is one */
 
         ApCheckForUnexpectedReturnValue (Op, MethodInfo);
         return;
 
     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
 
         /* Just return, nothing to do */
         return;
 
     default: /* A standard predefined ACPI name */
 
         ThisName = &AcpiGbl_PredefinedMethods[Index];
         if (!ThisName->Info.ExpectedBtypes)
         {
             /* No return value expected, warn if there is one */
 
             ApCheckForUnexpectedReturnValue (Op, MethodInfo);
             return;
         }
 
         /* Get the object returned, it is the next argument */
 
         ReturnValueOp = Op->Asl.Child;
         switch (ReturnValueOp->Asl.ParseOpcode)
         {
         case PARSEOP_ZERO:
         case PARSEOP_ONE:
         case PARSEOP_ONES:
         case PARSEOP_INTEGER:
         case PARSEOP_STRING_LITERAL:
         case PARSEOP_BUFFER:
         case PARSEOP_PACKAGE:
 
             /* Static data return object - check against expected type */
 
             ApCheckObjectType (ThisName->Info.Name, ReturnValueOp,
                 ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
 
             /* For packages, check the individual package elements */
 
             if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
             {
                 ApCheckPackage (ReturnValueOp, ThisName);
             }
             break;
 
         default:
 
             /*
              * All other ops are very difficult or impossible to typecheck at
              * compile time. These include all Localx, Argx, and method
              * invocations. Also, NAMESEG and NAMESTRING because the type of
              * any named object can be changed at runtime (for example,
              * CopyObject will change the type of the target object.)
              */
             break;
         }
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckForPredefinedObject
  *
  * PARAMETERS:  Op              - A parse node
  *              Name            - The ACPI name to be checked
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check for a predefined name for a static object (created via
  *              the ASL Name operator). If it is a predefined ACPI name, ensure
  *              that the name does not require any arguments (which would
  *              require a control method implemenation of the name), and that
  *              the type of the object is one of the expected types for the
  *              predefined name.
  *
  ******************************************************************************/
 
 void
 ApCheckForPredefinedObject (
     ACPI_PARSE_OBJECT       *Op,
     char                    *Name)
 {
     UINT32                      Index;
     ACPI_PARSE_OBJECT           *ObjectOp;
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     /*
      * Check for a real predefined name -- not a resource descriptor name
      * or a predefined scope name
      */
     Index = ApCheckForPredefinedName (Op, Name);
 
     switch (Index)
     {
     case ACPI_NOT_RESERVED_NAME:        /* No underscore or _Txx or _xxx name not matched */
     case ACPI_PREDEFINED_NAME:          /* Resource Name or reserved scope name */
     case ACPI_COMPILER_RESERVED_NAME:   /* A _Txx that was not emitted by compiler */
 
         /* Nothing to do */
         return;
 
     case ACPI_EVENT_RESERVED_NAME:      /* _Lxx/_Exx/_Wxx/_Qxx methods */
 
         /*
          * These names must be control methods, by definition in ACPI spec.
          * Also because they are defined to return no value. None of them
          * require any arguments.
          */
         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
             "with zero arguments");
         return;
 
     default:
         break;
     }
 
     /* A standard predefined ACPI name */
 
     /*
      * If this predefined name requires input arguments, then
      * it must be implemented as a control method
      */
     ThisName = &AcpiGbl_PredefinedMethods[Index];
-    if ((ThisName->Info.ArgumentList & METHOD_ARG_MASK) > 0)
+    if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0)
     {
         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
             "with arguments");
         return;
     }
 
     /*
      * If no return value is expected from this predefined name, then
      * it follows that it must be implemented as a control method
      * (with zero args, because the args > 0 case was handled above)
      * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx
      */
     if (!ThisName->Info.ExpectedBtypes)
     {
         AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
             "with zero arguments");
         return;
     }
 
     /* Typecheck the actual object, it is the next argument */
 
     ObjectOp = Op->Asl.Child->Asl.Next;
     ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next,
         ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
 
     /* For packages, check the individual package elements */
 
     if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
     {
         ApCheckPackage (ObjectOp, ThisName);
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckForPredefinedName
  *
  * PARAMETERS:  Op              - A parse node
  *              Name            - NameSeg to check
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check a NameSeg against the reserved list.
  *
  ******************************************************************************/
 
 UINT32
 ApCheckForPredefinedName (
     ACPI_PARSE_OBJECT       *Op,
     char                    *Name)
 {
     UINT32                      i;
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     if (Name[0] == 0)
     {
         AcpiOsPrintf ("Found a null name, external = %s\n",
             Op->Asl.ExternalName);
     }
 
     /* All reserved names are prefixed with a single underscore */
 
     if (Name[0] != '_')
     {
         return (ACPI_NOT_RESERVED_NAME);
     }
 
     /* Check for a standard predefined method name */
 
     ThisName = AcpiGbl_PredefinedMethods;
     for (i = 0; ThisName->Info.Name[0]; i++)
     {
         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
         {
             /* Return index into predefined array */
             return (i);
         }
 
         ThisName++; /* Does not account for extra package data, but is OK */
     }
 
     /* Check for resource names and predefined scope names */
 
     ThisName = AcpiGbl_ResourceNames;
     while (ThisName->Info.Name[0])
     {
         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
         {
             return (ACPI_PREDEFINED_NAME);
         }
 
         ThisName++;
     }
 
     ThisName = AcpiGbl_ScopeNames;
     while (ThisName->Info.Name[0])
     {
         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
         {
             return (ACPI_PREDEFINED_NAME);
         }
 
         ThisName++;
     }
 
     /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */
 
     return (ApCheckForSpecialName (Op, Name));
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckForSpecialName
  *
  * PARAMETERS:  Op              - A parse node
  *              Name            - NameSeg to check
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check for the "special" predefined names -
  *              _Lxx, _Exx, _Qxx, _Wxx, and _T_x
  *
  ******************************************************************************/
 
 static UINT32
 ApCheckForSpecialName (
     ACPI_PARSE_OBJECT       *Op,
     char                    *Name)
 {
 
     /*
      * Check for the "special" predefined names. We already know that the
      * first character is an underscore.
      *   GPE:  _Lxx
      *   GPE:  _Exx
      *   GPE:  _Wxx
      *   EC:   _Qxx
      */
     if ((Name[1] == 'L') ||
         (Name[1] == 'E') ||
         (Name[1] == 'W') ||
         (Name[1] == 'Q'))
     {
         /* The next two characters must be hex digits */
 
         if ((isxdigit ((int) Name[2])) &&
             (isxdigit ((int) Name[3])))
         {
             return (ACPI_EVENT_RESERVED_NAME);
         }
     }
 
     /* Check for the names reserved for the compiler itself: _T_x */
 
     else if ((Op->Asl.ExternalName[1] == 'T') &&
              (Op->Asl.ExternalName[2] == '_'))
     {
         /* Ignore if actually emitted by the compiler */
 
         if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED)
         {
             return (ACPI_NOT_RESERVED_NAME);
         }
 
         /*
          * Was not actually emitted by the compiler. This is a special case,
          * however. If the ASL code being compiled was the result of a
          * dissasembly, it may possibly contain valid compiler-emitted names
          * of the form "_T_x". We don't want to issue an error or even a
          * warning and force the user to manually change the names. So, we
          * will issue a remark instead.
          */
         AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName);
         return (ACPI_COMPILER_RESERVED_NAME);
     }
 
     /*
      * The name didn't match any of the known predefined names. Flag it as a
      * warning, since the entire namespace starting with an underscore is
      * reserved by the ACPI spec.
      */
     AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op,
         Op->Asl.ExternalName);
 
     return (ACPI_NOT_RESERVED_NAME);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckObjectType
  *
  * PARAMETERS:  PredefinedName  - Name of the predefined object we are checking
  *              Op              - Current parse node
  *              ExpectedBtypes  - Bitmap of expected return type(s)
  *              PackageIndex    - Index of object within parent package (if
  *                                applicable - ACPI_NOT_PACKAGE_ELEMENT
  *                                otherwise)
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check if the object type is one of the types that is expected
  *              by the predefined name. Only a limited number of object types
  *              can be returned by the predefined names.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 ApCheckObjectType (
     const char              *PredefinedName,
     ACPI_PARSE_OBJECT       *Op,
     UINT32                  ExpectedBtypes,
     UINT32                  PackageIndex)
 {
     UINT32                  ReturnBtype;
     char                    *TypeName;
 
 
     if (!Op)
     {
         return (AE_TYPE);
     }
 
     /* Map the parse opcode to a bitmapped return type (RTYPE) */
 
     switch (Op->Asl.ParseOpcode)
     {
     case PARSEOP_ZERO:
     case PARSEOP_ONE:
     case PARSEOP_ONES:
     case PARSEOP_INTEGER:
         ReturnBtype = ACPI_RTYPE_INTEGER;
         TypeName = "Integer";
         break;
 
     case PARSEOP_STRING_LITERAL:
         ReturnBtype = ACPI_RTYPE_STRING;
         TypeName = "String";
         break;
 
     case PARSEOP_BUFFER:
         ReturnBtype = ACPI_RTYPE_BUFFER;
         TypeName = "Buffer";
         break;
 
     case PARSEOP_PACKAGE:
     case PARSEOP_VAR_PACKAGE:
         ReturnBtype = ACPI_RTYPE_PACKAGE;
         TypeName = "Package";
         break;
 
     case PARSEOP_NAMESEG:
     case PARSEOP_NAMESTRING:
         ReturnBtype = ACPI_RTYPE_REFERENCE;
         TypeName = "Reference";
         break;
 
     default:
         /* Not one of the supported object types */
 
         TypeName = UtGetOpName (Op->Asl.ParseOpcode);
         goto TypeErrorExit;
     }
 
     /* Exit if the object is one of the expected types */
 
     if (ReturnBtype & ExpectedBtypes)
     {
         return (AE_OK);
     }
 
 
 TypeErrorExit:
 
     /* Format the expected types and emit an error message */
 
     AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes);
 
     if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
     {
         sprintf (MsgBuffer, "%4.4s: found %s, %s required",
             PredefinedName, TypeName, StringBuffer);
     }
     else
     {
         sprintf (MsgBuffer, "%4.4s: found %s at index %u, %s required",
             PredefinedName, TypeName, PackageIndex, StringBuffer);
     }
 
     AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer);
     return (AE_TYPE);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApDisplayReservedNames
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Dump information about the ACPI predefined names and predefined
  *              resource descriptor names.
  *
  ******************************************************************************/
 
 void
 ApDisplayReservedNames (
     void)
 {
     const ACPI_PREDEFINED_INFO  *ThisName;
     UINT32                      Count;
     UINT32                      NumTypes;
 
 
     /*
      * Predefined names/methods
      */
     printf ("\nPredefined Name Information\n\n");
 
     Count = 0;
     ThisName = AcpiGbl_PredefinedMethods;
     while (ThisName->Info.Name[0])
     {
         AcpiUtDisplayPredefinedMethod (MsgBuffer, ThisName, FALSE);
         Count++;
         ThisName = AcpiUtGetNextPredefinedMethod (ThisName);
     }
 
     printf ("%u Predefined Names are recognized\n", Count);
 
     /*
      * Resource Descriptor names
      */
     printf ("\nPredefined Names for Resource Descriptor Fields\n\n");
 
     Count = 0;
     ThisName = AcpiGbl_ResourceNames;
     while (ThisName->Info.Name[0])
     {
         NumTypes = AcpiUtGetResourceBitWidth (MsgBuffer,
             ThisName->Info.ArgumentList);
 
         printf ("%4.4s    Field is %s bits wide%s\n",
             ThisName->Info.Name, MsgBuffer,
             (NumTypes > 1) ? " (depending on descriptor type)" : "");
 
         Count++;
         ThisName++;
     }
 
     printf ("%u Resource Descriptor Field Names are recognized\n", Count);
 
     /*
      * Predefined scope names
      */
     printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n");
 
     ThisName = AcpiGbl_ScopeNames;
     while (ThisName->Info.Name[0])
     {
         printf ("%4.4s    Scope/Device\n", ThisName->Info.Name);
         ThisName++;
     }
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslprepkg.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslprepkg.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/compiler/aslprepkg.c	(revision 249699)
@@ -1,681 +1,682 @@
 /******************************************************************************
  *
  * Module Name: aslprepkg - support for ACPI predefined name package objects
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #include 
 #include "aslcompiler.y.h"
 #include 
 
 
 #define _COMPONENT          ACPI_COMPILER
         ACPI_MODULE_NAME    ("aslprepkg")
 
 
 /* Local prototypes */
 
 static void
 ApCheckPackageElements (
-    const char              *PredefinedName,
-    ACPI_PARSE_OBJECT       *Op,
-    UINT8                   Type1,
-    UINT32                  Count1,
-    UINT8                   Type2,
-    UINT32                  Count2);
+    const char                  *PredefinedName,
+    ACPI_PARSE_OBJECT           *Op,
+    UINT8                       Type1,
+    UINT32                      Count1,
+    UINT8                       Type2,
+    UINT32                      Count2);
 
 static void
 ApCheckPackageList (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *ParentOp,
     const ACPI_PREDEFINED_INFO  *Package,
     UINT32                      StartIndex,
     UINT32                      Count);
 
 static void
 ApPackageTooSmall (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op,
     UINT32                      Count,
     UINT32                      ExpectedCount);
 
 static void
 ApZeroLengthPackage (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op);
 
 static void
 ApPackageTooLarge (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op,
     UINT32                      Count,
     UINT32                      ExpectedCount);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckPackage
  *
- * PARAMETERS:  ParentOp        - Parser op for the package
- *              Predefined      - Pointer to package-specific info for method
+ * PARAMETERS:  ParentOp            - Parser op for the package
+ *              Predefined          - Pointer to package-specific info for
+ *                                    the method
  *
  * RETURN:      None
  *
  * DESCRIPTION: Top-level validation for predefined name return package
  *              objects.
  *
  ******************************************************************************/
 
 void
 ApCheckPackage (
     ACPI_PARSE_OBJECT           *ParentOp,
     const ACPI_PREDEFINED_INFO  *Predefined)
 {
     ACPI_PARSE_OBJECT           *Op;
     const ACPI_PREDEFINED_INFO  *Package;
     ACPI_STATUS                 Status;
     UINT32                      ExpectedCount;
     UINT32                      Count;
     UINT32                      i;
 
 
     /* The package info for this name is in the next table entry */
 
     Package = Predefined + 1;
 
     /* First child is the package length */
 
     Op = ParentOp->Asl.Child;
     Count = (UINT32) Op->Asl.Value.Integer;
 
     /*
      * Many of the variable-length top-level packages are allowed to simply
      * have zero elements. This allows the BIOS to tell the host that even
      * though the predefined name/method exists, the feature is not supported.
      * Other package types require one or more elements. In any case, there
      * is no need to continue validation.
      */
     if (!Count)
     {
         switch (Package->RetInfo.Type)
         {
         case ACPI_PTYPE1_FIXED:
         case ACPI_PTYPE1_OPTION:
         case ACPI_PTYPE2_PKG_COUNT:
         case ACPI_PTYPE2_REV_FIXED:
 
             ApZeroLengthPackage (Predefined->Info.Name, ParentOp);
             break;
 
         case ACPI_PTYPE1_VAR:
         case ACPI_PTYPE2:
         case ACPI_PTYPE2_COUNT:
         case ACPI_PTYPE2_FIXED:
         case ACPI_PTYPE2_MIN:
         case ACPI_PTYPE2_FIX_VAR:
         default:
 
             break;
         }
 
         return;
     }
 
     /* Get the first element of the package */
 
     Op = Op->Asl.Next;
 
     /* Decode the package type */
 
     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)
         {
             ApPackageTooLarge (Predefined->Info.Name, ParentOp,
                 Count, ExpectedCount);
         }
 
         /* Validate all elements of the package */
 
         ApCheckPackageElements (Predefined->Info.Name, Op,
             Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
             Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
         break;
 
     case ACPI_PTYPE1_VAR:
         /*
-         * The package count is variable, there are no sub-packages, and all
-         * elements must be of the same type
+         * 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++)
         {
             ApCheckObjectType (Predefined->Info.Name, Op,
                 Package->RetInfo.ObjectType1, i);
             Op = Op->Asl.Next;
         }
         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.
+         * 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) */
 
                 ApCheckObjectType (Predefined->Info.Name, Op,
                     Package->RetInfo3.ObjectType[i], i);
             }
             else
             {
                 /* These are the optional package elements */
 
                 ApCheckObjectType (Predefined->Info.Name, Op,
                     Package->RetInfo3.TailObjectType, i);
             }
             Op = Op->Asl.Next;
         }
         break;
 
     case ACPI_PTYPE2_REV_FIXED:
 
         /* First element is the (Integer) revision */
 
         ApCheckObjectType (Predefined->Info.Name, Op,
             ACPI_RTYPE_INTEGER, 0);
 
         Op = Op->Asl.Next;
         Count--;
 
         /* Examine the sub-packages */
 
         ApCheckPackageList (Predefined->Info.Name, Op,
             Package, 1, Count);
         break;
 
     case ACPI_PTYPE2_PKG_COUNT:
 
         /* First element is the (Integer) count of sub-packages to follow */
 
         Status = ApCheckObjectType (Predefined->Info.Name, Op,
             ACPI_RTYPE_INTEGER, 0);
 
         /* We must have an integer count from above (otherwise, use Count) */
 
         if (ACPI_SUCCESS (Status))
         {
             /*
-             * Count cannot be larger than the parent package length, but allow it
-             * to be smaller. The >= accounts for the Integer above.
+             * Count cannot be larger than the parent package length, but
+             * allow it to be smaller. The >= accounts for the Integer above.
              */
             ExpectedCount = (UINT32) Op->Asl.Value.Integer;
             if (ExpectedCount >= Count)
             {
                 goto PackageTooSmall;
             }
 
             Count = ExpectedCount;
         }
 
         Op = Op->Asl.Next;
 
         /* Examine the sub-packages */
 
         ApCheckPackageList (Predefined->Info.Name, Op,
             Package, 1, Count);
         break;
 
     case ACPI_PTYPE2:
     case ACPI_PTYPE2_FIXED:
     case ACPI_PTYPE2_MIN:
     case ACPI_PTYPE2_COUNT:
     case ACPI_PTYPE2_FIX_VAR:
         /*
          * These types all return a single Package that consists of a
          * variable number of sub-Packages.
          */
 
         /* Examine the sub-packages */
 
         ApCheckPackageList (Predefined->Info.Name, Op,
             Package, 0, Count);
         break;
 
     default:
         return;
     }
 
     return;
 
 PackageTooSmall:
     ApPackageTooSmall (Predefined->Info.Name, ParentOp,
         Count, ExpectedCount);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckPackageElements
  *
- * PARAMETERS:  PredefinedName  - Pointer to validation data structure
- *              Op              - Parser op for the package
- *              Type1           - Object type for first group
- *              Count1          - Count for first group
- *              Type2           - Object type for second group
- *              Count2          - Count for second group
+ * PARAMETERS:  PredefinedName      - Name of the predefined object
+ *              Op                  - Parser op for the package
+ *              Type1               - Object type for first group
+ *              Count1              - Count for first group
+ *              Type2               - Object type for second group
+ *              Count2              - Count for second group
  *
  * RETURN:      None
  *
  * DESCRIPTION: Validate all elements of a package. Works with packages that
  *              are defined to contain up to two groups of different object
  *              types.
  *
  ******************************************************************************/
 
 static void
 ApCheckPackageElements (
     const char              *PredefinedName,
     ACPI_PARSE_OBJECT       *Op,
     UINT8                   Type1,
     UINT32                  Count1,
     UINT8                   Type2,
     UINT32                  Count2)
 {
     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.
      *
      * Aborts check upon a NULL package element, as this means (at compile
      * time) that the remainder of the package elements are also NULL
      * (This is the only way to create NULL package elements.)
      */
     for (i = 0; (i < Count1) && Op; i++)
     {
         ApCheckObjectType (PredefinedName, Op, Type1, i);
         Op = Op->Asl.Next;
     }
 
     for (i = 0; (i < Count2) && Op; i++)
     {
         ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1));
         Op = Op->Asl.Next;
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApCheckPackageList
  *
  * PARAMETERS:  PredefinedName      - Name of the predefined object
  *              ParentOp            - Parser op of the parent package
  *              Package             - Package info for this predefined name
  *              StartIndex          - Index in parent package where list begins
  *              ParentCount         - Element count of parent package
  *
  * RETURN:      None
  *
  * DESCRIPTION: Validate the individual package elements for a predefined name.
  *              Handles the cases where the predefined name is defined as a
  *              Package of Packages (subpackages). These are the types:
  *
  *              ACPI_PTYPE2
  *              ACPI_PTYPE2_FIXED
  *              ACPI_PTYPE2_MIN
  *              ACPI_PTYPE2_COUNT
  *              ACPI_PTYPE2_FIX_VAR
  *
  ******************************************************************************/
 
 static void
 ApCheckPackageList (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *ParentOp,
     const ACPI_PREDEFINED_INFO  *Package,
     UINT32                      StartIndex,
     UINT32                      ParentCount)
 {
     ACPI_PARSE_OBJECT           *SubPackageOp = ParentOp;
     ACPI_PARSE_OBJECT           *Op;
     ACPI_STATUS                 Status;
     UINT32                      Count;
     UINT32                      ExpectedCount;
     UINT32                      i;
     UINT32                      j;
 
 
     /*
      * Validate each subpackage in the parent Package
      *
      * Note: We ignore NULL package elements on the assumption that
      * they will be initialized by the BIOS or other ASL code.
      */
     for (i = 0; (i < ParentCount) && SubPackageOp; i++)
     {
         /* Each object in the list must be of type Package */
 
         Status = ApCheckObjectType (PredefinedName, SubPackageOp,
             ACPI_RTYPE_PACKAGE, i + StartIndex);
         if (ACPI_FAILURE (Status))
         {
             goto NextSubpackage;
         }
 
         /* Examine the different types of expected subpackages */
 
         Op = SubPackageOp->Asl.Child;
 
         /* First child is the package length */
 
         Count = (UINT32) Op->Asl.Value.Integer;
         Op = Op->Asl.Next;
 
         /* The subpackage must have at least one element */
 
         if (!Count)
         {
             ApZeroLengthPackage (PredefinedName, SubPackageOp);
             goto NextSubpackage;
         }
 
         /*
          * Decode the package type.
          * PTYPE2 indicates that a "package of packages" is expected for
          * this name. The various flavors of PTYPE2 indicate the number
          * and format of the subpackages.
          */
         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 (Count < ExpectedCount)
             {
                 ApPackageTooSmall (PredefinedName, SubPackageOp,
                     Count, ExpectedCount);
                 break;
             }
 
             ApCheckPackageElements (PredefinedName, Op,
                 Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
                 Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
             break;
 
         case ACPI_PTYPE2_FIX_VAR:
             /*
              * Each subpackage has a fixed number of elements and an
              * optional element
              */
             ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
             if (Count < ExpectedCount)
             {
                 ApPackageTooSmall (PredefinedName, SubPackageOp,
                     Count, ExpectedCount);
                 break;
             }
 
             ApCheckPackageElements (PredefinedName, Op,
                 Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
                 Package->RetInfo.ObjectType2,
                 Count - Package->RetInfo.Count1);
             break;
 
         case ACPI_PTYPE2_FIXED:
 
             /* Each sub-package has a fixed length */
 
             ExpectedCount = Package->RetInfo2.Count;
             if (Count < ExpectedCount)
             {
                 ApPackageTooSmall (PredefinedName, SubPackageOp,
                     Count, ExpectedCount);
                 break;
             }
 
             /* Check each object/type combination */
 
             for (j = 0; j < ExpectedCount; j++)
             {
                 ApCheckObjectType (PredefinedName, Op,
                     Package->RetInfo2.ObjectType[j], j);
 
                 Op = Op->Asl.Next;
             }
             break;
 
         case ACPI_PTYPE2_MIN:
 
             /* Each sub-package has a variable but minimum length */
 
             ExpectedCount = Package->RetInfo.Count1;
             if (Count < ExpectedCount)
             {
                 ApPackageTooSmall (PredefinedName, SubPackageOp,
                     Count, ExpectedCount);
                 break;
             }
 
             /* Check the type of each sub-package element */
 
             ApCheckPackageElements (PredefinedName, Op,
                 Package->RetInfo.ObjectType1, Count, 0, 0);
             break;
 
         case ACPI_PTYPE2_COUNT:
             /*
              * First element is the (Integer) count of elements, including
              * the count field (the ACPI name is NumElements)
              */
             Status = ApCheckObjectType (PredefinedName, Op,
                 ACPI_RTYPE_INTEGER, 0);
 
             /* We must have an integer count from above (otherwise, use Count) */
 
             if (ACPI_SUCCESS (Status))
             {
                 /*
                  * Make sure package is large enough for the Count and is
                  * is as large as the minimum size
                  */
                 ExpectedCount = (UINT32) Op->Asl.Value.Integer;
 
                 if (Count < ExpectedCount)
                 {
                     ApPackageTooSmall (PredefinedName, SubPackageOp,
                         Count, ExpectedCount);
                     break;
                 }
                 else if (Count > ExpectedCount)
                 {
                     ApPackageTooLarge (PredefinedName, SubPackageOp,
                         Count, ExpectedCount);
                 }
 
                 /* Some names of this type have a minimum length */
 
                 if (Count < Package->RetInfo.Count1)
                 {
                     ExpectedCount = Package->RetInfo.Count1;
                     ApPackageTooSmall (PredefinedName, SubPackageOp,
                         Count, ExpectedCount);
                     break;
                 }
 
                 Count = ExpectedCount;
             }
 
             /* Check the type of each sub-package element */
 
             Op = Op->Asl.Next;
             ApCheckPackageElements (PredefinedName, Op,
                 Package->RetInfo.ObjectType1, (Count - 1), 0, 0);
             break;
 
         default:
             break;
         }
 
 NextSubpackage:
         SubPackageOp = SubPackageOp->Asl.Next;
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApPackageTooSmall
  *
  * PARAMETERS:  PredefinedName      - Name of the predefined object
  *              Op                  - Current parser op
  *              Count               - Actual package element count
  *              ExpectedCount       - Expected package element count
  *
  * RETURN:      None
  *
  * DESCRIPTION: Issue error message for a package that is smaller than
  *              required.
  *
  ******************************************************************************/
 
 static void
 ApPackageTooSmall (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op,
     UINT32                      Count,
     UINT32                      ExpectedCount)
 {
 
     sprintf (MsgBuffer, "%s: length %u, required minimum is %u",
         PredefinedName, Count, ExpectedCount);
 
     AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApZeroLengthPackage
  *
  * PARAMETERS:  PredefinedName      - Name of the predefined object
  *              Op                  - Current parser op
  *
  * RETURN:      None
  *
  * DESCRIPTION: Issue error message for a zero-length package (a package that
  *              is required to have a non-zero length). Variable length
  *              packages seem to be allowed to have zero length, however.
  *              Even if not allowed, BIOS code does it.
  *
  ******************************************************************************/
 
 static void
 ApZeroLengthPackage (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op)
 {
 
     sprintf (MsgBuffer, "%s: length is zero", PredefinedName);
 
     AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    ApPackageTooLarge
  *
  * PARAMETERS:  PredefinedName      - Name of the predefined object
  *              Op                  - Current parser op
  *              Count               - Actual package element count
  *              ExpectedCount       - Expected package element count
  *
  * RETURN:      None
  *
  * DESCRIPTION: Issue a remark for a package that is larger than expected.
  *
  ******************************************************************************/
 
 static void
 ApPackageTooLarge (
     const char                  *PredefinedName,
     ACPI_PARSE_OBJECT           *Op,
     UINT32                      Count,
     UINT32                      ExpectedCount)
 {
 
     sprintf (MsgBuffer, "%s: length is %u, only %u required",
         PredefinedName, Count, ExpectedCount);
 
     AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, MsgBuffer);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/compiler
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/compiler	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/compiler	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/compiler
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/compiler:r249111-249661
   Merged /head/sys/contrib/dev/acpica/compiler:r249197-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbdisply.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbdisply.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbdisply.c	(revision 249699)
@@ -1,1081 +1,1159 @@
 /*******************************************************************************
  *
  * Module Name: dbdisply - debug display commands
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #ifdef ACPI_DEBUGGER
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
         ACPI_MODULE_NAME    ("dbdisply")
 
 /* Local prototypes */
 
 static void
 AcpiDbDumpParserDescriptor (
     ACPI_PARSE_OBJECT       *Op);
 
 static void *
 AcpiDbGetPointer (
     void                    *Target);
 
+static ACPI_STATUS
+AcpiDbDisplayNonRootHandlers (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
 
 /*
  * System handler information.
  * Used for Handlers command, in AcpiDbDisplayHandlers.
  */
 #define ACPI_PREDEFINED_PREFIX          "%25s (%.2X) : "
 #define ACPI_HANDLER_NAME_STRING               "%30s : "
 #define ACPI_HANDLER_PRESENT_STRING                    "%-9s (%p)\n"
+#define ACPI_HANDLER_PRESENT_STRING2                   "%-9s (%p)"
 #define ACPI_HANDLER_NOT_PRESENT_STRING                "%-9s\n"
 
 /* All predefined Address Space IDs */
 
 static ACPI_ADR_SPACE_TYPE  AcpiGbl_SpaceIdList[] =
 {
     ACPI_ADR_SPACE_SYSTEM_MEMORY,
     ACPI_ADR_SPACE_SYSTEM_IO,
     ACPI_ADR_SPACE_PCI_CONFIG,
     ACPI_ADR_SPACE_EC,
     ACPI_ADR_SPACE_SMBUS,
     ACPI_ADR_SPACE_CMOS,
     ACPI_ADR_SPACE_PCI_BAR_TARGET,
     ACPI_ADR_SPACE_IPMI,
     ACPI_ADR_SPACE_GPIO,
     ACPI_ADR_SPACE_GSBUS,
     ACPI_ADR_SPACE_DATA_TABLE,
     ACPI_ADR_SPACE_FIXED_HARDWARE
 };
 
 /* Global handler information */
 
 typedef struct acpi_handler_info
 {
     void                    *Handler;
     char                    *Name;
 
 } ACPI_HANDLER_INFO;
 
 static ACPI_HANDLER_INFO    AcpiGbl_HandlerList[] =
 {
     {&AcpiGbl_GlobalNotify[0].Handler,  "System Notifications"},
     {&AcpiGbl_GlobalNotify[1].Handler,  "Device Notifications"},
     {&AcpiGbl_TableHandler,             "ACPI Table Events"},
     {&AcpiGbl_ExceptionHandler,         "Control Method Exceptions"},
     {&AcpiGbl_InterfaceHandler,         "OSI Invocations"}
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbGetPointer
  *
  * PARAMETERS:  Target          - Pointer to string to be converted
  *
  * RETURN:      Converted pointer
  *
  * DESCRIPTION: Convert an ascii pointer value to a real value
  *
  ******************************************************************************/
 
 static void *
 AcpiDbGetPointer (
     void                    *Target)
 {
     void                    *ObjPtr;
 
 
     ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16));
     return (ObjPtr);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDumpParserDescriptor
  *
  * PARAMETERS:  Op              - A parser Op descriptor
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display a formatted parser object
  *
  ******************************************************************************/
 
 static void
 AcpiDbDumpParserDescriptor (
     ACPI_PARSE_OBJECT       *Op)
 {
     const ACPI_OPCODE_INFO  *Info;
 
 
     Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
 
     AcpiOsPrintf ("Parser Op Descriptor:\n");
     AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
 
     ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
         Info->Name));
 
     AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
     AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
     AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDecodeAndDisplayObject
  *
  * PARAMETERS:  Target          - String with object to be displayed. Names
  *                                and hex pointers are supported.
  *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display a formatted ACPI object
  *
  ******************************************************************************/
 
 void
 AcpiDbDecodeAndDisplayObject (
     char                    *Target,
     char                    *OutputType)
 {
     void                    *ObjPtr;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     UINT32                  Display = DB_BYTE_DISPLAY;
     char                    Buffer[80];
     ACPI_BUFFER             RetBuf;
     ACPI_STATUS             Status;
     UINT32                  Size;
 
 
     if (!Target)
     {
         return;
     }
 
     /* Decode the output type */
 
     if (OutputType)
     {
         AcpiUtStrupr (OutputType);
         if (OutputType[0] == 'W')
         {
             Display = DB_WORD_DISPLAY;
         }
         else if (OutputType[0] == 'D')
         {
             Display = DB_DWORD_DISPLAY;
         }
         else if (OutputType[0] == 'Q')
         {
             Display = DB_QWORD_DISPLAY;
         }
     }
 
     RetBuf.Length = sizeof (Buffer);
     RetBuf.Pointer = Buffer;
 
     /* Differentiate between a number and a name */
 
     if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
     {
         ObjPtr = AcpiDbGetPointer (Target);
         if (!AcpiOsReadable (ObjPtr, 16))
         {
             AcpiOsPrintf ("Address %p is invalid in this address space\n",
                 ObjPtr);
             return;
         }
 
         /* Decode the object type */
 
         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
         {
         case ACPI_DESC_TYPE_NAMED:
 
             /* This is a namespace Node */
 
             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
             {
                 AcpiOsPrintf (
                     "Cannot read entire Named object at address %p\n", ObjPtr);
                 return;
             }
 
             Node = ObjPtr;
             goto DumpNode;
 
 
         case ACPI_DESC_TYPE_OPERAND:
 
             /* This is a ACPI OPERAND OBJECT */
 
             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
             {
                 AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n",
                     ObjPtr);
                 return;
             }
 
             AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display,
                 ACPI_UINT32_MAX);
             AcpiExDumpObjectDescriptor (ObjPtr, 1);
             break;
 
 
         case ACPI_DESC_TYPE_PARSER:
 
             /* This is a Parser Op object */
 
             if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
             {
                 AcpiOsPrintf (
                     "Cannot read entire Parser object at address %p\n", ObjPtr);
                 return;
             }
 
             AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display,
                 ACPI_UINT32_MAX);
             AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
             break;
 
 
         default:
 
             /* Is not a recognizeable object */
 
             Size = 16;
             if (AcpiOsReadable (ObjPtr, 64))
             {
                 Size = 64;
             }
 
             /* Just dump some memory */
 
             AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
             break;
         }
 
         return;
     }
 
     /* The parameter is a name string that must be resolved to a Named obj */
 
     Node = AcpiDbLocalNsLookup (Target);
     if (!Node)
     {
         return;
     }
 
 
 DumpNode:
     /* Now dump the NS node */
 
     Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could not convert name to pathname\n");
     }
 
     else
     {
         AcpiOsPrintf ("Object (%p) Pathname:  %s\n",
             Node, (char *) RetBuf.Pointer);
     }
 
     if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
     {
         AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
         return;
     }
 
     AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
         Display, ACPI_UINT32_MAX);
     AcpiExDumpNamespaceNode (Node, 1);
 
     ObjDesc = AcpiNsGetAttachedObject (Node);
     if (ObjDesc)
     {
         AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
         if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
         {
             AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
                 ObjDesc);
             return;
         }
 
         AcpiUtDebugDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT),
             Display, ACPI_UINT32_MAX);
         AcpiExDumpObjectDescriptor (ObjDesc, 1);
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayMethodInfo
  *
  * PARAMETERS:  StartOp         - Root of the control method parse tree
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display information about the current method
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayMethodInfo (
     ACPI_PARSE_OBJECT       *StartOp)
 {
     ACPI_WALK_STATE         *WalkState;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_PARSE_OBJECT       *RootOp;
     ACPI_PARSE_OBJECT       *Op;
     const ACPI_OPCODE_INFO  *OpInfo;
     UINT32                  NumOps = 0;
     UINT32                  NumOperands = 0;
     UINT32                  NumOperators = 0;
     UINT32                  NumRemainingOps = 0;
     UINT32                  NumRemainingOperands = 0;
     UINT32                  NumRemainingOperators = 0;
     BOOLEAN                 CountRemaining = FALSE;
 
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     ObjDesc = WalkState->MethodDesc;
     Node    = WalkState->MethodNode;
 
     AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
             AcpiUtGetNodeName (Node));
     AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
             (UINT32) ObjDesc->Method.ParamCount,
             (UINT32) ObjDesc->Method.SyncLevel);
 
 
     RootOp = StartOp;
     while (RootOp->Common.Parent)
     {
         RootOp = RootOp->Common.Parent;
     }
 
     Op = RootOp;
 
     while (Op)
     {
         if (Op == StartOp)
         {
             CountRemaining = TRUE;
         }
 
         NumOps++;
         if (CountRemaining)
         {
             NumRemainingOps++;
         }
 
         /* Decode the opcode */
 
         OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
         switch (OpInfo->Class)
         {
         case AML_CLASS_ARGUMENT:
             if (CountRemaining)
             {
                 NumRemainingOperands++;
             }
 
             NumOperands++;
             break;
 
         case AML_CLASS_UNKNOWN:
             /* Bad opcode or ASCII character */
 
             continue;
 
         default:
             if (CountRemaining)
             {
                 NumRemainingOperators++;
             }
 
             NumOperators++;
             break;
         }
 
         Op = AcpiPsGetDepthNext (StartOp, Op);
     }
 
     AcpiOsPrintf (
         "Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
         NumOps, NumOperators, NumOperands);
 
     AcpiOsPrintf (
         "Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
         NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayLocals
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display all locals for the currently running control method
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayLocals (
     void)
 {
     ACPI_WALK_STATE         *WalkState;
 
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     AcpiDmDisplayLocals (WalkState);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayArguments
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display all arguments for the currently running control method
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayArguments (
     void)
 {
     ACPI_WALK_STATE         *WalkState;
 
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     AcpiDmDisplayArguments (WalkState);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayResults
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display current contents of a method result stack
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayResults (
     void)
 {
     UINT32                  i;
     ACPI_WALK_STATE         *WalkState;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     UINT32                  ResultCount = 0;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_GENERIC_STATE      *Frame;
     UINT32                  Index; /* Index onto current frame */
 
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     ObjDesc = WalkState->MethodDesc;
     Node    = WalkState->MethodNode;
 
     if (WalkState->Results)
     {
         ResultCount = WalkState->ResultCount;
     }
 
     AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
             AcpiUtGetNodeName (Node), ResultCount);
 
     /* From the top element of result stack */
 
     Frame = WalkState->Results;
     Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
 
     for (i = 0; i < ResultCount; i++)
     {
         ObjDesc = Frame->Results.ObjDesc[Index];
         AcpiOsPrintf ("Result%u: ", i);
         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
         if (Index == 0)
         {
             Frame = Frame->Results.Next;
             Index = ACPI_RESULTS_FRAME_OBJ_NUM;
         }
         Index--;
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayCallingTree
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display current calling tree of nested control methods
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayCallingTree (
     void)
 {
     ACPI_WALK_STATE         *WalkState;
     ACPI_NAMESPACE_NODE     *Node;
 
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     Node = WalkState->MethodNode;
     AcpiOsPrintf ("Current Control Method Call Tree\n");
 
     while (WalkState)
     {
         Node = WalkState->MethodNode;
 
         AcpiOsPrintf ("    [%4.4s]\n", AcpiUtGetNodeName (Node));
 
         WalkState = WalkState->Next;
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayObjectType
  *
  * PARAMETERS:  Name            - User entered NS node handle or name
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display type of an arbitrary NS node
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayObjectType (
     char                    *Name)
 {
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_DEVICE_INFO        *Info;
     ACPI_STATUS             Status;
     UINT32                  i;
 
 
     Node = AcpiDbConvertToNode (Name);
     if (!Node)
     {
         return;
     }
 
     Status = AcpiGetObjectInfo (ACPI_CAST_PTR (ACPI_HANDLE, Node), &Info);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could not get object info, %s\n",
             AcpiFormatException (Status));
         return;
     }
 
     if (Info->Valid & ACPI_VALID_ADR)
     {
         AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
             ACPI_FORMAT_UINT64 (Info->Address),
             Info->CurrentStatus, Info->Flags);
     }
     if (Info->Valid & ACPI_VALID_SXDS)
     {
         AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
             Info->HighestDstates[0], Info->HighestDstates[1],
             Info->HighestDstates[2], Info->HighestDstates[3]);
     }
     if (Info->Valid & ACPI_VALID_SXWS)
     {
         AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
             Info->LowestDstates[0], Info->LowestDstates[1],
             Info->LowestDstates[2], Info->LowestDstates[3],
             Info->LowestDstates[4]);
     }
 
     if (Info->Valid & ACPI_VALID_HID)
     {
         AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
     }
     if (Info->Valid & ACPI_VALID_UID)
     {
         AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
     }
     if (Info->Valid & ACPI_VALID_SUB)
     {
         AcpiOsPrintf ("SUB: %s\n", Info->SubsystemId.String);
     }
     if (Info->Valid & ACPI_VALID_CID)
     {
         for (i = 0; i < Info->CompatibleIdList.Count; i++)
         {
             AcpiOsPrintf ("CID %u: %s\n", i,
                 Info->CompatibleIdList.Ids[i].String);
         }
     }
 
     ACPI_FREE (Info);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayResultObject
  *
  * PARAMETERS:  ObjDesc         - Object to be displayed
  *              WalkState       - Current walk state
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display the result of an AML opcode
  *
  * Note: Curently only displays the result object if we are single stepping.
  * However, this output may be useful in other contexts and could be enabled
  * to do so if needed.
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayResultObject (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     ACPI_WALK_STATE         *WalkState)
 {
 
     /* Only display if single stepping */
 
     if (!AcpiGbl_CmSingleStep)
     {
         return;
     }
 
     AcpiOsPrintf ("ResultObj: ");
     AcpiDmDisplayInternalObject (ObjDesc, WalkState);
     AcpiOsPrintf ("\n");
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayArgumentObject
  *
  * PARAMETERS:  ObjDesc         - Object to be displayed
  *              WalkState       - Current walk state
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display the result of an AML opcode
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayArgumentObject (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     ACPI_WALK_STATE         *WalkState)
 {
 
     if (!AcpiGbl_CmSingleStep)
     {
         return;
     }
 
     AcpiOsPrintf ("ArgObj:    ");
     AcpiDmDisplayInternalObject (ObjDesc, WalkState);
 }
 
 
 #if (!ACPI_REDUCED_HARDWARE)
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayGpes
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display the current GPE structures
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayGpes (
     void)
 {
     ACPI_GPE_BLOCK_INFO     *GpeBlock;
     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
     char                    *GpeType;
     ACPI_GPE_NOTIFY_INFO    *Notify;
     UINT32                  GpeIndex;
     UINT32                  Block = 0;
     UINT32                  i;
     UINT32                  j;
     UINT32                  Count;
     char                    Buffer[80];
     ACPI_BUFFER             RetBuf;
     ACPI_STATUS             Status;
 
 
     RetBuf.Length = sizeof (Buffer);
     RetBuf.Pointer = Buffer;
 
     Block = 0;
 
     /* Walk the GPE lists */
 
     GpeXruptInfo = AcpiGbl_GpeXruptListHead;
     while (GpeXruptInfo)
     {
         GpeBlock = GpeXruptInfo->GpeBlockListHead;
         while (GpeBlock)
         {
             Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
             if (ACPI_FAILURE (Status))
             {
                 AcpiOsPrintf ("Could not convert name to pathname\n");
             }
 
             if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
             {
                 GpeType = "FADT-defined GPE block";
             }
             else
             {
                 GpeType = "GPE Block Device";
             }
 
             AcpiOsPrintf ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
                 Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
 
             AcpiOsPrintf ("    Registers:    %u (%u GPEs)\n",
                 GpeBlock->RegisterCount, GpeBlock->GpeCount);
 
             AcpiOsPrintf ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
                 GpeBlock->BlockBaseNumber,
                 GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
                 GpeXruptInfo->InterruptNumber);
 
             AcpiOsPrintf (
                 "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
                 GpeBlock->RegisterInfo,
                 ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address),
                 ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address));
 
             AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
 
             /* Examine each GPE Register within the block */
 
             for (i = 0; i < GpeBlock->RegisterCount; i++)
             {
                 GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
 
                 AcpiOsPrintf (
                     "    Reg %u: (GPE %.2X-%.2X)  RunEnable %2.2X WakeEnable %2.2X"
                     " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
                     i, GpeRegisterInfo->BaseGpeNumber,
                     GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
                     GpeRegisterInfo->EnableForRun,
                     GpeRegisterInfo->EnableForWake,
                     ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address),
                     ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address));
 
                 /* Now look at the individual GPEs in this byte register */
 
                 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
                 {
                     GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
                     GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
 
                     if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
                         ACPI_GPE_DISPATCH_NONE)
                     {
                         /* This GPE is not used (no method or handler), ignore it */
 
                         continue;
                     }
 
                     AcpiOsPrintf (
                         "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
                         GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
                         GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
 
                     /* Decode the flags byte */
 
                     if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
                     {
                         AcpiOsPrintf ("Level, ");
                     }
                     else
                     {
                         AcpiOsPrintf ("Edge,  ");
                     }
 
                     if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
                     {
                         AcpiOsPrintf ("CanWake, ");
                     }
                     else
                     {
                         AcpiOsPrintf ("RunOnly, ");
                     }
 
                     switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
                     {
                     case ACPI_GPE_DISPATCH_NONE:
                         AcpiOsPrintf ("NotUsed");
                         break;
                     case ACPI_GPE_DISPATCH_METHOD:
                         AcpiOsPrintf ("Method");
                         break;
                     case ACPI_GPE_DISPATCH_HANDLER:
                         AcpiOsPrintf ("Handler");
                         break;
                     case ACPI_GPE_DISPATCH_NOTIFY:
                         Count = 0;
                         Notify = GpeEventInfo->Dispatch.NotifyList;
                         while (Notify)
                         {
                             Count++;
                             Notify = Notify->Next;
                         }
                         AcpiOsPrintf ("Implicit Notify on %u devices", Count);
                         break;
                     default:
                         AcpiOsPrintf ("UNKNOWN: %X",
                             GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
                         break;
                     }
 
                     AcpiOsPrintf (")\n");
                 }
             }
             Block++;
             GpeBlock = GpeBlock->Next;
         }
         GpeXruptInfo = GpeXruptInfo->Next;
     }
 }
 #endif /* !ACPI_REDUCED_HARDWARE */
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayHandlers
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display the currently installed global handlers
  *
  ******************************************************************************/
 
 void
 AcpiDbDisplayHandlers (
     void)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_OPERAND_OBJECT     *HandlerObj;
     ACPI_ADR_SPACE_TYPE     SpaceId;
     UINT32                  i;
 
 
     /* Operation region handlers */
 
-    AcpiOsPrintf ("\nOperation Region Handlers:\n");
+    AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");
 
     ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
     if (ObjDesc)
     {
         for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
         {
             SpaceId = AcpiGbl_SpaceIdList[i];
             HandlerObj = ObjDesc->Device.Handler;
 
             AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
                 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
 
             while (HandlerObj)
             {
                 if (AcpiGbl_SpaceIdList[i] == HandlerObj->AddressSpace.SpaceId)
                 {
                     AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
                         (HandlerObj->AddressSpace.HandlerFlags &
                             ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
                         HandlerObj->AddressSpace.Handler);
                     goto FoundHandler;
                 }
 
                 HandlerObj = HandlerObj->AddressSpace.Next;
             }
 
             /* There is no handler for this SpaceId */
 
             AcpiOsPrintf ("None\n");
 
         FoundHandler:;
         }
 
         /* Find all handlers for user-defined SpaceIDs */
 
         HandlerObj = ObjDesc->Device.Handler;
         while (HandlerObj)
         {
             if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
             {
                 AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
                     "User-defined ID", HandlerObj->AddressSpace.SpaceId);
                 AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
                     (HandlerObj->AddressSpace.HandlerFlags &
                         ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
                     HandlerObj->AddressSpace.Handler);
             }
 
             HandlerObj = HandlerObj->AddressSpace.Next;
         }
     }
 
 #if (!ACPI_REDUCED_HARDWARE)
 
     /* Fixed event handlers */
 
     AcpiOsPrintf ("\nFixed Event Handlers:\n");
 
     for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
     {
         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
         if (AcpiGbl_FixedEventHandlers[i].Handler)
         {
             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
                 AcpiGbl_FixedEventHandlers[i].Handler);
         }
         else
         {
             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
         }
     }
 
 #endif /* !ACPI_REDUCED_HARDWARE */
 
     /* Miscellaneous global handlers */
 
     AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
 
     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
     {
         AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name);
         if (AcpiGbl_HandlerList[i].Handler)
         {
             AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
                 AcpiGbl_HandlerList[i].Handler);
         }
         else
         {
             AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
         }
     }
+
+
+    /* Other handlers that are installed throughout the namespace */
+
+    AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,
+                NULL, NULL, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayNonRootHandlers
+ *
+ * PARAMETERS:  ACPI_WALK_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Display information about all handlers installed for a
+ *              device object.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbDisplayNonRootHandlers (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+    char                    *Pathname;
+
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (!ObjDesc)
+    {
+        return (AE_OK);
+    }
+
+    Pathname = AcpiNsGetExternalPathname (Node);
+    if (!Pathname)
+    {
+        return (AE_OK);
+    }
+
+    /* Display all handlers associated with this device */
+
+    HandlerObj = ObjDesc->Device.Handler;
+    while (HandlerObj)
+    {
+        AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
+            AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),
+            HandlerObj->AddressSpace.SpaceId);
+
+        AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,
+            (HandlerObj->AddressSpace.HandlerFlags &
+                ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
+            HandlerObj->AddressSpace.Handler);
+
+        AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);
+
+        HandlerObj = HandlerObj->AddressSpace.Next;
+    }
+
+    ACPI_FREE (Pathname);
+    return (AE_OK);
 }
 
 #endif /* ACPI_DEBUGGER */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbexec.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbexec.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbexec.c	(revision 249699)
@@ -1,829 +1,778 @@
 /*******************************************************************************
  *
  * Module Name: dbexec - debugger control method execution
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #include 
 #include 
 #include 
 #include 
 
 #ifdef ACPI_DEBUGGER
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
         ACPI_MODULE_NAME    ("dbexec")
 
 
 static ACPI_DB_METHOD_INFO          AcpiGbl_DbMethodInfo;
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiDbExecuteMethod (
     ACPI_DB_METHOD_INFO     *Info,
     ACPI_BUFFER             *ReturnObj);
 
 static void
 AcpiDbExecuteSetup (
     ACPI_DB_METHOD_INFO     *Info);
 
 static UINT32
 AcpiDbGetOutstandingAllocations (
     void);
 
 static void ACPI_SYSTEM_XFACE
 AcpiDbMethodThread (
     void                    *Context);
 
 static ACPI_STATUS
 AcpiDbExecutionWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDeleteObjects
  *
  * PARAMETERS:  Count               - Count of objects in the list
  *              Objects             - Array of ACPI_OBJECTs to be deleted
  *
  * RETURN:      None
  *
  * DESCRIPTION: Delete a list of ACPI_OBJECTS. Handles packages and nested
  *              packages via recursion.
  *
  ******************************************************************************/
 
 void
 AcpiDbDeleteObjects (
     UINT32                  Count,
     ACPI_OBJECT             *Objects)
 {
     UINT32                  i;
 
 
     for (i = 0; i < Count; i++)
     {
         switch (Objects[i].Type)
         {
         case ACPI_TYPE_BUFFER:
             ACPI_FREE (Objects[i].Buffer.Pointer);
             break;
 
         case ACPI_TYPE_PACKAGE:
 
             /* Recursive call to delete package elements */
 
             AcpiDbDeleteObjects (Objects[i].Package.Count,
                 Objects[i].Package.Elements);
 
             /* Free the elements array */
 
             ACPI_FREE (Objects[i].Package.Elements);
             break;
 
         default:
             break;
         }
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbExecuteMethod
  *
  * PARAMETERS:  Info            - Valid info segment
  *              ReturnObj       - Where to put return object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Execute a control method.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbExecuteMethod (
     ACPI_DB_METHOD_INFO     *Info,
     ACPI_BUFFER             *ReturnObj)
 {
     ACPI_STATUS             Status;
     ACPI_OBJECT_LIST        ParamObjects;
-    ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
-    ACPI_DEVICE_INFO        *ObjInfo;
+    ACPI_OBJECT             Params[ACPI_DEBUGGER_MAX_ARGS + 1];
     UINT32                  i;
 
 
     ACPI_FUNCTION_TRACE (DbExecuteMethod);
 
 
     if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel)
     {
         AcpiOsPrintf ("Warning: debug output is not enabled!\n");
     }
 
-    /* Get the object info for number of method parameters */
-
-    Status = AcpiGetObjectInfo (Info->Method, &ObjInfo);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
-
+    ParamObjects.Count = 0;
     ParamObjects.Pointer = NULL;
-    ParamObjects.Count   = 0;
 
-    if (ObjInfo->Type == ACPI_TYPE_METHOD)
+    /* Pass through any command-line arguments */
+
+    if (Info->Args && Info->Args[0])
     {
-        /* Are there arguments to the method? */
+        /* Get arguments passed on the command line */
 
-        i = 0;
-        if (Info->Args && Info->Args[0])
+        for (i = 0; (Info->Args[i] && *(Info->Args[i])); i++)
         {
-            /* Get arguments passed on the command line */
+            /* Convert input string (token) to an actual ACPI_OBJECT */
 
-            for (; Info->Args[i] &&
-                (i < ACPI_METHOD_NUM_ARGS) &&
-                (i < ObjInfo->ParamCount);
-                i++)
+            Status = AcpiDbConvertToObject (Info->Types[i],
+                Info->Args[i], &Params[i]);
+            if (ACPI_FAILURE (Status))
             {
-                /* Convert input string (token) to an actual ACPI_OBJECT */
-
-                Status = AcpiDbConvertToObject (Info->Types[i],
-                    Info->Args[i], &Params[i]);
-                if (ACPI_FAILURE (Status))
-                {
-                    ACPI_EXCEPTION ((AE_INFO, Status,
-                        "While parsing method arguments"));
-                    goto Cleanup;
-                }
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "While parsing method arguments"));
+                goto Cleanup;
             }
         }
 
-        /* Create additional "default" parameters as needed */
-
-        if (i < ObjInfo->ParamCount)
-        {
-            AcpiOsPrintf ("Adding %u arguments containing default values\n",
-                ObjInfo->ParamCount - i);
-
-            for (; i < ObjInfo->ParamCount; i++)
-            {
-                switch (i)
-                {
-                case 0:
-
-                    Params[0].Type           = ACPI_TYPE_INTEGER;
-                    Params[0].Integer.Value  = 0x01020304;
-                    break;
-
-                case 1:
-
-                    Params[1].Type           = ACPI_TYPE_STRING;
-                    Params[1].String.Length  = 12;
-                    Params[1].String.Pointer = "AML Debugger";
-                    break;
-
-                default:
-
-                    Params[i].Type           = ACPI_TYPE_INTEGER;
-                    Params[i].Integer.Value  = i * (UINT64) 0x1000;
-                    break;
-                }
-            }
-        }
-
-        ParamObjects.Count = ObjInfo->ParamCount;
+        ParamObjects.Count = i;
         ParamObjects.Pointer = Params;
     }
 
     /* Prepare for a return object of arbitrary size */
 
     ReturnObj->Pointer = AcpiGbl_DbBuffer;
     ReturnObj->Length  = ACPI_DEBUG_BUFFER_SIZE;
 
     /* Do the actual method execution */
 
     AcpiGbl_MethodExecuting = TRUE;
-    Status = AcpiEvaluateObject (NULL,
-        Info->Pathname, &ParamObjects, ReturnObj);
+    Status = AcpiEvaluateObject (NULL, Info->Pathname,
+        &ParamObjects, ReturnObj);
 
     AcpiGbl_CmSingleStep = FALSE;
     AcpiGbl_MethodExecuting = FALSE;
 
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status,
             "while executing %s from debugger", Info->Pathname));
 
         if (Status == AE_BUFFER_OVERFLOW)
         {
             ACPI_ERROR ((AE_INFO,
                 "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)",
                 ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length));
         }
     }
 
 Cleanup:
-    AcpiDbDeleteObjects (ObjInfo->ParamCount, Params);
-    ACPI_FREE (ObjInfo);
-
+    AcpiDbDeleteObjects (ParamObjects.Count, Params);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbExecuteSetup
  *
  * PARAMETERS:  Info            - Valid method info
  *
  * RETURN:      None
  *
  * DESCRIPTION: Setup info segment prior to method execution
  *
  ******************************************************************************/
 
 static void
 AcpiDbExecuteSetup (
     ACPI_DB_METHOD_INFO     *Info)
 {
 
     /* Catenate the current scope to the supplied name */
 
     Info->Pathname[0] = 0;
     if ((Info->Name[0] != '\\') &&
         (Info->Name[0] != '/'))
     {
         ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf);
     }
 
     ACPI_STRCAT (Info->Pathname, Info->Name);
     AcpiDbPrepNamestring (Info->Pathname);
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
     AcpiOsPrintf ("Evaluating %s\n", Info->Pathname);
 
     if (Info->Flags & EX_SINGLE_STEP)
     {
         AcpiGbl_CmSingleStep = TRUE;
         AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
     }
 
     else
     {
         /* No single step, allow redirection to a file */
 
         AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
     }
 }
 
 
 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
 UINT32
 AcpiDbGetCacheInfo (
     ACPI_MEMORY_LIST        *Cache)
 {
 
     return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth);
 }
 #endif
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbGetOutstandingAllocations
  *
  * PARAMETERS:  None
  *
  * RETURN:      Current global allocation count minus cache entries
  *
  * DESCRIPTION: Determine the current number of "outstanding" allocations --
  *              those allocations that have not been freed and also are not
  *              in one of the various object caches.
  *
  ******************************************************************************/
 
 static UINT32
 AcpiDbGetOutstandingAllocations (
     void)
 {
     UINT32                  Outstanding = 0;
 
 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
 
     Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache);
     Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache);
     Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache);
     Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache);
 #endif
 
     return (Outstanding);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbExecutionWalk
  *
  * PARAMETERS:  WALK_CALLBACK
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Execute a control method. Name is relative to the current
  *              scope.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbExecutionWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
     ACPI_BUFFER             ReturnObj;
     ACPI_STATUS             Status;
 
 
     ObjDesc = AcpiNsGetAttachedObject (Node);
     if (ObjDesc->Method.ParamCount)
     {
         return (AE_OK);
     }
 
     ReturnObj.Pointer = NULL;
     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
 
     AcpiNsPrintNodePathname (Node, "Evaluating");
 
     /* Do the actual method execution */
 
     AcpiOsPrintf ("\n");
     AcpiGbl_MethodExecuting = TRUE;
 
     Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj);
 
     AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", AcpiUtGetNodeName (Node),
             AcpiFormatException (Status));
     AcpiGbl_MethodExecuting = FALSE;
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbExecute
  *
  * PARAMETERS:  Name                - Name of method to execute
  *              Args                - Parameters to the method
  *              Flags               - single step/no single step
  *
  * RETURN:      None
  *
  * DESCRIPTION: Execute a control method. Name is relative to the current
  *              scope.
  *
  ******************************************************************************/
 
 void
 AcpiDbExecute (
     char                    *Name,
     char                    **Args,
     ACPI_OBJECT_TYPE        *Types,
     UINT32                  Flags)
 {
     ACPI_STATUS             Status;
     ACPI_BUFFER             ReturnObj;
     char                    *NameString;
 
 
 #ifdef ACPI_DEBUG_OUTPUT
     UINT32                  PreviousAllocations;
     UINT32                  Allocations;
 
 
     /* Memory allocation tracking */
 
     PreviousAllocations = AcpiDbGetOutstandingAllocations ();
 #endif
 
     if (*Name == '*')
     {
         (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT,
                     ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL);
         return;
     }
     else
     {
         NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1);
         if (!NameString)
         {
             return;
         }
 
         ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
 
         ACPI_STRCPY (NameString, Name);
         AcpiUtStrupr (NameString);
         AcpiGbl_DbMethodInfo.Name = NameString;
         AcpiGbl_DbMethodInfo.Args = Args;
         AcpiGbl_DbMethodInfo.Types = Types;
         AcpiGbl_DbMethodInfo.Flags = Flags;
 
         ReturnObj.Pointer = NULL;
         ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
 
         AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
 
         /* Get the NS node, determines existence also */
 
         Status = AcpiGetHandle (NULL, AcpiGbl_DbMethodInfo.Pathname,
             &AcpiGbl_DbMethodInfo.Method);
         if (ACPI_SUCCESS (Status))
         {
             Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj);
         }
         ACPI_FREE (NameString);
     }
 
     /*
      * Allow any handlers in separate threads to complete.
      * (Such as Notify handlers invoked from AML executed above).
      */
     AcpiOsSleep ((UINT64) 10);
 
 #ifdef ACPI_DEBUG_OUTPUT
 
     /* Memory allocation tracking */
 
     Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations;
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
 
     if (Allocations > 0)
     {
         AcpiOsPrintf ("0x%X Outstanding allocations after evaluation of %s\n",
                         Allocations, AcpiGbl_DbMethodInfo.Pathname);
     }
 #endif
 
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Evaluation of %s failed with status %s\n",
             AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status));
     }
     else
     {
         /* Display a return object, if any */
 
         if (ReturnObj.Length)
         {
             AcpiOsPrintf (
                 "Evaluation of %s returned object %p, external buffer length %X\n",
                 AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer,
                 (UINT32) ReturnObj.Length);
             AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
 
             /* Dump a _PLD buffer if present */
 
             if (ACPI_COMPARE_NAME ((ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
                     AcpiGbl_DbMethodInfo.Method)->Name.Ascii), METHOD_NAME__PLD))
             {
                 AcpiDbDumpPldBuffer (ReturnObj.Pointer);
             }
         }
         else
         {
             AcpiOsPrintf ("No object was returned from evaluation of %s\n",
                 AcpiGbl_DbMethodInfo.Pathname);
         }
     }
 
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbMethodThread
  *
  * PARAMETERS:  Context             - Execution info segment
  *
  * RETURN:      None
  *
  * DESCRIPTION: Debugger execute thread. Waits for a command line, then
  *              simply dispatches it.
  *
  ******************************************************************************/
 
 static void ACPI_SYSTEM_XFACE
 AcpiDbMethodThread (
     void                    *Context)
 {
     ACPI_STATUS             Status;
     ACPI_DB_METHOD_INFO     *Info = Context;
     ACPI_DB_METHOD_INFO     LocalInfo;
     UINT32                  i;
     UINT8                   Allow;
     ACPI_BUFFER             ReturnObj;
 
 
     /*
      * AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments.
      * Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads
      * concurrently.
      *
      * Note: The arguments we are passing are used by the ASL test suite
      * (aslts). Do not change them without updating the tests.
      */
     (void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER);
 
     if (Info->InitArgs)
     {
         AcpiDbUint32ToHexString (Info->NumCreated, Info->IndexOfThreadStr);
         AcpiDbUint32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr);
     }
 
     if (Info->Threads && (Info->NumCreated < Info->NumThreads))
     {
         Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId();
     }
 
     LocalInfo = *Info;
     LocalInfo.Args = LocalInfo.Arguments;
     LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr;
     LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr;
     LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr;
     LocalInfo.Arguments[3] = NULL;
 
     LocalInfo.Types = LocalInfo.ArgTypes;
 
     (void) AcpiOsSignalSemaphore (Info->InfoGate, 1);
 
     for (i = 0; i < Info->NumLoops; i++)
     {
         Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj);
         if (ACPI_FAILURE (Status))
         {
             AcpiOsPrintf ("%s During evaluation of %s at iteration %X\n",
                 AcpiFormatException (Status), Info->Pathname, i);
             if (Status == AE_ABORT_METHOD)
             {
                 break;
             }
         }
 
 #if 0
         if ((i % 100) == 0)
         {
             AcpiOsPrintf ("%u loops, Thread 0x%x\n", i, AcpiOsGetThreadId ());
         }
 
         if (ReturnObj.Length)
         {
             AcpiOsPrintf ("Evaluation of %s returned object %p Buflen %X\n",
                 Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length);
             AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
         }
 #endif
     }
 
     /* Signal our completion */
 
     Allow = 0;
     (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER);
     Info->NumCompleted++;
 
     if (Info->NumCompleted == Info->NumThreads)
     {
         /* Do signal for main thread once only */
         Allow = 1;
     }
 
     (void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1);
 
     if (Allow)
     {
         Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1);
         if (ACPI_FAILURE (Status))
         {
             AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n",
                 AcpiFormatException (Status));
         }
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbCreateExecutionThreads
  *
  * PARAMETERS:  NumThreadsArg           - Number of threads to create
  *              NumLoopsArg             - Loop count for the thread(s)
  *              MethodNameArg           - Control method to execute
  *
  * RETURN:      None
  *
  * DESCRIPTION: Create threads to execute method(s)
  *
  ******************************************************************************/
 
 void
 AcpiDbCreateExecutionThreads (
     char                    *NumThreadsArg,
     char                    *NumLoopsArg,
     char                    *MethodNameArg)
 {
     ACPI_STATUS             Status;
     UINT32                  NumThreads;
     UINT32                  NumLoops;
     UINT32                  i;
     UINT32                  Size;
     ACPI_MUTEX              MainThreadGate;
     ACPI_MUTEX              ThreadCompleteGate;
     ACPI_MUTEX              InfoGate;
 
 
     /* Get the arguments */
 
     NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0);
     NumLoops   = ACPI_STRTOUL (NumLoopsArg, NULL, 0);
 
     if (!NumThreads || !NumLoops)
     {
         AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n",
             NumThreads, NumLoops);
         return;
     }
 
     /*
      * Create the semaphore for synchronization of
      * the created threads with the main thread.
      */
     Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n",
             AcpiFormatException (Status));
         return;
     }
 
     /*
      * Create the semaphore for synchronization
      * between the created threads.
      */
     Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n",
             AcpiFormatException (Status));
         (void) AcpiOsDeleteSemaphore (MainThreadGate);
         return;
     }
 
     Status = AcpiOsCreateSemaphore (1, 1, &InfoGate);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n",
             AcpiFormatException (Status));
         (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
         (void) AcpiOsDeleteSemaphore (MainThreadGate);
         return;
     }
 
     ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
 
     /* Array to store IDs of threads */
 
     AcpiGbl_DbMethodInfo.NumThreads = NumThreads;
     Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads;
     AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size);
     if (AcpiGbl_DbMethodInfo.Threads == NULL)
     {
         AcpiOsPrintf ("No memory for thread IDs array\n");
         (void) AcpiOsDeleteSemaphore (MainThreadGate);
         (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
         (void) AcpiOsDeleteSemaphore (InfoGate);
         return;
     }
     ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size);
 
     /* Setup the context to be passed to each thread */
 
     AcpiGbl_DbMethodInfo.Name = MethodNameArg;
     AcpiGbl_DbMethodInfo.Flags = 0;
     AcpiGbl_DbMethodInfo.NumLoops = NumLoops;
     AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate;
     AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate;
     AcpiGbl_DbMethodInfo.InfoGate = InfoGate;
 
     /* Init arguments to be passed to method */
 
     AcpiGbl_DbMethodInfo.InitArgs = 1;
     AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments;
     AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr;
     AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr;
     AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr;
     AcpiGbl_DbMethodInfo.Arguments[3] = NULL;
 
     AcpiGbl_DbMethodInfo.Types = AcpiGbl_DbMethodInfo.ArgTypes;
     AcpiGbl_DbMethodInfo.ArgTypes[0] = ACPI_TYPE_INTEGER;
     AcpiGbl_DbMethodInfo.ArgTypes[1] = ACPI_TYPE_INTEGER;
     AcpiGbl_DbMethodInfo.ArgTypes[2] = ACPI_TYPE_INTEGER;
 
     AcpiDbUint32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr);
 
     AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
 
     /* Get the NS node, determines existence also */
 
     Status = AcpiGetHandle (NULL, AcpiGbl_DbMethodInfo.Pathname,
         &AcpiGbl_DbMethodInfo.Method);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("%s Could not get handle for %s\n",
             AcpiFormatException (Status), AcpiGbl_DbMethodInfo.Pathname);
         goto CleanupAndExit;
     }
 
     /* Create the threads */
 
     AcpiOsPrintf ("Creating %X threads to execute %X times each\n",
         NumThreads, NumLoops);
 
     for (i = 0; i < (NumThreads); i++)
     {
         Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread,
             &AcpiGbl_DbMethodInfo);
         if (ACPI_FAILURE (Status))
         {
             break;
         }
     }
 
     /* Wait for all threads to complete */
 
     (void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER);
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
     AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads);
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
 
 CleanupAndExit:
 
     /* Cleanup and exit */
 
     (void) AcpiOsDeleteSemaphore (MainThreadGate);
     (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
     (void) AcpiOsDeleteSemaphore (InfoGate);
 
     AcpiOsFree (AcpiGbl_DbMethodInfo.Threads);
     AcpiGbl_DbMethodInfo.Threads = NULL;
 }
 
 #endif /* ACPI_DEBUGGER */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbmethod.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbmethod.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbmethod.c	(revision 249699)
@@ -1,561 +1,606 @@
 /*******************************************************************************
  *
  * Module Name: dbmethod - Debug commands for control methods
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 
 #ifdef ACPI_DEBUGGER
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
         ACPI_MODULE_NAME    ("dbmethod")
 
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiDbWalkForExecute (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbSetMethodBreakpoint
  *
  * PARAMETERS:  Location            - AML offset of breakpoint
  *              WalkState           - Current walk info
  *              Op                  - Current Op (from parse walk)
  *
  * RETURN:      None
  *
  * DESCRIPTION: Set a breakpoint in a control method at the specified
  *              AML offset
  *
  ******************************************************************************/
 
 void
 AcpiDbSetMethodBreakpoint (
     char                    *Location,
     ACPI_WALK_STATE         *WalkState,
     ACPI_PARSE_OBJECT       *Op)
 {
     UINT32                  Address;
 
 
     if (!Op)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     /* Get and verify the breakpoint address */
 
     Address = ACPI_STRTOUL (Location, NULL, 16);
     if (Address <= Op->Common.AmlOffset)
     {
         AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
             Address, Op->Common.AmlOffset);
     }
 
     /* Save breakpoint in current walk */
 
     WalkState->UserBreakpoint = Address;
     AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbSetMethodCallBreakpoint
  *
  * PARAMETERS:  Op                  - Current Op (from parse walk)
  *
  * RETURN:      None
  *
  * DESCRIPTION: Set a breakpoint in a control method at the specified
  *              AML offset
  *
  ******************************************************************************/
 
 void
 AcpiDbSetMethodCallBreakpoint (
     ACPI_PARSE_OBJECT       *Op)
 {
 
 
     if (!Op)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     AcpiGbl_StepToNextCall = TRUE;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbSetMethodData
  *
  * PARAMETERS:  TypeArg         - L for local, A for argument
  *              IndexArg        - which one
  *              ValueArg        - Value to set.
  *
  * RETURN:      None
  *
  * DESCRIPTION: Set a local or argument for the running control method.
  *              NOTE: only object supported is Number.
  *
  ******************************************************************************/
 
 void
 AcpiDbSetMethodData (
     char                    *TypeArg,
     char                    *IndexArg,
     char                    *ValueArg)
 {
     char                    Type;
     UINT32                  Index;
     UINT32                  Value;
     ACPI_WALK_STATE         *WalkState;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
     ACPI_NAMESPACE_NODE     *Node;
 
 
     /* Validate TypeArg */
 
     AcpiUtStrupr (TypeArg);
     Type = TypeArg[0];
     if ((Type != 'L') &&
         (Type != 'A') &&
         (Type != 'N'))
     {
         AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
         return;
     }
 
     Value = ACPI_STRTOUL (ValueArg, NULL, 16);
 
     if (Type == 'N')
     {
         Node = AcpiDbConvertToNode (IndexArg);
         if (Node->Type != ACPI_TYPE_INTEGER)
         {
             AcpiOsPrintf ("Can only set Integer nodes\n");
             return;
         }
         ObjDesc = Node->Object;
         ObjDesc->Integer.Value = Value;
         return;
     }
 
     /* Get the index and value */
 
     Index = ACPI_STRTOUL (IndexArg, NULL, 16);
 
     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
     if (!WalkState)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     /* Create and initialize the new object */
 
     ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
     if (!ObjDesc)
     {
         AcpiOsPrintf ("Could not create an internal object\n");
         return;
     }
 
     /* Store the new object into the target */
 
     switch (Type)
     {
     case 'A':
 
         /* Set a method argument */
 
         if (Index > ACPI_METHOD_MAX_ARG)
         {
             AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index);
             goto Cleanup;
         }
 
         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
                     WalkState);
         if (ACPI_FAILURE (Status))
         {
             goto Cleanup;
         }
 
         ObjDesc = WalkState->Arguments[Index].Object;
 
         AcpiOsPrintf ("Arg%u: ", Index);
         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
         break;
 
     case 'L':
 
         /* Set a method local */
 
         if (Index > ACPI_METHOD_MAX_LOCAL)
         {
             AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index);
             goto Cleanup;
         }
 
         Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
                     WalkState);
         if (ACPI_FAILURE (Status))
         {
             goto Cleanup;
         }
 
         ObjDesc = WalkState->LocalVariables[Index].Object;
 
         AcpiOsPrintf ("Local%u: ", Index);
         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
         break;
 
     default:
         break;
     }
 
 Cleanup:
     AcpiUtRemoveReference (ObjDesc);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisassembleAml
  *
  * PARAMETERS:  Statements          - Number of statements to disassemble
  *              Op                  - Current Op (from parse walk)
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
  *              of statements specified.
  *
  ******************************************************************************/
 
 void
 AcpiDbDisassembleAml (
     char                    *Statements,
     ACPI_PARSE_OBJECT       *Op)
 {
     UINT32                  NumStatements = 8;
 
 
     if (!Op)
     {
         AcpiOsPrintf ("There is no method currently executing\n");
         return;
     }
 
     if (Statements)
     {
         NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
     }
 
 #ifdef ACPI_DISASSEMBLER
     AcpiDmDisassemble (NULL, Op, NumStatements);
 #endif
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisassembleMethod
  *
  * PARAMETERS:  Name            - Name of control method
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
  *              of statements specified.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiDbDisassembleMethod (
     char                    *Name)
 {
     ACPI_STATUS             Status;
     ACPI_PARSE_OBJECT       *Op;
     ACPI_WALK_STATE         *WalkState;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_NAMESPACE_NODE     *Method;
 
 
     Method = AcpiDbConvertToNode (Name);
     if (!Method)
     {
         return (AE_BAD_PARAMETER);
     }
 
     if (Method->Type != ACPI_TYPE_METHOD)
     {
         ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method",
             Name, AcpiUtGetTypeName (Method->Type)));
         return (AE_BAD_PARAMETER);
     }
 
     ObjDesc = Method->Object;
 
     Op = AcpiPsCreateScopeOp ();
     if (!Op)
     {
         return (AE_NO_MEMORY);
     }
 
     /* Create and initialize a new walk state */
 
     WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
     if (!WalkState)
     {
         return (AE_NO_MEMORY);
     }
 
     Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
         ObjDesc->Method.AmlStart,
         ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
     WalkState->OwnerId = ObjDesc->Method.OwnerId;
 
     /* Push start scope on scope stack and make it current */
 
     Status = AcpiDsScopeStackPush (Method,
         Method->Type, WalkState);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     /* Parse the entire method AML including deferred operators */
 
     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
 
     Status = AcpiPsParseAml (WalkState);
     (void) AcpiDmParseDeferredOps (Op);
 
     /* Now we can disassemble the method */
 
     AcpiGbl_DbOpt_verbose = FALSE;
 #ifdef ACPI_DISASSEMBLER
     AcpiDmDisassemble (NULL, Op, 0);
 #endif
     AcpiGbl_DbOpt_verbose = TRUE;
 
     AcpiPsDeleteParseTree (Op);
 
     /* Method cleanup */
 
     AcpiNsDeleteNamespaceSubtree (Method);
     AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId);
     AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbWalkForExecute
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Batch execution module. Currently only executes predefined
  *              ACPI names.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbWalkForExecute (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
-    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
-    ACPI_DB_EXECUTE_WALK    *Info = (ACPI_DB_EXECUTE_WALK *) Context;
-    ACPI_BUFFER             ReturnObj;
-    ACPI_STATUS             Status;
-    char                    *Pathname;
-    UINT32                  i;
-    ACPI_DEVICE_INFO        *ObjInfo;
-    ACPI_OBJECT_LIST        ParamObjects;
-    ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
-    const ACPI_PREDEFINED_INFO *Predefined;
+    ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    ACPI_DB_EXECUTE_WALK        *Info = (ACPI_DB_EXECUTE_WALK *) Context;
+    char                        *Pathname;
+    const ACPI_PREDEFINED_INFO  *Predefined;
+    ACPI_DEVICE_INFO            *ObjInfo;
+    ACPI_OBJECT_LIST            ParamObjects;
+    ACPI_OBJECT                 Params[ACPI_METHOD_NUM_ARGS];
+    ACPI_OBJECT                 *ThisParam;
+    ACPI_BUFFER                 ReturnObj;
+    ACPI_STATUS                 Status;
+    UINT16                      ArgTypeList;
+    UINT8                       ArgCount;
+    UINT8                       ArgType;
+    UINT32                      i;
 
 
+    /* The name must be a predefined ACPI name */
+
     Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
     if (!Predefined)
     {
         return (AE_OK);
     }
 
     if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
     {
         return (AE_OK);
     }
 
     Pathname = AcpiNsGetExternalPathname (Node);
     if (!Pathname)
     {
         return (AE_OK);
     }
 
     /* Get the object info for number of method parameters */
 
     Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
+    ParamObjects.Count = 0;
     ParamObjects.Pointer = NULL;
-    ParamObjects.Count   = 0;
 
     if (ObjInfo->Type == ACPI_TYPE_METHOD)
     {
-        /* Setup default parameters */
+        /* Setup default parameters (with proper types) */
 
-        for (i = 0; i < ObjInfo->ParamCount; i++)
+        ArgTypeList = Predefined->Info.ArgumentList;
+        ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
+
+        /*
+         * Setup the ACPI-required number of arguments, regardless of what
+         * the actual method defines. If there is a difference, then the
+         * method is wrong and a warning will be issued during execution.
+         */
+        ThisParam = Params;
+        for (i = 0; i < ArgCount; i++)
         {
-            Params[i].Type           = ACPI_TYPE_INTEGER;
-            Params[i].Integer.Value  = 1;
+            ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
+            ThisParam->Type = ArgType;
+
+            switch (ArgType)
+            {
+            case ACPI_TYPE_INTEGER:
+                ThisParam->Integer.Value = 1;
+                break;
+
+            case ACPI_TYPE_STRING:
+                ThisParam->String.Pointer = "This is the default argument string";
+                ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
+                break;
+
+            case ACPI_TYPE_BUFFER:
+                ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
+                ThisParam->Buffer.Length = 48;
+                break;
+
+             case ACPI_TYPE_PACKAGE:
+                ThisParam->Package.Elements = NULL;
+                ThisParam->Package.Count = 0;
+                break;
+
+           default:
+                AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
+                    Pathname, ArgType);
+                break;
+            }
+
+            ThisParam++;
         }
 
-        ParamObjects.Pointer     = Params;
-        ParamObjects.Count       = ObjInfo->ParamCount;
+        ParamObjects.Count = ArgCount;
+        ParamObjects.Pointer = Params;
     }
 
     ACPI_FREE (ObjInfo);
     ReturnObj.Pointer = NULL;
     ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
 
     /* Do the actual method execution */
 
     AcpiGbl_MethodExecuting = TRUE;
 
     Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
 
     AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
     AcpiGbl_MethodExecuting = FALSE;
     ACPI_FREE (Pathname);
 
     /* Ignore status from method execution */
 
     Status = AE_OK;
 
     /* Update count, check if we have executed enough methods */
 
     Info->Count++;
     if (Info->Count >= Info->MaxCount)
     {
         Status = AE_CTRL_TERMINATE;
     }
 
     return (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbBatchExecute
  *
  * PARAMETERS:  CountArg            - Max number of methods to execute
  *
  * RETURN:      None
  *
  * DESCRIPTION: Namespace batch execution. Execute predefined names in the
  *              namespace, up to the max count, if specified.
  *
  ******************************************************************************/
 
 void
 AcpiDbBatchExecute (
     char                    *CountArg)
 {
     ACPI_DB_EXECUTE_WALK    Info;
 
 
     Info.Count = 0;
     Info.MaxCount = ACPI_UINT32_MAX;
 
     if (CountArg)
     {
         Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
     }
 
 
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                 AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
 
     AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
 }
 
 #endif /* ACPI_DEBUGGER */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbnames.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbnames.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger/dbnames.c	(revision 249699)
@@ -1,936 +1,942 @@
 /*******************************************************************************
  *
  * Module Name: dbnames - Debugger commands for the acpi namespace
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #ifdef ACPI_DEBUGGER
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
         ACPI_MODULE_NAME    ("dbnames")
 
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiDbWalkAndMatchName (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 static ACPI_STATUS
 AcpiDbWalkForPredefinedNames (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 static ACPI_STATUS
 AcpiDbWalkForSpecificObjects (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 static ACPI_STATUS
 AcpiDbIntegrityWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 static ACPI_STATUS
 AcpiDbWalkForReferences (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 static ACPI_STATUS
 AcpiDbBusWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue);
 
 /*
  * Arguments for the Objects command
  * These object types map directly to the ACPI_TYPES
  */
 static ACPI_DB_ARGUMENT_INFO    AcpiDbObjectTypes [] =
 {
     {"ANY"},
     {"INTEGERS"},
     {"STRINGS"},
     {"BUFFERS"},
     {"PACKAGES"},
     {"FIELDS"},
     {"DEVICES"},
     {"EVENTS"},
     {"METHODS"},
     {"MUTEXES"},
     {"REGIONS"},
     {"POWERRESOURCES"},
     {"PROCESSORS"},
     {"THERMALZONES"},
     {"BUFFERFIELDS"},
     {"DDBHANDLES"},
     {"DEBUG"},
     {"REGIONFIELDS"},
     {"BANKFIELDS"},
     {"INDEXFIELDS"},
     {"REFERENCES"},
     {"ALIAS"},
     {NULL}           /* Must be null terminated */
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbSetScope
  *
  * PARAMETERS:  Name                - New scope path
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Set the "current scope" as maintained by this utility.
  *              The scope is used as a prefix to ACPI paths.
  *
  ******************************************************************************/
 
 void
 AcpiDbSetScope (
     char                    *Name)
 {
     ACPI_STATUS             Status;
     ACPI_NAMESPACE_NODE     *Node;
 
 
     if (!Name || Name[0] == 0)
     {
         AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
         return;
     }
 
     AcpiDbPrepNamestring (Name);
 
     if (ACPI_IS_ROOT_PREFIX (Name[0]))
     {
         /* Validate new scope from the root */
 
         Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
                     &Node);
         if (ACPI_FAILURE (Status))
         {
             goto ErrorExit;
         }
 
         ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
     }
     else
     {
         /* Validate new scope relative to old scope */
 
         Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
                     &Node);
         if (ACPI_FAILURE (Status))
         {
             goto ErrorExit;
         }
 
         ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
     }
 
     AcpiGbl_DbScopeNode = Node;
     AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
     return;
 
 ErrorExit:
 
     AcpiOsPrintf ("Could not attach scope: %s, %s\n",
         Name, AcpiFormatException (Status));
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDumpNamespace
  *
  * PARAMETERS:  StartArg        - Node to begin namespace dump
  *              DepthArg        - Maximum tree depth to be dumped
  *
  * RETURN:      None
  *
  * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
  *              with type and other information.
  *
  ******************************************************************************/
 
 void
 AcpiDbDumpNamespace (
     char                    *StartArg,
     char                    *DepthArg)
 {
     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
     UINT32                  MaxDepth = ACPI_UINT32_MAX;
 
 
     /* No argument given, just start at the root and dump entire namespace */
 
     if (StartArg)
     {
         SubtreeEntry = AcpiDbConvertToNode (StartArg);
         if (!SubtreeEntry)
         {
             return;
         }
 
         /* Now we can check for the depth argument */
 
         if (DepthArg)
         {
             MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
         }
     }
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
     AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
         ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
 
     /* Display the subtree */
 
     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
         ACPI_OWNER_ID_MAX, SubtreeEntry);
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDumpNamespaceByOwner
  *
  * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
  *              DepthArg        - Maximum tree depth to be dumped
  *
  * RETURN:      None
  *
  * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
  *
  ******************************************************************************/
 
 void
 AcpiDbDumpNamespaceByOwner (
     char                    *OwnerArg,
     char                    *DepthArg)
 {
     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
     UINT32                  MaxDepth = ACPI_UINT32_MAX;
     ACPI_OWNER_ID           OwnerId;
 
 
     OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
 
     /* Now we can check for the depth argument */
 
     if (DepthArg)
     {
         MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
     }
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
     AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
 
     /* Display the subtree */
 
     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
         SubtreeEntry);
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbWalkAndMatchName
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
  *              are supported -- '?' matches any character.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbWalkAndMatchName (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_STATUS             Status;
     char                    *RequestedName = (char *) Context;
     UINT32                  i;
     ACPI_BUFFER             Buffer;
     ACPI_WALK_INFO          Info;
 
 
     /* Check for a name match */
 
     for (i = 0; i < 4; i++)
     {
         /* Wildcard support */
 
         if ((RequestedName[i] != '?') &&
             (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
         {
             /* No match, just exit */
 
             return (AE_OK);
         }
     }
 
     /* Get the full pathname to this object */
 
     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
     }
     else
     {
         Info.OwnerId = ACPI_OWNER_ID_MAX;
         Info.DebugLevel = ACPI_UINT32_MAX;
         Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
 
         AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
         (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
         ACPI_FREE (Buffer.Pointer);
     }
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbFindNameInNamespace
  *
  * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
  *                                wildcards are supported.
  *
  * RETURN:      None
  *
  * DESCRIPTION: Search the namespace for a given name (with wildcards)
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiDbFindNameInNamespace (
     char                    *NameArg)
 {
     char                    AcpiName[5] = "____";
     char                    *AcpiNamePtr = AcpiName;
 
 
     if (ACPI_STRLEN (NameArg) > 4)
     {
         AcpiOsPrintf ("Name must be no longer than 4 characters\n");
         return (AE_OK);
     }
 
     /* Pad out name with underscores as necessary to create a 4-char name */
 
     AcpiUtStrupr (NameArg);
     while (*NameArg)
     {
         *AcpiNamePtr = *NameArg;
         AcpiNamePtr++;
         NameArg++;
     }
 
     /* Walk the namespace from the root */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                         AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
 
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbWalkForPredefinedNames
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Detect and display predefined ACPI names (names that start with
  *              an underscore)
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbWalkForPredefinedNames (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
     UINT32                      *Count = (UINT32 *) Context;
     const ACPI_PREDEFINED_INFO  *Predefined;
     const ACPI_PREDEFINED_INFO  *Package = NULL;
     char                        *Pathname;
+    char                        StringBuffer[48];
 
 
     Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
     if (!Predefined)
     {
         return (AE_OK);
     }
 
     Pathname = AcpiNsGetExternalPathname (Node);
     if (!Pathname)
     {
         return (AE_OK);
     }
 
     /* If method returns a package, the info is in the next table entry */
 
     if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
     {
         Package = Predefined + 1;
     }
 
-    AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
-        (Predefined->Info.ArgumentList & METHOD_ARG_MASK),
+    AcpiUtGetExpectedReturnTypes (StringBuffer,
         Predefined->Info.ExpectedBtypes);
 
+    AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname,
+        METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList),
+        StringBuffer);
+
     if (Package)
     {
-        AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
+        AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
             Package->RetInfo.Type, Package->RetInfo.ObjectType1,
             Package->RetInfo.Count1);
     }
 
     AcpiOsPrintf("\n");
 
-    AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
+    /* Check that the declared argument count matches the ACPI spec */
+
+    AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);
+
     ACPI_FREE (Pathname);
     (*Count)++;
-
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbCheckPredefinedNames
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Validate all predefined names in the namespace
  *
  ******************************************************************************/
 
 void
 AcpiDbCheckPredefinedNames (
     void)
 {
     UINT32                  Count = 0;
 
 
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                 AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL);
 
     AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbWalkForSpecificObjects
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Display short info about objects in the namespace
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbWalkForSpecificObjects (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
     ACPI_BUFFER             Buffer;
     ACPI_STATUS             Status;
 
 
     Info->Count++;
 
     /* Get and display the full pathname to this object */
 
     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
         return (AE_OK);
     }
 
     AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
     ACPI_FREE (Buffer.Pointer);
 
     /* Dump short info about the object */
 
     (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbDisplayObjects
  *
  * PARAMETERS:  ObjTypeArg          - Type of object to display
  *              DisplayCountArg     - Max depth to display
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display objects in the namespace of the requested type
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiDbDisplayObjects (
     char                    *ObjTypeArg,
     char                    *DisplayCountArg)
 {
     ACPI_WALK_INFO          Info;
     ACPI_OBJECT_TYPE        Type;
 
 
     /* Get the object type */
 
     Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
     if (Type == ACPI_TYPE_NOT_FOUND)
     {
         AcpiOsPrintf ("Invalid or unsupported argument\n");
         return (AE_OK);
     }
 
     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
     AcpiOsPrintf (
         "Objects of type [%s] defined in the current ACPI Namespace:\n",
         AcpiUtGetTypeName (Type));
 
     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
 
     Info.Count = 0;
     Info.OwnerId = ACPI_OWNER_ID_MAX;
     Info.DebugLevel = ACPI_UINT32_MAX;
     Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
 
     /* Walk the namespace from the root */
 
     (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
 
     AcpiOsPrintf (
         "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
         Info.Count, AcpiUtGetTypeName (Type));
 
     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbIntegrityWalk
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Examine one NS node for valid values.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbIntegrityWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_INTEGRITY_INFO     *Info = (ACPI_INTEGRITY_INFO *) Context;
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
     ACPI_OPERAND_OBJECT     *Object;
     BOOLEAN                 Alias = TRUE;
 
 
     Info->Nodes++;
 
     /* Verify the NS node, and dereference aliases */
 
     while (Alias)
     {
         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
         {
             AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
                 Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
                 ACPI_DESC_TYPE_NAMED);
             return (AE_OK);
         }
 
         if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
             (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
         {
             Node = (ACPI_NAMESPACE_NODE *) Node->Object;
         }
         else
         {
             Alias = FALSE;
         }
     }
 
     if (Node->Type > ACPI_TYPE_LOCAL_MAX)
     {
         AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
             Node, Node->Type);
         return (AE_OK);
     }
 
     if (!AcpiUtValidAcpiName (Node->Name.Integer))
     {
         AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
         return (AE_OK);
     }
 
     Object = AcpiNsGetAttachedObject (Node);
     if (Object)
     {
         Info->Objects++;
         if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
         {
             AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
                 Object, AcpiUtGetDescriptorName (Object));
         }
     }
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbCheckIntegrity
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Check entire namespace for data structure integrity
  *
  ******************************************************************************/
 
 void
 AcpiDbCheckIntegrity (
     void)
 {
     ACPI_INTEGRITY_INFO     Info = {0,0};
 
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                     AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
 
     AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
         Info.Nodes, Info.Objects);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbWalkForReferences
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Check if this namespace object refers to the target object
  *              that is passed in as the context value.
  *
  * Note: Currently doesn't check subobjects within the Node's object
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbWalkForReferences (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
 
 
     /* Check for match against the namespace node itself */
 
     if (Node == (void *) ObjDesc)
     {
         AcpiOsPrintf ("Object is a Node [%4.4s]\n",
             AcpiUtGetNodeName (Node));
     }
 
     /* Check for match against the object attached to the node */
 
     if (AcpiNsGetAttachedObject (Node) == ObjDesc)
     {
         AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
             Node, AcpiUtGetNodeName (Node));
     }
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbFindReferences
  *
  * PARAMETERS:  ObjectArg       - String with hex value of the object
  *
  * RETURN:      None
  *
  * DESCRIPTION: Search namespace for all references to the input object
  *
  ******************************************************************************/
 
 void
 AcpiDbFindReferences (
     char                    *ObjectArg)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
 
 
     /* Convert string to object pointer */
 
     ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
 
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                     AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbBusWalk
  *
  * PARAMETERS:  Callback from WalkNamespace
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Display info about device objects that have a corresponding
  *              _PRT method.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiDbBusWalk (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
     ACPI_STATUS             Status;
     ACPI_BUFFER             Buffer;
     ACPI_NAMESPACE_NODE     *TempNode;
     ACPI_DEVICE_INFO        *Info;
     UINT32                  i;
 
 
     if ((Node->Type != ACPI_TYPE_DEVICE) &&
         (Node->Type != ACPI_TYPE_PROCESSOR))
     {
         return (AE_OK);
     }
 
     /* Exit if there is no _PRT under this device */
 
     Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
                 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
     if (ACPI_FAILURE (Status))
     {
         return (AE_OK);
     }
 
     /* Get the full path to this device object */
 
     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
     if (ACPI_FAILURE (Status))
     {
         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
         return (AE_OK);
     }
 
     Status = AcpiGetObjectInfo (ObjHandle, &Info);
     if (ACPI_FAILURE (Status))
     {
         return (AE_OK);
     }
 
     /* Display the full path */
 
     AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
     ACPI_FREE (Buffer.Pointer);
 
     if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
     {
         AcpiOsPrintf ("  - Is PCI Root Bridge");
     }
     AcpiOsPrintf ("\n");
 
     /* _PRT info */
 
     AcpiOsPrintf ("_PRT: %p\n", TempNode);
 
     /* Dump _ADR, _HID, _UID, _CID */
 
     if (Info->Valid & ACPI_VALID_ADR)
     {
         AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
     }
     else
     {
         AcpiOsPrintf ("_ADR: \n");
     }
 
     if (Info->Valid & ACPI_VALID_HID)
     {
         AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
     }
     else
     {
         AcpiOsPrintf ("_HID: \n");
     }
 
     if (Info->Valid & ACPI_VALID_UID)
     {
         AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
     }
     else
     {
         AcpiOsPrintf ("_UID: \n");
     }
 
     if (Info->Valid & ACPI_VALID_CID)
     {
         for (i = 0; i < Info->CompatibleIdList.Count; i++)
         {
             AcpiOsPrintf ("_CID: %s\n",
                 Info->CompatibleIdList.Ids[i].String);
         }
     }
     else
     {
         AcpiOsPrintf ("_CID: \n");
     }
 
     ACPI_FREE (Info);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDbGetBusInfo
  *
  * PARAMETERS:  None
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display info about system busses.
  *
  ******************************************************************************/
 
 void
 AcpiDbGetBusInfo (
     void)
 {
     /* Search all nodes in namespace */
 
     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
                     AcpiDbBusWalk, NULL, NULL, NULL);
 }
 
 #endif /* ACPI_DEBUGGER */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/debugger
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/components/debugger:r249111-249661
   Merged /head/sys/contrib/dev/acpica/components/debugger:r249197-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evgpe.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evgpe.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evgpe.c	(revision 249699)
@@ -1,852 +1,851 @@
 /******************************************************************************
  *
  * Module Name: evgpe - General Purpose Event handling and dispatch
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #include 
 #include 
 #include 
 #include 
 
 #define _COMPONENT          ACPI_EVENTS
         ACPI_MODULE_NAME    ("evgpe")
 
 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
 
 /* Local prototypes */
 
 static void ACPI_SYSTEM_XFACE
 AcpiEvAsynchExecuteGpeMethod (
     void                    *Context);
 
 static void ACPI_SYSTEM_XFACE
 AcpiEvAsynchEnableGpe (
     void                    *Context);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvUpdateGpeEnableMask
  *
  * PARAMETERS:  GpeEventInfo            - GPE to update
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Updates GPE register enable mask based upon whether there are
  *              runtime references to this GPE
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvUpdateGpeEnableMask (
     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
 {
     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
     UINT32                  RegisterBit;
 
 
     ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMask);
 
 
     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
     if (!GpeRegisterInfo)
     {
         return_ACPI_STATUS (AE_NOT_EXIST);
     }
 
     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
 
     /* Clear the run bit up front */
 
     ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
 
     /* Set the mask bit only if there are references to this GPE */
 
     if (GpeEventInfo->RuntimeCount)
     {
         ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit);
     }
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvEnableGpe
  *
  * PARAMETERS:  GpeEventInfo            - GPE to enable
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Clear a GPE of stale events and enable it.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvEnableGpe (
     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
 {
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (EvEnableGpe);
 
 
     /*
      * We will only allow a GPE to be enabled if it has either an associated
      * method (_Lxx/_Exx) or a handler, or is using the implicit notify
      * feature. Otherwise, the GPE will be immediately disabled by
      * AcpiEvGpeDispatch the first time it fires.
      */
     if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
         ACPI_GPE_DISPATCH_NONE)
     {
         return_ACPI_STATUS (AE_NO_HANDLER);
     }
 
     /* Clear the GPE (of stale events) */
 
     Status = AcpiHwClearGpe (GpeEventInfo);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /* Enable the requested GPE */
 
     Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvAddGpeReference
  *
  * PARAMETERS:  GpeEventInfo            - Add a reference to this GPE
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
  *              hardware-enabled.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvAddGpeReference (
     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
 {
     ACPI_STATUS             Status = AE_OK;
 
 
     ACPI_FUNCTION_TRACE (EvAddGpeReference);
 
 
     if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX)
     {
         return_ACPI_STATUS (AE_LIMIT);
     }
 
     GpeEventInfo->RuntimeCount++;
     if (GpeEventInfo->RuntimeCount == 1)
     {
         /* Enable on first reference */
 
         Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
         if (ACPI_SUCCESS (Status))
         {
             Status = AcpiEvEnableGpe (GpeEventInfo);
         }
 
         if (ACPI_FAILURE (Status))
         {
             GpeEventInfo->RuntimeCount--;
         }
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvRemoveGpeReference
  *
  * PARAMETERS:  GpeEventInfo            - Remove a reference to this GPE
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Remove a reference to a GPE. When the last reference is
  *              removed, the GPE is hardware-disabled.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvRemoveGpeReference (
     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
 {
     ACPI_STATUS             Status = AE_OK;
 
 
     ACPI_FUNCTION_TRACE (EvRemoveGpeReference);
 
 
     if (!GpeEventInfo->RuntimeCount)
     {
         return_ACPI_STATUS (AE_LIMIT);
     }
 
     GpeEventInfo->RuntimeCount--;
     if (!GpeEventInfo->RuntimeCount)
     {
         /* Disable on last reference */
 
         Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
         if (ACPI_SUCCESS (Status))
         {
             Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
         }
 
         if (ACPI_FAILURE (Status))
         {
             GpeEventInfo->RuntimeCount++;
         }
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvLowGetGpeInfo
  *
  * PARAMETERS:  GpeNumber           - Raw GPE number
  *              GpeBlock            - A GPE info block
  *
  * RETURN:      A GPE EventInfo struct. NULL if not a valid GPE (The GpeNumber
  *              is not within the specified GPE block)
  *
  * DESCRIPTION: Returns the EventInfo struct associated with this GPE. This is
  *              the low-level implementation of EvGetGpeEventInfo.
  *
  ******************************************************************************/
 
 ACPI_GPE_EVENT_INFO *
 AcpiEvLowGetGpeInfo (
     UINT32                  GpeNumber,
     ACPI_GPE_BLOCK_INFO     *GpeBlock)
 {
     UINT32                  GpeIndex;
 
 
     /*
      * Validate that the GpeNumber is within the specified GpeBlock.
      * (Two steps)
      */
     if (!GpeBlock ||
         (GpeNumber < GpeBlock->BlockBaseNumber))
     {
         return (NULL);
     }
 
     GpeIndex = GpeNumber - GpeBlock->BlockBaseNumber;
     if (GpeIndex >= GpeBlock->GpeCount)
     {
         return (NULL);
     }
 
     return (&GpeBlock->EventInfo[GpeIndex]);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvGetGpeEventInfo
  *
  * PARAMETERS:  GpeDevice           - Device node. NULL for GPE0/GPE1
  *              GpeNumber           - Raw GPE number
  *
  * RETURN:      A GPE EventInfo struct. NULL if not a valid GPE
  *
  * DESCRIPTION: Returns the EventInfo struct associated with this GPE.
  *              Validates the GpeBlock and the GpeNumber
  *
  *              Should be called only when the GPE lists are semaphore locked
  *              and not subject to change.
  *
  ******************************************************************************/
 
 ACPI_GPE_EVENT_INFO *
 AcpiEvGetGpeEventInfo (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_GPE_EVENT_INFO     *GpeInfo;
     UINT32                  i;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     /* A NULL GpeDevice means use the FADT-defined GPE block(s) */
 
     if (!GpeDevice)
     {
         /* Examine GPE Block 0 and 1 (These blocks are permanent) */
 
         for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++)
         {
             GpeInfo = AcpiEvLowGetGpeInfo (GpeNumber,
                         AcpiGbl_GpeFadtBlocks[i]);
             if (GpeInfo)
             {
                 return (GpeInfo);
             }
         }
 
         /* The GpeNumber was not in the range of either FADT GPE block */
 
         return (NULL);
     }
 
     /* A Non-NULL GpeDevice means this is a GPE Block Device */
 
     ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice);
     if (!ObjDesc ||
         !ObjDesc->Device.GpeBlock)
     {
         return (NULL);
     }
 
     return (AcpiEvLowGetGpeInfo (GpeNumber, ObjDesc->Device.GpeBlock));
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvGpeDetect
  *
  * PARAMETERS:  GpeXruptList        - Interrupt block for this interrupt.
  *                                    Can have multiple GPE blocks attached.
  *
  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
  *
  * DESCRIPTION: Detect if any GP events have occurred. This function is
  *              executed at interrupt level.
  *
  ******************************************************************************/
 
 UINT32
 AcpiEvGpeDetect (
     ACPI_GPE_XRUPT_INFO     *GpeXruptList)
 {
     ACPI_STATUS             Status;
     ACPI_GPE_BLOCK_INFO     *GpeBlock;
     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
     UINT32                  IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
     UINT8                   EnabledStatusByte;
     UINT32                  StatusReg;
     UINT32                  EnableReg;
     ACPI_CPU_FLAGS          Flags;
     UINT32                  i;
     UINT32                  j;
 
 
     ACPI_FUNCTION_NAME (EvGpeDetect);
 
     /* Check for the case where there are no GPEs */
 
     if (!GpeXruptList)
     {
         return (IntStatus);
     }
 
     /*
      * We need to obtain the GPE lock for both the data structs and registers
      * Note: Not necessary to obtain the hardware lock, since the GPE
      * registers are owned by the GpeLock.
      */
     Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
 
     /* Examine all GPE blocks attached to this interrupt level */
 
     GpeBlock = GpeXruptList->GpeBlockListHead;
     while (GpeBlock)
     {
         /*
          * Read all of the 8-bit GPE status and enable registers in this GPE
          * block, saving all of them. Find all currently active GP events.
          */
         for (i = 0; i < GpeBlock->RegisterCount; i++)
         {
             /* Get the next status/enable pair */
 
             GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
 
             /*
              * Optimization: If there are no GPEs enabled within this
              * register, we can safely ignore the entire register.
              */
             if (!(GpeRegisterInfo->EnableForRun |
                   GpeRegisterInfo->EnableForWake))
             {
                 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
                     "Ignore disabled registers for GPE%02X-GPE%02X: "
                     "RunEnable=%02X, WakeEnable=%02X\n",
                     GpeRegisterInfo->BaseGpeNumber,
                     GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
                     GpeRegisterInfo->EnableForRun,
                     GpeRegisterInfo->EnableForWake));
                 continue;
             }
 
             /* Read the Status Register */
 
             Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);
             if (ACPI_FAILURE (Status))
             {
                 goto UnlockAndExit;
             }
 
             /* Read the Enable Register */
 
             Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress);
             if (ACPI_FAILURE (Status))
             {
                 goto UnlockAndExit;
             }
 
             ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
                 "Read registers for GPE%02X-GPE%02X: Status=%02X, Enable=%02X, "
                 "RunEnable=%02X, WakeEnable=%02X\n",
                 GpeRegisterInfo->BaseGpeNumber,
                 GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
                 StatusReg, EnableReg,
                 GpeRegisterInfo->EnableForRun,
                 GpeRegisterInfo->EnableForWake));
 
             /* Check if there is anything active at all in this register */
 
             EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
             if (!EnabledStatusByte)
             {
                 /* No active GPEs in this register, move on */
 
                 continue;
             }
 
             /* Now look at the individual GPEs in this byte register */
 
             for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
             {
                 /* Examine one GPE bit */
 
                 if (EnabledStatusByte & (1 << j))
                 {
                     /*
                      * Found an active GPE. Dispatch the event to a handler
                      * or method.
                      */
                     IntStatus |= AcpiEvGpeDispatch (GpeBlock->Node,
                         &GpeBlock->EventInfo[((ACPI_SIZE) i *
                             ACPI_GPE_REGISTER_WIDTH) + j],
                         j + GpeRegisterInfo->BaseGpeNumber);
                 }
             }
         }
 
         GpeBlock = GpeBlock->Next;
     }
 
 UnlockAndExit:
 
     AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
     return (IntStatus);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvAsynchExecuteGpeMethod
  *
  * PARAMETERS:  Context (GpeEventInfo) - Info for this GPE
  *
  * RETURN:      None
  *
  * DESCRIPTION: Perform the actual execution of a GPE control method. This
  *              function is called from an invocation of AcpiOsExecute and
  *              therefore does NOT execute at interrupt level - so that
  *              the control method itself is not executed in the context of
  *              an interrupt handler.
  *
  ******************************************************************************/
 
 static void ACPI_SYSTEM_XFACE
 AcpiEvAsynchExecuteGpeMethod (
     void                    *Context)
 {
     ACPI_GPE_EVENT_INFO     *GpeEventInfo = Context;
     ACPI_STATUS             Status;
     ACPI_GPE_EVENT_INFO     *LocalGpeEventInfo;
     ACPI_EVALUATE_INFO      *Info;
     ACPI_GPE_NOTIFY_INFO    *Notify;
 
 
     ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod);
 
 
     /* Allocate a local GPE block */
 
     LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO));
     if (!LocalGpeEventInfo)
     {
         ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
             "while handling a GPE"));
         return_VOID;
     }
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
     if (ACPI_FAILURE (Status))
     {
         return_VOID;
     }
 
     /* Must revalidate the GpeNumber/GpeBlock */
 
     if (!AcpiEvValidGpeEvent (GpeEventInfo))
     {
         Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
         return_VOID;
     }
 
     /*
      * Take a snapshot of the GPE info for this level - we copy the info to
      * prevent a race condition with RemoveHandler/RemoveBlock.
      */
     ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo,
         sizeof (ACPI_GPE_EVENT_INFO));
 
     Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
     if (ACPI_FAILURE (Status))
     {
         return_VOID;
     }
 
     /* Do the correct dispatch - normal method or implicit notify */
 
     switch (LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
     {
     case ACPI_GPE_DISPATCH_NOTIFY:
 
         /*
          * Implicit notify.
          * Dispatch a DEVICE_WAKE notify to the appropriate handler.
          * NOTE: the request is queued for execution after this method
          * completes. The notify handlers are NOT invoked synchronously
          * from this thread -- because handlers may in turn run other
          * control methods.
          *
          * June 2012: Expand implicit notify mechanism to support
          * notifies on multiple device objects.
          */
         Notify = LocalGpeEventInfo->Dispatch.NotifyList;
         while (ACPI_SUCCESS (Status) && Notify)
         {
             Status = AcpiEvQueueNotifyRequest (Notify->DeviceNode,
                         ACPI_NOTIFY_DEVICE_WAKE);
 
             Notify = Notify->Next;
         }
         break;
 
     case ACPI_GPE_DISPATCH_METHOD:
 
         /* Allocate the evaluation information block */
 
         Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
         if (!Info)
         {
             Status = AE_NO_MEMORY;
         }
         else
         {
             /*
              * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
              * _Lxx/_Exx control method that corresponds to this GPE
              */
             Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode;
             Info->Flags = ACPI_IGNORE_RETURN_VALUE;
 
             Status = AcpiNsEvaluate (Info);
             ACPI_FREE (Info);
         }
 
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "while evaluating GPE method [%4.4s]",
                 AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode)));
         }
-
         break;
 
     default:
         return_VOID; /* Should never happen */
     }
 
     /* Defer enabling of GPE until all notify handlers are done */
 
     Status = AcpiOsExecute (OSL_NOTIFY_HANDLER,
                 AcpiEvAsynchEnableGpe, LocalGpeEventInfo);
     if (ACPI_FAILURE (Status))
     {
         ACPI_FREE (LocalGpeEventInfo);
     }
     return_VOID;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvAsynchEnableGpe
  *
  * PARAMETERS:  Context (GpeEventInfo) - Info for this GPE
  *              Callback from AcpiOsExecute
  *
  * RETURN:      None
  *
  * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to
  *              complete (i.e., finish execution of Notify)
  *
  ******************************************************************************/
 
 static void ACPI_SYSTEM_XFACE
 AcpiEvAsynchEnableGpe (
     void                    *Context)
 {
     ACPI_GPE_EVENT_INFO     *GpeEventInfo = Context;
 
 
     (void) AcpiEvFinishGpe (GpeEventInfo);
 
     ACPI_FREE (GpeEventInfo);
     return;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvFinishGpe
  *
  * PARAMETERS:  GpeEventInfo        - Info for this GPE
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution
  *              of a GPE method or a synchronous or asynchronous GPE handler.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvFinishGpe (
     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
 {
     ACPI_STATUS             Status;
 
 
     if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
             ACPI_GPE_LEVEL_TRIGGERED)
     {
         /*
          * GPE is level-triggered, we clear the GPE status bit after
          * handling the event.
          */
         Status = AcpiHwClearGpe (GpeEventInfo);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
     }
 
     /*
      * Enable this GPE, conditionally. This means that the GPE will
      * only be physically enabled if the EnableForRun bit is set
      * in the EventInfo.
      */
     (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_CONDITIONAL_ENABLE);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvGpeDispatch
  *
  * PARAMETERS:  GpeDevice           - Device node. NULL for GPE0/GPE1
  *              GpeEventInfo        - Info for this GPE
  *              GpeNumber           - Number relative to the parent GPE block
  *
  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
  *
  * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
  *              or method (e.g. _Lxx/_Exx) handler.
  *
  *              This function executes at interrupt level.
  *
  ******************************************************************************/
 
 UINT32
 AcpiEvGpeDispatch (
     ACPI_NAMESPACE_NODE     *GpeDevice,
     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
     UINT32                  GpeNumber)
 {
     ACPI_STATUS             Status;
     UINT32                  ReturnValue;
 
 
     ACPI_FUNCTION_TRACE (EvGpeDispatch);
 
 
     /* Invoke global event handler if present */
 
     AcpiGpeCount++;
     if (AcpiGbl_GlobalEventHandler)
     {
         AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE, GpeDevice,
              GpeNumber, AcpiGbl_GlobalEventHandlerContext);
     }
 
     /*
      * If edge-triggered, clear the GPE status bit now. Note that
      * level-triggered events are cleared after the GPE is serviced.
      */
     if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
             ACPI_GPE_EDGE_TRIGGERED)
     {
         Status = AcpiHwClearGpe (GpeEventInfo);
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "Unable to clear GPE%02X", GpeNumber));
             return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
         }
     }
 
     /*
      * Always disable the GPE so that it does not keep firing before
      * any asynchronous activity completes (either from the execution
      * of a GPE method or an asynchronous GPE handler.)
      *
      * If there is no handler or method to run, just disable the
      * GPE and leave it disabled permanently to prevent further such
      * pointless events from firing.
      */
     Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status,
             "Unable to disable GPE%02X", GpeNumber));
         return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
     }
 
     /*
      * Dispatch the GPE to either an installed handler or the control
      * method associated with this GPE (_Lxx or _Exx). If a handler
      * exists, we invoke it and do not attempt to run the method.
      * If there is neither a handler nor a method, leave the GPE
      * disabled.
      */
     switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
     {
     case ACPI_GPE_DISPATCH_HANDLER:
 
         /* Invoke the installed handler (at interrupt level) */
 
         ReturnValue = GpeEventInfo->Dispatch.Handler->Address (
             GpeDevice, GpeNumber,
             GpeEventInfo->Dispatch.Handler->Context);
 
         /* If requested, clear (if level-triggered) and reenable the GPE */
 
         if (ReturnValue & ACPI_REENABLE_GPE)
         {
             (void) AcpiEvFinishGpe (GpeEventInfo);
         }
         break;
 
     case ACPI_GPE_DISPATCH_METHOD:
     case ACPI_GPE_DISPATCH_NOTIFY:
 
         /*
          * Execute the method associated with the GPE
          * NOTE: Level-triggered GPEs are cleared after the method completes.
          */
         Status = AcpiOsExecute (OSL_GPE_HANDLER,
                     AcpiEvAsynchExecuteGpeMethod, GpeEventInfo);
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "Unable to queue handler for GPE%02X - event disabled",
                 GpeNumber));
         }
         break;
 
     default:
 
         /*
          * No handler or method to run!
          * 03/2010: This case should no longer be possible. We will not allow
          * a GPE to be enabled if it has no handler or method.
          */
         ACPI_ERROR ((AE_INFO,
             "No handler or method for GPE%02X, disabling event",
             GpeNumber));
         break;
     }
 
     return_UINT32 (ACPI_INTERRUPT_HANDLED);
 }
 
 #endif /* !ACPI_REDUCED_HARDWARE */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evregion.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evregion.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/events/evregion.c	(revision 249699)
@@ -1,840 +1,819 @@
 /******************************************************************************
  *
  * Module Name: evregion - Operation Region support
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #define __EVREGION_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #define _COMPONENT          ACPI_EVENTS
         ACPI_MODULE_NAME    ("evregion")
 
 
 extern UINT8        AcpiGbl_DefaultAddressSpaces[];
 
 /* Local prototypes */
 
 static void
 AcpiEvOrphanEcRegMethod (
-    void);
+    ACPI_NAMESPACE_NODE     *EcDeviceNode);
 
 static ACPI_STATUS
 AcpiEvRegRun (
     ACPI_HANDLE             ObjHandle,
     UINT32                  Level,
     void                    *Context,
     void                    **ReturnValue);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvInitializeOpRegions
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Execute _REG methods for all Operation Regions that have
  *              an installed default region handler.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvInitializeOpRegions (
     void)
 {
     ACPI_STATUS             Status;
     UINT32                  i;
 
 
     ACPI_FUNCTION_TRACE (EvInitializeOpRegions);
 
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /* Run the _REG methods for OpRegions in each default address space */
 
     for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
     {
         /*
          * Make sure the installed handler is the DEFAULT handler. If not the
          * default, the _REG methods will have already been run (when the
          * handler was installed)
          */
         if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode,
                AcpiGbl_DefaultAddressSpaces[i]))
         {
             Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
                         AcpiGbl_DefaultAddressSpaces[i]);
         }
     }
 
     AcpiGbl_RegMethodsExecuted = TRUE;
 
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvAddressSpaceDispatch
  *
  * PARAMETERS:  RegionObj           - Internal region object
  *              FieldObj            - Corresponding field. Can be NULL.
  *              Function            - Read or Write operation
  *              RegionOffset        - Where in the region to read or write
  *              BitWidth            - Field width in bits (8, 16, 32, or 64)
  *              Value               - Pointer to in or out value, must be
  *                                    a full 64-bit integer
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Dispatch an address space or operation region access to
  *              a previously installed handler.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvAddressSpaceDispatch (
     ACPI_OPERAND_OBJECT     *RegionObj,
     ACPI_OPERAND_OBJECT     *FieldObj,
     UINT32                  Function,
     UINT32                  RegionOffset,
     UINT32                  BitWidth,
     UINT64                  *Value)
 {
     ACPI_STATUS             Status;
     ACPI_ADR_SPACE_HANDLER  Handler;
     ACPI_ADR_SPACE_SETUP    RegionSetup;
     ACPI_OPERAND_OBJECT     *HandlerDesc;
     ACPI_OPERAND_OBJECT     *RegionObj2;
     void                    *RegionContext = NULL;
     ACPI_CONNECTION_INFO    *Context;
 
 
     ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch);
 
 
     RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
     if (!RegionObj2)
     {
         return_ACPI_STATUS (AE_NOT_EXIST);
     }
 
     /* Ensure that there is a handler associated with this region */
 
     HandlerDesc = RegionObj->Region.Handler;
     if (!HandlerDesc)
     {
         ACPI_ERROR ((AE_INFO,
             "No handler for Region [%4.4s] (%p) [%s]",
             AcpiUtGetNodeName (RegionObj->Region.Node),
             RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
 
         return_ACPI_STATUS (AE_NOT_EXIST);
     }
 
     Context = HandlerDesc->AddressSpace.Context;
 
     /*
      * It may be the case that the region has never been initialized.
      * Some types of regions require special init code
      */
     if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
     {
         /* This region has not been initialized yet, do it */
 
         RegionSetup = HandlerDesc->AddressSpace.Setup;
         if (!RegionSetup)
         {
             /* No initialization routine, exit with error */
 
             ACPI_ERROR ((AE_INFO,
                 "No init routine for region(%p) [%s]",
                 RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
             return_ACPI_STATUS (AE_NOT_EXIST);
         }
 
         /*
          * We must exit the interpreter because the region setup will
          * potentially execute control methods (for example, the _REG method
          * for this region)
          */
         AcpiExExitInterpreter ();
 
         Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE,
                     Context, &RegionContext);
 
         /* Re-enter the interpreter */
 
         AcpiExEnterInterpreter ();
 
         /* Check for failure of the Region Setup */
 
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "During region initialization: [%s]",
                 AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
             return_ACPI_STATUS (Status);
         }
 
         /* Region initialization may have been completed by RegionSetup */
 
         if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
         {
             RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
 
             if (RegionObj2->Extra.RegionContext)
             {
                 /* The handler for this region was already installed */
 
                 ACPI_FREE (RegionContext);
             }
             else
             {
                 /*
                  * Save the returned context for use in all accesses to
                  * this particular region
                  */
                 RegionObj2->Extra.RegionContext = RegionContext;
             }
         }
     }
 
     /* We have everything we need, we can invoke the address space handler */
 
     Handler = HandlerDesc->AddressSpace.Handler;
 
     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
         "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
         &RegionObj->Region.Handler->AddressSpace, Handler,
         ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset),
         AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
 
 
     /*
      * Special handling for GenericSerialBus and GeneralPurposeIo:
      * There are three extra parameters that must be passed to the
      * handler via the context:
      *   1) Connection buffer, a resource template from Connection() op.
      *   2) Length of the above buffer.
      *   3) Actual access length from the AccessAs() op.
      */
     if (((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) ||
             (RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) &&
         Context &&
         FieldObj)
     {
         /* Get the Connection (ResourceTemplate) buffer */
 
         Context->Connection = FieldObj->Field.ResourceBuffer;
         Context->Length = FieldObj->Field.ResourceLength;
         Context->AccessLength = FieldObj->Field.AccessLength;
     }
 
     if (!(HandlerDesc->AddressSpace.HandlerFlags &
             ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
     {
         /*
          * For handlers other than the default (supplied) handlers, we must
          * exit the interpreter because the handler *might* block -- we don't
          * know what it will do, so we can't hold the lock on the intepreter.
          */
         AcpiExExitInterpreter();
     }
 
     /* Call the handler */
 
     Status = Handler (Function,
         (RegionObj->Region.Address + RegionOffset), BitWidth, Value,
         Context, RegionObj2->Extra.RegionContext);
 
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]",
             AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
     }
 
     if (!(HandlerDesc->AddressSpace.HandlerFlags &
             ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
     {
         /*
          * We just returned from a non-default handler, we must re-enter the
          * interpreter
          */
        AcpiExEnterInterpreter ();
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvDetachRegion
  *
  * PARAMETERS:  RegionObj           - Region Object
  *              AcpiNsIsLocked      - Namespace Region Already Locked?
  *
  * RETURN:      None
  *
  * DESCRIPTION: Break the association between the handler and the region
  *              this is a two way association.
  *
  ******************************************************************************/
 
 void
 AcpiEvDetachRegion(
     ACPI_OPERAND_OBJECT     *RegionObj,
     BOOLEAN                 AcpiNsIsLocked)
 {
     ACPI_OPERAND_OBJECT     *HandlerObj;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_OPERAND_OBJECT     **LastObjPtr;
     ACPI_ADR_SPACE_SETUP    RegionSetup;
     void                    **RegionContext;
     ACPI_OPERAND_OBJECT     *RegionObj2;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (EvDetachRegion);
 
 
     RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
     if (!RegionObj2)
     {
         return_VOID;
     }
     RegionContext = &RegionObj2->Extra.RegionContext;
 
     /* Get the address handler from the region object */
 
     HandlerObj = RegionObj->Region.Handler;
     if (!HandlerObj)
     {
         /* This region has no handler, all done */
 
         return_VOID;
     }
 
     /* Find this region in the handler's list */
 
     ObjDesc = HandlerObj->AddressSpace.RegionList;
     LastObjPtr = &HandlerObj->AddressSpace.RegionList;
 
     while (ObjDesc)
     {
         /* Is this the correct Region? */
 
         if (ObjDesc == RegionObj)
         {
             ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
                 "Removing Region %p from address handler %p\n",
                 RegionObj, HandlerObj));
 
             /* This is it, remove it from the handler's list */
 
             *LastObjPtr = ObjDesc->Region.Next;
             ObjDesc->Region.Next = NULL;        /* Must clear field */
 
             if (AcpiNsIsLocked)
             {
                 Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
                 if (ACPI_FAILURE (Status))
                 {
                     return_VOID;
                 }
             }
 
             /* Now stop region accesses by executing the _REG method */
 
             Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_DISCONNECT);
             if (ACPI_FAILURE (Status))
             {
                 ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]",
                     AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
             }
 
             if (AcpiNsIsLocked)
             {
                 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
                 if (ACPI_FAILURE (Status))
                 {
                     return_VOID;
                 }
             }
 
             /*
              * If the region has been activated, call the setup handler with
              * the deactivate notification
              */
             if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)
             {
                 RegionSetup = HandlerObj->AddressSpace.Setup;
                 Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE,
                     HandlerObj->AddressSpace.Context, RegionContext);
 
                 /* Init routine may fail, Just ignore errors */
 
                 if (ACPI_FAILURE (Status))
                 {
                     ACPI_EXCEPTION ((AE_INFO, Status,
                         "from region handler - deactivate, [%s]",
                         AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
                 }
 
                 RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
             }
 
             /*
              * Remove handler reference in the region
              *
              * NOTE: this doesn't mean that the region goes away, the region
              * is just inaccessible as indicated to the _REG method
              *
              * If the region is on the handler's list, this must be the
              * region's handler
              */
             RegionObj->Region.Handler = NULL;
             AcpiUtRemoveReference (HandlerObj);
 
             return_VOID;
         }
 
         /* Walk the linked list of handlers */
 
         LastObjPtr = &ObjDesc->Region.Next;
         ObjDesc = ObjDesc->Region.Next;
     }
 
     /* If we get here, the region was not in the handler's region list */
 
     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
         "Cannot remove region %p from address handler %p\n",
         RegionObj, HandlerObj));
 
     return_VOID;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvAttachRegion
  *
  * PARAMETERS:  HandlerObj          - Handler Object
  *              RegionObj           - Region Object
  *              AcpiNsIsLocked      - Namespace Region Already Locked?
  *
  * RETURN:      None
  *
  * DESCRIPTION: Create the association between the handler and the region
  *              this is a two way association.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvAttachRegion (
     ACPI_OPERAND_OBJECT     *HandlerObj,
     ACPI_OPERAND_OBJECT     *RegionObj,
     BOOLEAN                 AcpiNsIsLocked)
 {
 
     ACPI_FUNCTION_TRACE (EvAttachRegion);
 
 
     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
         "Adding Region [%4.4s] %p to address handler %p [%s]\n",
         AcpiUtGetNodeName (RegionObj->Region.Node),
         RegionObj, HandlerObj,
         AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
 
     /* Link this region to the front of the handler's list */
 
     RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
     HandlerObj->AddressSpace.RegionList = RegionObj;
 
     /* Install the region's handler */
 
     if (RegionObj->Region.Handler)
     {
         return_ACPI_STATUS (AE_ALREADY_EXISTS);
     }
 
     RegionObj->Region.Handler = HandlerObj;
     AcpiUtAddReference (HandlerObj);
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    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->RelativePathname = 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:    AcpiEvExecuteRegMethods
  *
  * PARAMETERS:  Node            - Namespace node for the device
  *              SpaceId         - The address space ID
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Run all _REG methods for the input Space ID;
  *              Note: assumes namespace is locked, or system init time.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiEvExecuteRegMethods (
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_ADR_SPACE_TYPE     SpaceId)
 {
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (EvExecuteRegMethods);
 
 
     /*
      * Run all _REG methods for all Operation Regions for this space ID. This
      * is a separate walk in order to handle any interdependencies between
      * regions and _REG methods. (i.e. handlers must be installed for all
      * regions of this Space ID before we can run any _REG methods)
      */
     Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
                 ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL,
                 &SpaceId, NULL);
 
     /* Special case for EC: handle "orphan" _REG methods with no region */
 
     if (SpaceId == ACPI_ADR_SPACE_EC)
     {
-        AcpiEvOrphanEcRegMethod ();
+        AcpiEvOrphanEcRegMethod (Node);
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvRegRun
  *
  * PARAMETERS:  WalkNamespace callback
  *
  * DESCRIPTION: Run _REG method for region objects of the requested spaceID
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiEvRegRun (
     ACPI_HANDLE             ObjHandle,
     UINT32                  Level,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_ADR_SPACE_TYPE     SpaceId;
     ACPI_STATUS             Status;
 
 
     SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context);
 
     /* Convert and validate the device handle */
 
     Node = AcpiNsValidateHandle (ObjHandle);
     if (!Node)
     {
         return (AE_BAD_PARAMETER);
     }
 
     /*
      * We only care about regions.and objects that are allowed to have address
      * space handlers
      */
     if ((Node->Type != ACPI_TYPE_REGION) &&
         (Node != AcpiGbl_RootNode))
     {
         return (AE_OK);
     }
 
     /* Check for an existing internal object */
 
     ObjDesc = AcpiNsGetAttachedObject (Node);
     if (!ObjDesc)
     {
         /* No object, just exit */
 
         return (AE_OK);
     }
 
     /* Object is a Region */
 
     if (ObjDesc->Region.SpaceId != SpaceId)
     {
         /* This region is for a different address space, just ignore it */
 
         return (AE_OK);
     }
 
     Status = AcpiEvExecuteRegMethod (ObjDesc, ACPI_REG_CONNECT);
     return (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiEvOrphanEcRegMethod
  *
- * PARAMETERS:  None
+ * PARAMETERS:  EcDeviceNode        - Namespace node for an EC device
  *
  * RETURN:      None
  *
  * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
  *              device. This is a _REG method that has no corresponding region
  *              within the EC device scope. The orphan _REG method appears to
  *              have been enabled by the description of the ECDT in the ACPI
  *              specification: "The availability of the region space can be
  *              detected by providing a _REG method object underneath the
  *              Embedded Controller device."
  *
- *              To quickly access the EC device, we use the EC_ID that appears
- *              within the ECDT. Otherwise, we would need to perform a time-
- *              consuming namespace walk, executing _HID methods to find the
- *              EC device.
+ *              To quickly access the EC device, we use the EcDeviceNode used
+ *              during EC handler installation. Otherwise, we would need to
+ *              perform a time consuming namespace walk, executing _HID
+ *              methods to find the EC device.
  *
+ *  MUTEX:      Assumes the namespace is locked
+ *
  ******************************************************************************/
 
 static void
 AcpiEvOrphanEcRegMethod (
-    void)
+    ACPI_NAMESPACE_NODE     *EcDeviceNode)
 {
-    ACPI_TABLE_ECDT         *Table;
+    ACPI_HANDLE             RegMethod;
+    ACPI_NAMESPACE_NODE     *NextNode;
     ACPI_STATUS             Status;
     ACPI_OBJECT_LIST        Args;
     ACPI_OBJECT             Objects[2];
-    ACPI_NAMESPACE_NODE     *EcDeviceNode;
-    ACPI_NAMESPACE_NODE     *RegMethod;
-    ACPI_NAMESPACE_NODE     *NextNode;
 
 
     ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod);
 
 
-    /* Get the ECDT (if present in system) */
-
-    Status = AcpiGetTable (ACPI_SIG_ECDT, 0,
-        ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Table));
-    if (ACPI_FAILURE (Status))
+    if (!EcDeviceNode)
     {
         return_VOID;
     }
 
-    /* We need a valid EC_ID string */
-
-    if (!(*Table->Id))
-    {
-        return_VOID;
-    }
-
     /* Namespace is currently locked, must release */
 
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
 
-    /* Get a handle to the EC device referenced in the ECDT */
-
-    Status = AcpiGetHandle (NULL,
-        ACPI_CAST_PTR (char, Table->Id),
-        ACPI_CAST_PTR (ACPI_HANDLE, &EcDeviceNode));
-    if (ACPI_FAILURE (Status))
-    {
-        goto Exit;
-    }
-
     /* Get a handle to a _REG method immediately under the EC device */
 
-    Status = AcpiGetHandle (EcDeviceNode,
-        METHOD_NAME__REG, ACPI_CAST_PTR (ACPI_HANDLE, &RegMethod));
+    Status = AcpiGetHandle (EcDeviceNode, METHOD_NAME__REG, &RegMethod);
     if (ACPI_FAILURE (Status))
     {
-        goto Exit;
+        goto Exit; /* There is no _REG method present */
     }
 
     /*
      * Execute the _REG method only if there is no Operation Region in
      * this scope with the Embedded Controller space ID. Otherwise, it
      * will already have been executed. Note, this allows for Regions
      * with other space IDs to be present; but the code below will then
-     * execute the _REG method with the EC space ID argument.
+     * execute the _REG method with the EmbeddedControl SpaceID argument.
      */
     NextNode = AcpiNsGetNextNode (EcDeviceNode, NULL);
     while (NextNode)
     {
         if ((NextNode->Type == ACPI_TYPE_REGION) &&
             (NextNode->Object) &&
             (NextNode->Object->Region.SpaceId == ACPI_ADR_SPACE_EC))
         {
-            goto Exit; /* Do not execute _REG */
+            goto Exit; /* Do not execute the _REG */
         }
+
         NextNode = AcpiNsGetNextNode (EcDeviceNode, NextNode);
     }
 
-    /* Evaluate the _REG(EC,Connect) method */
+    /* Evaluate the _REG(EmbeddedControl,Connect) method */
 
     Args.Count = 2;
     Args.Pointer = Objects;
     Objects[0].Type = ACPI_TYPE_INTEGER;
     Objects[0].Integer.Value = ACPI_ADR_SPACE_EC;
     Objects[1].Type = ACPI_TYPE_INTEGER;
     Objects[1].Integer.Value = ACPI_REG_CONNECT;
 
     Status = AcpiEvaluateObject (RegMethod, NULL, &Args, NULL);
 
 Exit:
     /* We ignore all errors from above, don't care */
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     return_VOID;
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/events
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/events	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/events	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/events
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/components/events:r249197-249698
   Merged /vendor-sys/acpica/dist/source/components/events:r249111-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exconfig.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exconfig.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exconfig.c	(revision 249699)
@@ -1,689 +1,689 @@
 /******************************************************************************
  *
  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __EXCONFIG_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_EXECUTER
         ACPI_MODULE_NAME    ("exconfig")
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiExAddTable (
     UINT32                  TableIndex,
     ACPI_NAMESPACE_NODE     *ParentNode,
     ACPI_OPERAND_OBJECT     **DdbHandle);
 
 static ACPI_STATUS
 AcpiExRegionRead (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  Length,
     UINT8                   *Buffer);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExAddTable
  *
  * PARAMETERS:  Table               - Pointer to raw table
  *              ParentNode          - Where to load the table (scope)
  *              DdbHandle           - Where to return the table handle.
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Common function to Install and Load an ACPI table with a
  *              returned table handle.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiExAddTable (
     UINT32                  TableIndex,
     ACPI_NAMESPACE_NODE     *ParentNode,
     ACPI_OPERAND_OBJECT     **DdbHandle)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
     ACPI_OWNER_ID           OwnerId;
 
 
     ACPI_FUNCTION_TRACE (ExAddTable);
 
 
     /* Create an object to be the table handle */
 
     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
     if (!ObjDesc)
     {
         return_ACPI_STATUS (AE_NO_MEMORY);
     }
 
     /* Init the table handle */
 
     ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
     ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE;
     *DdbHandle = ObjDesc;
 
     /* Install the new table into the local data structures */
 
     ObjDesc->Reference.Value = TableIndex;
 
     /* Add the table to the namespace */
 
     Status = AcpiNsLoadTable (TableIndex, ParentNode);
     if (ACPI_FAILURE (Status))
     {
         AcpiUtRemoveReference (ObjDesc);
         *DdbHandle = NULL;
         return_ACPI_STATUS (Status);
     }
 
     /* Execute any module-level code that was found in the table */
 
     AcpiExExitInterpreter ();
     AcpiNsExecModuleCodeList ();
     AcpiExEnterInterpreter ();
 
     /*
      * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
      * responsible for discovering any new wake GPEs by running _PRW methods
      * that may have been loaded by this table.
      */
     Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
     if (ACPI_SUCCESS (Status))
     {
         AcpiEvUpdateGpes (OwnerId);
     }
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExLoadTableOp
  *
  * PARAMETERS:  WalkState           - Current state with operands
  *              ReturnDesc          - Where to store the return object
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Load an ACPI table from the RSDT/XSDT
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExLoadTableOp (
     ACPI_WALK_STATE         *WalkState,
     ACPI_OPERAND_OBJECT     **ReturnDesc)
 {
     ACPI_STATUS             Status;
     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
     ACPI_NAMESPACE_NODE     *ParentNode;
     ACPI_NAMESPACE_NODE     *StartNode;
     ACPI_NAMESPACE_NODE     *ParameterNode = NULL;
     ACPI_OPERAND_OBJECT     *DdbHandle;
     ACPI_TABLE_HEADER       *Table;
     UINT32                  TableIndex;
 
 
     ACPI_FUNCTION_TRACE (ExLoadTableOp);
 
 
     /* Validate lengths for the Signature, OemId, and OemTableId strings */
 
     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_AML_STRING_LIMIT);
     }
 
     /* 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] != AML_ROOT_PREFIX) &&
             (Operand[4]->String.Pointer[0] != AML_PARENT_PREFIX))
         {
             /*
              * Path is not absolute, so it will be relative to the node
              * referenced by the RootPathString (or the NS root if omitted)
              */
             StartNode = ParentNode;
         }
 
         /* Find the node referenced by the ParameterPathString */
 
         Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
                     ACPI_NS_SEARCH_PARENT, &ParameterNode);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
     }
 
     /* Load the table into the namespace */
 
     Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /* Parameter Data (optional) */
 
     if (ParameterNode)
     {
         /* Store the parameter data into the optional parameter object */
 
         Status = AcpiExStore (Operand[5],
                     ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode),
                     WalkState);
         if (ACPI_FAILURE (Status))
         {
             (void) AcpiExUnloadTable (DdbHandle);
 
             AcpiUtRemoveReference (DdbHandle);
             return_ACPI_STATUS (Status);
         }
     }
 
     Status = AcpiGetTableByIndex (TableIndex, &Table);
     if (ACPI_SUCCESS (Status))
     {
         ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
         AcpiTbPrintTableHeader (0, Table);
     }
 
     /* Invoke table handler if present */
 
     if (AcpiGbl_TableHandler)
     {
         (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
                     AcpiGbl_TableHandlerContext);
     }
 
     *ReturnDesc = DdbHandle;
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExRegionRead
  *
  * PARAMETERS:  ObjDesc         - Region descriptor
  *              Length          - Number of bytes to read
  *              Buffer          - Pointer to where to put the data
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Read data from an operation region. The read starts from the
  *              beginning of the region.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiExRegionRead (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  Length,
     UINT8                   *Buffer)
 {
     ACPI_STATUS             Status;
     UINT64                  Value;
     UINT32                  RegionOffset = 0;
     UINT32                  i;
 
 
     /* Bytewise reads */
 
     for (i = 0; i < Length; i++)
     {
         Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ,
                     RegionOffset, 8, &Value);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
         *Buffer = (UINT8) Value;
         Buffer++;
         RegionOffset++;
     }
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExLoadOp
  *
  * PARAMETERS:  ObjDesc         - Region or Buffer/Field where the table will be
  *                                obtained
  *              Target          - Where a handle to the table will be stored
  *              WalkState       - Current state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Load an ACPI table from a field or operation region
  *
  * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer
  *       objects before this code is reached.
  *
  *       If source is an operation region, it must refer to SystemMemory, as
  *       per the ACPI specification.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExLoadOp (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     ACPI_OPERAND_OBJECT     *Target,
     ACPI_WALK_STATE         *WalkState)
 {
     ACPI_OPERAND_OBJECT     *DdbHandle;
     ACPI_TABLE_HEADER       *Table;
     ACPI_TABLE_DESC         TableDesc;
     UINT32                  TableIndex;
     ACPI_STATUS             Status;
     UINT32                  Length;
 
 
     ACPI_FUNCTION_TRACE (ExLoadOp);
 
 
     ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC));
 
     /* Source Object can be either an OpRegion or a Buffer/Field */
 
     switch (ObjDesc->Common.Type)
     {
     case ACPI_TYPE_REGION:
 
         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
             "Load table from Region %p\n", ObjDesc));
 
         /* Region must be SystemMemory (from ACPI spec) */
 
         if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY)
         {
             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
         }
 
         /*
          * If the Region Address and Length have not been previously evaluated,
          * evaluate them now and save the results.
          */
         if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
         {
             Status = AcpiDsGetRegionArguments (ObjDesc);
             if (ACPI_FAILURE (Status))
             {
                 return_ACPI_STATUS (Status);
             }
         }
 
         /* Get the table header first so we can get the table length */
 
         Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
         if (!Table)
         {
             return_ACPI_STATUS (AE_NO_MEMORY);
         }
 
         Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER),
                     ACPI_CAST_PTR (UINT8, Table));
         Length = Table->Length;
         ACPI_FREE (Table);
 
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
 
         /* Must have at least an ACPI table header */
 
         if (Length < sizeof (ACPI_TABLE_HEADER))
         {
             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
         }
 
         /*
          * The original implementation simply mapped the table, with no copy.
          * However, the memory region is not guaranteed to remain stable and
          * we must copy the table to a local buffer. For example, the memory
          * region is corrupted after suspend on some machines. Dynamically
          * loaded tables are usually small, so this overhead is minimal.
          *
          * The latest implementation (5/2009) does not use a mapping at all.
          * We use the low-level operation region interface to read the table
          * instead of the obvious optimization of using a direct mapping.
          * This maintains a consistent use of operation regions across the
          * entire subsystem. This is important if additional processing must
          * be performed in the (possibly user-installed) operation region
          * handler. For example, AcpiExec and ASLTS depend on this.
          */
 
         /* Allocate a buffer for the table */
 
         TableDesc.Pointer = ACPI_ALLOCATE (Length);
         if (!TableDesc.Pointer)
         {
             return_ACPI_STATUS (AE_NO_MEMORY);
         }
 
         /* Read the entire table */
 
         Status = AcpiExRegionRead (ObjDesc, Length,
                     ACPI_CAST_PTR (UINT8, TableDesc.Pointer));
         if (ACPI_FAILURE (Status))
         {
             ACPI_FREE (TableDesc.Pointer);
             return_ACPI_STATUS (Status);
         }
 
         TableDesc.Address = ObjDesc->Region.Address;
         break;
 
 
     case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
 
         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
             "Load table from Buffer or Field %p\n", ObjDesc));
 
         /* Must have at least an ACPI table header */
 
         if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
         {
             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
         }
 
         /* Get the actual table length from the table header */
 
         Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
         Length = Table->Length;
 
         /* Table cannot extend beyond the buffer */
 
         if (Length > ObjDesc->Buffer.Length)
         {
             return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
         }
         if (Length < sizeof (ACPI_TABLE_HEADER))
         {
             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
         }
 
         /*
          * Copy the table from the buffer because the buffer could be modified
          * or even deleted in the future
          */
         TableDesc.Pointer = ACPI_ALLOCATE (Length);
         if (!TableDesc.Pointer)
         {
             return_ACPI_STATUS (AE_NO_MEMORY);
         }
 
         ACPI_MEMCPY (TableDesc.Pointer, Table, Length);
         TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer);
         break;
 
 
     default:
         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
     }
 
     /* Validate table checksum (will not get validated in TbAddTable) */
 
     Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length);
     if (ACPI_FAILURE (Status))
     {
         ACPI_FREE (TableDesc.Pointer);
         return_ACPI_STATUS (Status);
     }
 
     /* Complete the table descriptor */
 
     TableDesc.Length = Length;
     TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
 
     /* Install the new table into the local data structures */
 
     Status = AcpiTbAddTable (&TableDesc, &TableIndex);
     if (ACPI_FAILURE (Status))
     {
         /* Delete allocated table buffer */
 
         AcpiTbDeleteTable (&TableDesc);
         return_ACPI_STATUS (Status);
     }
 
     /*
      * Add the table to the namespace.
      *
      * Note: Load the table objects relative to the root of the namespace.
      * This appears to go against the ACPI specification, but we do it for
      * compatibility with other ACPI implementations.
      */
     Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle);
     if (ACPI_FAILURE (Status))
     {
         /* On error, TablePtr was deallocated above */
 
         return_ACPI_STATUS (Status);
     }
 
     /* Store the DdbHandle into the Target operand */
 
     Status = AcpiExStore (DdbHandle, Target, WalkState);
     if (ACPI_FAILURE (Status))
     {
         (void) AcpiExUnloadTable (DdbHandle);
 
         /* TablePtr was deallocated above */
 
         AcpiUtRemoveReference (DdbHandle);
         return_ACPI_STATUS (Status);
     }
 
     ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
     AcpiTbPrintTableHeader (0, TableDesc.Pointer);
 
     /* Remove the reference by added by AcpiExStore above */
 
     AcpiUtRemoveReference (DdbHandle);
 
     /* Invoke table handler if present */
 
     if (AcpiGbl_TableHandler)
     {
         (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer,
                     AcpiGbl_TableHandlerContext);
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExUnloadTable
  *
  * PARAMETERS:  DdbHandle           - Handle to a previously loaded table
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Unload an ACPI table
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExUnloadTable (
     ACPI_OPERAND_OBJECT     *DdbHandle)
 {
     ACPI_STATUS             Status = AE_OK;
     ACPI_OPERAND_OBJECT     *TableDesc = DdbHandle;
     UINT32                  TableIndex;
     ACPI_TABLE_HEADER       *Table;
 
 
     ACPI_FUNCTION_TRACE (ExUnloadTable);
 
 
     /*
      * Validate the handle
      * Although the handle is partially validated in AcpiExReconfiguration()
      * when it calls AcpiExResolveOperands(), the handle is more completely
      * validated here.
      *
      * Handle must be a valid operand object of type reference. Also, the
      * DdbHandle must still be marked valid (table has not been previously
      * unloaded)
      */
     if ((!DdbHandle) ||
         (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) ||
         (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
         (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
     {
-        return_ACPI_STATUS (AE_BAD_PARAMETER);
+        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
     }
 
     /* 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);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exfldio.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exfldio.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer/exfldio.c	(revision 249699)
@@ -1,1053 +1,1064 @@
 /******************************************************************************
  *
  * Module Name: exfldio - Aml Field I/O
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #define __EXFLDIO_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_EXECUTER
         ACPI_MODULE_NAME    ("exfldio")
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiExFieldDatumIo (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  FieldDatumByteOffset,
     UINT64                  *Value,
     UINT32                  ReadWrite);
 
 static BOOLEAN
 AcpiExRegisterOverflow (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT64                  Value);
 
 static ACPI_STATUS
 AcpiExSetupRegion (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  FieldDatumByteOffset);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExSetupRegion
  *
  * PARAMETERS:  ObjDesc                 - Field to be read or written
  *              FieldDatumByteOffset    - Byte offset of this datum within the
  *                                        parent field
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Common processing for AcpiExExtractFromField and
  *              AcpiExInsertIntoField. Initialize the Region if necessary and
  *              validate the request.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiExSetupRegion (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  FieldDatumByteOffset)
 {
     ACPI_STATUS             Status = AE_OK;
     ACPI_OPERAND_OBJECT     *RgnDesc;
     UINT8                   SpaceId;
 
 
     ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset);
 
 
     RgnDesc = ObjDesc->CommonField.RegionObj;
 
     /* We must have a valid region */
 
     if (RgnDesc->Common.Type != ACPI_TYPE_REGION)
     {
         ACPI_ERROR ((AE_INFO, "Needed Region, found type 0x%X (%s)",
             RgnDesc->Common.Type,
             AcpiUtGetObjectTypeName (RgnDesc)));
 
         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
     }
 
     SpaceId = RgnDesc->Region.SpaceId;
 
     /* Validate the Space ID */
 
     if (!AcpiIsValidSpaceId (SpaceId))
     {
         ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
         return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
     }
 
     /*
      * If the Region Address and Length have not been previously evaluated,
      * evaluate them now and save the results.
      */
     if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID))
     {
         Status = AcpiDsGetRegionArguments (RgnDesc);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
     }
 
     /*
      * Exit now for SMBus, GSBus or IPMI address space, it has a non-linear
      * address space and the request cannot be directly validated
      */
     if (SpaceId == ACPI_ADR_SPACE_SMBUS ||
         SpaceId == ACPI_ADR_SPACE_GSBUS ||
         SpaceId == ACPI_ADR_SPACE_IPMI)
     {
         /* SMBus or IPMI has a non-linear address space */
 
         return_ACPI_STATUS (AE_OK);
     }
 
 #ifdef ACPI_UNDER_DEVELOPMENT
     /*
      * If the Field access is AnyAcc, we can now compute the optimal
      * access (because we know know the length of the parent region)
      */
     if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
     {
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
     }
 #endif
 
     /*
      * Validate the request. The entire request from the byte offset for a
      * length of one field datum (access width) must fit within the region.
      * (Region length is specified in bytes)
      */
     if (RgnDesc->Region.Length <
             (ObjDesc->CommonField.BaseByteOffset + FieldDatumByteOffset +
             ObjDesc->CommonField.AccessByteWidth))
     {
         if (AcpiGbl_EnableInterpreterSlack)
         {
             /*
              * Slack mode only:  We will go ahead and allow access to this
              * field if it is within the region length rounded up to the next
              * access width boundary. ACPI_SIZE cast for 64-bit compile.
              */
             if (ACPI_ROUND_UP (RgnDesc->Region.Length,
                     ObjDesc->CommonField.AccessByteWidth) >=
                 ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset +
                     ObjDesc->CommonField.AccessByteWidth +
                     FieldDatumByteOffset))
             {
                 return_ACPI_STATUS (AE_OK);
             }
         }
 
         if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
         {
             /*
              * This is the case where the AccessType (AccWord, etc.) is wider
              * than the region itself. For example, a region of length one
              * byte, and a field with Dword access specified.
              */
             ACPI_ERROR ((AE_INFO,
                 "Field [%4.4s] access width (%u bytes) too large for region [%4.4s] (length %u)",
                 AcpiUtGetNodeName (ObjDesc->CommonField.Node),
                 ObjDesc->CommonField.AccessByteWidth,
                 AcpiUtGetNodeName (RgnDesc->Region.Node),
                 RgnDesc->Region.Length));
         }
 
         /*
          * Offset rounded up to next multiple of field width
          * exceeds region length, indicate an error
          */
         ACPI_ERROR ((AE_INFO,
             "Field [%4.4s] Base+Offset+Width %u+%u+%u is beyond end of region [%4.4s] (length %u)",
             AcpiUtGetNodeName (ObjDesc->CommonField.Node),
             ObjDesc->CommonField.BaseByteOffset,
             FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
             AcpiUtGetNodeName (RgnDesc->Region.Node),
             RgnDesc->Region.Length));
 
         return_ACPI_STATUS (AE_AML_REGION_LIMIT);
     }
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExAccessRegion
  *
  * PARAMETERS:  ObjDesc                 - Field to be read
  *              FieldDatumByteOffset    - Byte offset of this datum within the
  *                                        parent field
  *              Value                   - Where to store value (must at least
  *                                        64 bits)
  *              Function                - Read or Write flag plus other region-
  *                                        dependent flags
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Read or Write a single field datum to an Operation Region.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExAccessRegion (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  FieldDatumByteOffset,
     UINT64                  *Value,
     UINT32                  Function)
 {
     ACPI_STATUS             Status;
     ACPI_OPERAND_OBJECT     *RgnDesc;
     UINT32                  RegionOffset;
 
 
     ACPI_FUNCTION_TRACE (ExAccessRegion);
 
 
     /*
      * Ensure that the region operands are fully evaluated and verify
      * the validity of the request
      */
     Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * The physical address of this field datum is:
      *
      * 1) The base of the region, plus
      * 2) The base offset of the field, plus
      * 3) The current offset into the field
      */
     RgnDesc = ObjDesc->CommonField.RegionObj;
     RegionOffset =
         ObjDesc->CommonField.BaseByteOffset +
         FieldDatumByteOffset;
 
     if ((Function & ACPI_IO_MASK) == ACPI_READ)
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
     }
     else
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
     }
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
         " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n",
         AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
         RgnDesc->Region.SpaceId,
         ObjDesc->CommonField.AccessByteWidth,
         ObjDesc->CommonField.BaseByteOffset,
         FieldDatumByteOffset,
         ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset))));
 
     /* Invoke the appropriate AddressSpace/OpRegion handler */
 
     Status = AcpiEvAddressSpaceDispatch (RgnDesc, ObjDesc,
                 Function, RegionOffset,
                 ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
 
     if (ACPI_FAILURE (Status))
     {
         if (Status == AE_NOT_IMPLEMENTED)
         {
             ACPI_ERROR ((AE_INFO,
                 "Region %s (ID=%u) not implemented",
                 AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
                 RgnDesc->Region.SpaceId));
         }
         else if (Status == AE_NOT_EXIST)
         {
             ACPI_ERROR ((AE_INFO,
                 "Region %s (ID=%u) has no handler",
                 AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
                 RgnDesc->Region.SpaceId));
         }
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExRegisterOverflow
  *
  * PARAMETERS:  ObjDesc                 - Register(Field) to be written
  *              Value                   - Value to be stored
  *
  * RETURN:      TRUE if value overflows the field, FALSE otherwise
  *
  * DESCRIPTION: Check if a value is out of range of the field being written.
  *              Used to check if the values written to Index and Bank registers
  *              are out of range. Normally, the value is simply truncated
  *              to fit the field, but this case is most likely a serious
  *              coding error in the ASL.
  *
  ******************************************************************************/
 
 static BOOLEAN
 AcpiExRegisterOverflow (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT64                  Value)
 {
 
     if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
     {
         /*
          * The field is large enough to hold the maximum integer, so we can
          * never overflow it.
          */
         return (FALSE);
     }
 
     if (Value >= ((UINT64) 1 << ObjDesc->CommonField.BitLength))
     {
         /*
          * The Value is larger than the maximum value that can fit into
          * the register.
          */
         ACPI_ERROR ((AE_INFO,
             "Index value 0x%8.8X%8.8X overflows field width 0x%X",
             ACPI_FORMAT_UINT64 (Value),
             ObjDesc->CommonField.BitLength));
 
         return (TRUE);
     }
 
     /* The Value will fit into the field with no truncation */
 
     return (FALSE);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExFieldDatumIo
  *
  * PARAMETERS:  ObjDesc                 - Field to be read
  *              FieldDatumByteOffset    - Byte offset of this datum within the
  *                                        parent field
  *              Value                   - Where to store value (must be 64 bits)
  *              ReadWrite               - Read or Write flag
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
  *              demultiplexed here to handle the different types of fields
  *              (BufferField, RegionField, IndexField, BankField)
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiExFieldDatumIo (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT32                  FieldDatumByteOffset,
     UINT64                  *Value,
     UINT32                  ReadWrite)
 {
     ACPI_STATUS             Status;
     UINT64                  LocalValue;
 
 
     ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset);
 
 
     if (ReadWrite == ACPI_READ)
     {
         if (!Value)
         {
             LocalValue = 0;
 
             /* To support reads without saving return value */
             Value = &LocalValue;
         }
 
         /* Clear the entire return buffer first, [Very Important!] */
 
         *Value = 0;
     }
 
     /*
      * The four types of fields are:
      *
      * BufferField - Read/write from/to a Buffer
      * RegionField - Read/write from/to a Operation Region.
      * BankField   - Write to a Bank Register, then read/write from/to an
      *               OperationRegion
      * IndexField  - Write to an Index Register, then read/write from/to a
      *               Data Register
      */
     switch (ObjDesc->Common.Type)
     {
     case ACPI_TYPE_BUFFER_FIELD:
         /*
          * If the BufferField arguments have not been previously evaluated,
          * evaluate them now and save the results.
          */
         if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
         {
             Status = AcpiDsGetBufferFieldArguments (ObjDesc);
             if (ACPI_FAILURE (Status))
             {
                 return_ACPI_STATUS (Status);
             }
         }
 
         if (ReadWrite == ACPI_READ)
         {
             /*
              * Copy the data from the source buffer.
              * Length is the field width in bytes.
              */
             ACPI_MEMCPY (Value,
                 (ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
                     ObjDesc->BufferField.BaseByteOffset +
                     FieldDatumByteOffset,
                 ObjDesc->CommonField.AccessByteWidth);
         }
         else
         {
             /*
              * Copy the data to the target buffer.
              * Length is the field width in bytes.
              */
             ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer +
                 ObjDesc->BufferField.BaseByteOffset +
                 FieldDatumByteOffset,
                 Value, ObjDesc->CommonField.AccessByteWidth);
         }
 
         Status = AE_OK;
         break;
 
 
     case ACPI_TYPE_LOCAL_BANK_FIELD:
 
         /*
          * Ensure that the BankValue is not beyond the capacity of
          * the register
          */
         if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
                 (UINT64) ObjDesc->BankField.Value))
         {
             return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
         }
 
         /*
          * For BankFields, we must write the BankValue to the BankRegister
          * (itself a RegionField) before we can access the data.
          */
         Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
                     &ObjDesc->BankField.Value,
                     sizeof (ObjDesc->BankField.Value));
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
 
         /*
          * Now that the Bank has been selected, fall through to the
          * RegionField case and write the datum to the Operation Region
          */
 
         /*lint -fallthrough */
 
 
     case ACPI_TYPE_LOCAL_REGION_FIELD:
         /*
          * For simple RegionFields, we just directly access the owning
          * Operation Region.
          */
         Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
                     ReadWrite);
         break;
 
 
     case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
 
         /*
          * Ensure that the IndexValue is not beyond the capacity of
          * the register
          */
         if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
                 (UINT64) ObjDesc->IndexField.Value))
         {
             return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
         }
 
         /* Write the index value to the IndexRegister (itself a RegionField) */
 
         FieldDatumByteOffset += ObjDesc->IndexField.Value;
 
         ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
             "Write to Index Register: Value %8.8X\n",
             FieldDatumByteOffset));
 
         Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
                     &FieldDatumByteOffset,
                     sizeof (FieldDatumByteOffset));
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
 
         if (ReadWrite == ACPI_READ)
         {
             /* Read the datum from the DataRegister */
 
             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
                 "Read from Data Register\n"));
 
             Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
                         Value, sizeof (UINT64));
         }
         else
         {
             /* Write the datum to the DataRegister */
 
             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
                 "Write to Data Register: Value %8.8X%8.8X\n",
                 ACPI_FORMAT_UINT64 (*Value)));
 
             Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
                         Value, sizeof (UINT64));
         }
         break;
 
 
     default:
 
         ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %u",
             ObjDesc->Common.Type));
         Status = AE_AML_INTERNAL;
         break;
     }
 
     if (ACPI_SUCCESS (Status))
     {
         if (ReadWrite == ACPI_READ)
         {
             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
                 "Value Read %8.8X%8.8X, Width %u\n",
                 ACPI_FORMAT_UINT64 (*Value),
                 ObjDesc->CommonField.AccessByteWidth));
         }
         else
         {
             ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
                 "Value Written %8.8X%8.8X, Width %u\n",
                 ACPI_FORMAT_UINT64 (*Value),
                 ObjDesc->CommonField.AccessByteWidth));
         }
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExWriteWithUpdateRule
  *
  * PARAMETERS:  ObjDesc                 - Field to be written
  *              Mask                    - bitmask within field datum
  *              FieldValue              - Value to write
  *              FieldDatumByteOffset    - Offset of datum within field
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Apply the field update rule to a field write
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExWriteWithUpdateRule (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     UINT64                  Mask,
     UINT64                  FieldValue,
     UINT32                  FieldDatumByteOffset)
 {
     ACPI_STATUS             Status = AE_OK;
     UINT64                  MergedValue;
     UINT64                  CurrentValue;
 
 
     ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask);
 
 
     /* Start with the new bits  */
 
     MergedValue = FieldValue;
 
     /* If the mask is all ones, we don't need to worry about the update rule */
 
     if (Mask != ACPI_UINT64_MAX)
     {
         /* Decode the update rule */
 
         switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
         {
         case AML_FIELD_UPDATE_PRESERVE:
             /*
              * Check if update rule needs to be applied (not if mask is all
              * ones)  The left shift drops the bits we want to ignore.
              */
             if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
                            ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
             {
                 /*
                  * Read the current contents of the byte/word/dword containing
                  * the field, and merge with the new field value.
                  */
                 Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
                             &CurrentValue, ACPI_READ);
                 if (ACPI_FAILURE (Status))
                 {
                     return_ACPI_STATUS (Status);
                 }
 
                 MergedValue |= (CurrentValue & ~Mask);
             }
             break;
 
         case AML_FIELD_UPDATE_WRITE_AS_ONES:
 
             /* Set positions outside the field to all ones */
 
             MergedValue |= ~Mask;
             break;
 
         case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
 
             /* Set positions outside the field to all zeros */
 
             MergedValue &= Mask;
             break;
 
         default:
 
             ACPI_ERROR ((AE_INFO,
                 "Unknown UpdateRule value: 0x%X",
                 (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
             return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
         }
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
         "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
         ACPI_FORMAT_UINT64 (Mask),
         FieldDatumByteOffset,
         ObjDesc->CommonField.AccessByteWidth,
         ACPI_FORMAT_UINT64 (FieldValue),
         ACPI_FORMAT_UINT64 (MergedValue)));
 
     /* Write the merged value */
 
     Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
                 &MergedValue, ACPI_WRITE);
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExExtractFromField
  *
  * PARAMETERS:  ObjDesc             - Field to be read
  *              Buffer              - Where to store the field data
  *              BufferLength        - Length of Buffer
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Retrieve the current value of the given field
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExExtractFromField (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     void                    *Buffer,
     UINT32                  BufferLength)
 {
     ACPI_STATUS             Status;
     UINT64                  RawDatum;
     UINT64                  MergedDatum;
     UINT32                  FieldOffset = 0;
     UINT32                  BufferOffset = 0;
     UINT32                  BufferTailBits;
     UINT32                  DatumCount;
     UINT32                  FieldDatumCount;
     UINT32                  AccessBitWidth;
     UINT32                  i;
 
 
     ACPI_FUNCTION_TRACE (ExExtractFromField);
 
 
     /* Validate target buffer and clear it */
 
     if (BufferLength <
         ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength))
     {
         ACPI_ERROR ((AE_INFO,
             "Field size %u (bits) is too large for buffer (%u)",
             ObjDesc->CommonField.BitLength, BufferLength));
 
         return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
     }
 
     ACPI_MEMSET (Buffer, 0, BufferLength);
     AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
 
     /* Handle the simple case here */
 
     if ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
         (ObjDesc->CommonField.BitLength == AccessBitWidth))
     {
-        Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
+        if (BufferLength >= sizeof (UINT64))
+        {
+            Status = AcpiExFieldDatumIo (ObjDesc, 0, Buffer, ACPI_READ);
+        }
+        else
+        {
+            /* Use RawDatum (UINT64) to handle buffers < 64 bits */
+
+            Status = AcpiExFieldDatumIo (ObjDesc, 0, &RawDatum, ACPI_READ);
+            ACPI_MEMCPY (Buffer, &RawDatum, BufferLength);
+        }
+
         return_ACPI_STATUS (Status);
     }
 
 /* TBD: Move to common setup code */
 
     /* Field algorithm is limited to sizeof(UINT64), truncate if needed */
 
     if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
     {
         ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
         AccessBitWidth = sizeof (UINT64) * 8;
     }
 
     /* Compute the number of datums (access width data items) */
 
     DatumCount = ACPI_ROUND_UP_TO (
         ObjDesc->CommonField.BitLength, AccessBitWidth);
 
     FieldDatumCount = ACPI_ROUND_UP_TO (
         ObjDesc->CommonField.BitLength +
         ObjDesc->CommonField.StartFieldBitOffset, AccessBitWidth);
 
     /* Priming read from the field */
 
     Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
     MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
 
     /* Read the rest of the field */
 
     for (i = 1; i < FieldDatumCount; i++)
     {
         /* Get next input datum from the field */
 
         FieldOffset += ObjDesc->CommonField.AccessByteWidth;
         Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset,
                     &RawDatum, ACPI_READ);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
         }
 
         /*
          * Merge with previous datum if necessary.
          *
          * Note: Before the shift, check if the shift value will be larger than
          * the integer size. If so, there is no need to perform the operation.
          * This avoids the differences in behavior between different compilers
          * concerning shift values larger than the target data width.
          */
         if (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset <
             ACPI_INTEGER_BIT_SIZE)
         {
             MergedDatum |= RawDatum <<
                 (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
         }
 
         if (i == DatumCount)
         {
             break;
         }
 
         /* Write merged datum to target buffer */
 
         ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
             ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
                 BufferLength - BufferOffset));
 
         BufferOffset += ObjDesc->CommonField.AccessByteWidth;
         MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset;
     }
 
     /* Mask off any extra bits in the last datum */
 
     BufferTailBits = ObjDesc->CommonField.BitLength % AccessBitWidth;
     if (BufferTailBits)
     {
         MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
     }
 
     /* Write the last datum to the buffer */
 
     ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum,
         ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
             BufferLength - BufferOffset));
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiExInsertIntoField
  *
  * PARAMETERS:  ObjDesc             - Field to be written
  *              Buffer              - Data to be written
  *              BufferLength        - Length of Buffer
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Store the Buffer contents into the given field
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiExInsertIntoField (
     ACPI_OPERAND_OBJECT     *ObjDesc,
     void                    *Buffer,
     UINT32                  BufferLength)
 {
     void                    *NewBuffer;
     ACPI_STATUS             Status;
     UINT64                  Mask;
     UINT64                  WidthMask;
     UINT64                  MergedDatum;
     UINT64                  RawDatum = 0;
     UINT32                  FieldOffset = 0;
     UINT32                  BufferOffset = 0;
     UINT32                  BufferTailBits;
     UINT32                  DatumCount;
     UINT32                  FieldDatumCount;
     UINT32                  AccessBitWidth;
     UINT32                  RequiredLength;
     UINT32                  i;
 
 
     ACPI_FUNCTION_TRACE (ExInsertIntoField);
 
 
     /* Validate input buffer */
 
     NewBuffer = NULL;
     RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (
                         ObjDesc->CommonField.BitLength);
     /*
      * We must have a buffer that is at least as long as the field
      * we are writing to. This is because individual fields are
      * indivisible and partial writes are not supported -- as per
      * the ACPI specification.
      */
     if (BufferLength < RequiredLength)
     {
         /* We need to create a new buffer */
 
         NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength);
         if (!NewBuffer)
         {
             return_ACPI_STATUS (AE_NO_MEMORY);
         }
 
         /*
          * Copy the original data to the new buffer, starting
          * at Byte zero. All unused (upper) bytes of the
          * buffer will be 0.
          */
         ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength);
         Buffer = NewBuffer;
         BufferLength = RequiredLength;
     }
 
 /* TBD: Move to common setup code */
 
     /* Algo is limited to sizeof(UINT64), so cut the AccessByteWidth */
     if (ObjDesc->CommonField.AccessByteWidth > sizeof (UINT64))
     {
         ObjDesc->CommonField.AccessByteWidth = sizeof (UINT64);
     }
 
     AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
 
     /*
      * Create the bitmasks used for bit insertion.
      * Note: This if/else is used to bypass compiler differences with the
      * shift operator
      */
     if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
     {
         WidthMask = ACPI_UINT64_MAX;
     }
     else
     {
         WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
     }
 
     Mask = WidthMask &
         ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
 
     /* Compute the number of datums (access width data items) */
 
     DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength,
         AccessBitWidth);
 
     FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength +
         ObjDesc->CommonField.StartFieldBitOffset,
         AccessBitWidth);
 
     /* Get initial Datum from the input buffer */
 
     ACPI_MEMCPY (&RawDatum, Buffer,
         ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
             BufferLength - BufferOffset));
 
     MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
 
     /* Write the entire field */
 
     for (i = 1; i < FieldDatumCount; i++)
     {
         /* Write merged datum to the target field */
 
         MergedDatum &= Mask;
         Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask,
                     MergedDatum, FieldOffset);
         if (ACPI_FAILURE (Status))
         {
             goto Exit;
         }
 
         FieldOffset += ObjDesc->CommonField.AccessByteWidth;
 
         /*
          * Start new output datum by merging with previous input datum
          * if necessary.
          *
          * Note: Before the shift, check if the shift value will be larger than
          * the integer size. If so, there is no need to perform the operation.
          * This avoids the differences in behavior between different compilers
          * concerning shift values larger than the target data width.
          */
         if ((AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset) <
             ACPI_INTEGER_BIT_SIZE)
         {
             MergedDatum = RawDatum >>
                 (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset);
         }
         else
         {
             MergedDatum = 0;
         }
 
         Mask = WidthMask;
 
         if (i == DatumCount)
         {
             break;
         }
 
         /* Get the next input datum from the buffer */
 
         BufferOffset += ObjDesc->CommonField.AccessByteWidth;
         ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset,
             ACPI_MIN(ObjDesc->CommonField.AccessByteWidth,
                  BufferLength - BufferOffset));
 
         MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset;
     }
 
     /* Mask off any extra bits in the last datum */
 
     BufferTailBits = (ObjDesc->CommonField.BitLength +
         ObjDesc->CommonField.StartFieldBitOffset) % AccessBitWidth;
     if (BufferTailBits)
     {
         Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits);
     }
 
     /* Write the last datum to the field */
 
     MergedDatum &= Mask;
     Status = AcpiExWriteWithUpdateRule (ObjDesc,
                 Mask, MergedDatum, FieldOffset);
 
 Exit:
     /* Free temporary buffer if we used one */
 
     if (NewBuffer)
     {
         ACPI_FREE (NewBuffer);
     }
     return_ACPI_STATUS (Status);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/executer
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/components/executer:r249197-249698
   Merged /vendor-sys/acpica/dist/source/components/executer:r249111-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware/hwxface.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware/hwxface.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware/hwxface.c	(revision 249699)
@@ -1,640 +1,641 @@
 /******************************************************************************
  *
  * Module Name: hwxface - Public ACPICA hardware interfaces
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #include 
 #include 
 #include 
 
 #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);
     }
 
     /* Initialize entire 64-bit return value to zero */
 
     *ReturnValue = 0;
     Value = 0;
 
     /*
      * Two address spaces supported: Memory or IO. PCI_Config is
      * not supported here because the GAS structure is insufficient
      */
     if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
     {
         Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
                     Address, ReturnValue, Reg->BitWidth);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
     }
     else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
     {
         Width = Reg->BitWidth;
         if (Width == 64)
         {
             Width = 32; /* Break into two 32-bit transfers */
         }
 
         Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
                     Address, &Value, Width);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
         *ReturnValue = Value;
 
         if (Reg->BitWidth == 64)
         {
             /* Read the top 32 bits */
 
             Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
                         (Address + 4), &Value, 32);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
             *ReturnValue |= ((UINT64) Value << 32);
         }
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "Read:  %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n",
         ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth,
         ACPI_FORMAT_UINT64 (Address),
         AcpiUtGetRegionName (Reg->SpaceId)));
 
     return (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiRead)
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiWrite
  *
  * PARAMETERS:  Value               - Value to be written
  *              Reg                 - GAS register structure
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Write to either memory or IO space.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiWrite (
     UINT64                  Value,
     ACPI_GENERIC_ADDRESS    *Reg)
 {
     UINT32                  Width;
     UINT64                  Address;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_NAME (AcpiWrite);
 
 
     /* Validate contents of the GAS register. Allow 64-bit transfers */
 
     Status = AcpiHwValidateRegister (Reg, 64, &Address);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     /*
      * Two address spaces supported: Memory or IO. PCI_Config is
      * not supported here because the GAS structure is insufficient
      */
     if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
     {
         Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
                     Address, Value, Reg->BitWidth);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
     }
     else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
     {
         Width = Reg->BitWidth;
         if (Width == 64)
         {
             Width = 32; /* Break into two 32-bit transfers */
         }
 
         Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
                     Address, ACPI_LODWORD (Value), Width);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
         if (Reg->BitWidth == 64)
         {
             Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
                         (Address + 4), ACPI_HIDWORD (Value), 32);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
         }
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "Wrote: %8.8X%8.8X width %2d   to %8.8X%8.8X (%s)\n",
         ACPI_FORMAT_UINT64 (Value), Reg->BitWidth,
         ACPI_FORMAT_UINT64 (Address),
         AcpiUtGetRegionName (Reg->SpaceId)));
 
     return (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiWrite)
 
 
 #if (!ACPI_REDUCED_HARDWARE)
 /*******************************************************************************
  *
  * FUNCTION:    AcpiReadBitRegister
  *
  * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
  *              ReturnValue     - Value that was read from the register,
  *                                normalized to bit position zero.
  *
  * RETURN:      Status and the value read from the specified Register. Value
  *              returned is normalized to bit0 (is shifted all the way right)
  *
  * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock.
  *
  * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
  *              PM2 Control.
  *
  * Note: The hardware lock is not required when reading the ACPI bit registers
  *       since almost all of them are single bit and it does not matter that
  *       the parent hardware register can be split across two physical
  *       registers. The only multi-bit field is SLP_TYP in the PM1 control
  *       register, but this field does not cross an 8-bit boundary (nor does
  *       it make much sense to actually read this field.)
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiReadBitRegister (
     UINT32                  RegisterId,
     UINT32                  *ReturnValue)
 {
     ACPI_BIT_REGISTER_INFO  *BitRegInfo;
     UINT32                  RegisterValue;
     UINT32                  Value;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId);
 
 
     /* Get the info structure corresponding to the requested ACPI Register */
 
     BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
     if (!BitRegInfo)
     {
         return_ACPI_STATUS (AE_BAD_PARAMETER);
     }
 
     /* Read the entire parent register */
 
     Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
                 &RegisterValue);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /* Normalize the value that was read, mask off other bits */
 
     Value = ((RegisterValue & BitRegInfo->AccessBitMask)
                 >> BitRegInfo->BitPosition);
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n",
         RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value));
 
     *ReturnValue = Value;
     return_ACPI_STATUS (AE_OK);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiReadBitRegister)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiWriteBitRegister
  *
  * PARAMETERS:  RegisterId      - ID of ACPI Bit Register to access
  *              Value           - Value to write to the register, in bit
  *                                position zero. The bit is automatically
  *                                shifted to the correct position.
  *
  * RETURN:      Status
  *
  * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock
  *              since most operations require a read/modify/write sequence.
  *
  * SUPPORTS:    Bit fields in PM1 Status, PM1 Enable, PM1 Control, and
  *              PM2 Control.
  *
  * Note that at this level, the fact that there may be actually two
  * hardware registers (A and B - and B may not exist) is abstracted.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiWriteBitRegister (
     UINT32                  RegisterId,
     UINT32                  Value)
 {
     ACPI_BIT_REGISTER_INFO  *BitRegInfo;
     ACPI_CPU_FLAGS          LockFlags;
     UINT32                  RegisterValue;
     ACPI_STATUS             Status = AE_OK;
 
 
     ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId);
 
 
     /* Get the info structure corresponding to the requested ACPI Register */
 
     BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
     if (!BitRegInfo)
     {
         return_ACPI_STATUS (AE_BAD_PARAMETER);
     }
 
     LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock);
 
     /*
      * At this point, we know that the parent register is one of the
      * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control
      */
     if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS)
     {
         /*
          * 1) Case for PM1 Enable, PM1 Control, and PM2 Control
          *
          * Perform a register read to preserve the bits that we are not
          * interested in
          */
         Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister,
                     &RegisterValue);
         if (ACPI_FAILURE (Status))
         {
             goto UnlockAndExit;
         }
 
         /*
          * Insert the input bit into the value that was just read
          * and write the register
          */
         ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
             BitRegInfo->AccessBitMask, Value);
 
         Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister,
                     RegisterValue);
     }
     else
     {
         /*
          * 2) Case for PM1 Status
          *
          * The Status register is different from the rest. Clear an event
          * by writing 1, writing 0 has no effect. So, the only relevant
          * information is the single bit we're interested in, all others
          * should be written as 0 so they will be left unchanged.
          */
         RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value,
             BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
 
         /* No need to write the register if value is all zeros */
 
         if (RegisterValue)
         {
             Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS,
                         RegisterValue);
         }
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n",
         RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue));
 
 
 UnlockAndExit:
 
     AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags);
     return_ACPI_STATUS (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister)
 
 #endif /* !ACPI_REDUCED_HARDWARE */
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiGetSleepTypeData
  *
  * PARAMETERS:  SleepState          - Numeric sleep state
  *              *SleepTypeA         - Where SLP_TYPa is returned
  *              *SleepTypeB         - Where SLP_TYPb is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested
  *              sleep state via the appropriate \_Sx object.
  *
  *  The sleep state package returned from the corresponding \_Sx_ object
  *  must contain at least one integer.
  *
  *  March 2005:
  *  Added support for a package that contains two integers. This
  *  goes against the ACPI specification which defines this object as a
  *  package with one encoded DWORD integer. However, existing practice
  *  by many BIOS vendors is to return a package with 2 or more integer
  *  elements, at least one per sleep type (A/B).
  *
  *  January 2013:
  *  Therefore, we must be prepared to accept a package with either a
  *  single integer or multiple integers.
  *
  *  The single integer DWORD format is as follows:
  *      BYTE 0 - Value for the PM1A SLP_TYP register
  *      BYTE 1 - Value for the PM1B SLP_TYP register
  *      BYTE 2-3 - Reserved
  *
  *  The dual integer format is as follows:
  *      Integer 0 - Value for the PM1A SLP_TYP register
  *      Integer 1 - Value for the PM1A SLP_TYP register
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiGetSleepTypeData (
     UINT8                   SleepState,
     UINT8                   *SleepTypeA,
     UINT8                   *SleepTypeB)
 {
     ACPI_STATUS             Status;
     ACPI_EVALUATE_INFO      *Info;
     ACPI_OPERAND_OBJECT     **Elements;
 
 
     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);
     }
 
     /*
      * Evaluate the \_Sx namespace object containing the register values
      * for this state
      */
-    Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]);
+    Info->RelativePathname = ACPI_CAST_PTR (
+        char, AcpiGbl_SleepStateNames[SleepState]);
     Status = AcpiNsEvaluate (Info);
     if (ACPI_FAILURE (Status))
     {
         goto Cleanup;
     }
 
     /* Must have a return object */
 
     if (!Info->ReturnObject)
     {
         ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]",
-            Info->Pathname));
+            Info->RelativePathname));
         Status = AE_AML_NO_RETURN_VALUE;
         goto Cleanup;
     }
 
     /* Return object must be of type Package */
 
     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;
         goto Cleanup1;
     }
 
     /*
      * Any warnings about the package length or the object types have
      * already been issued by the predefined name module -- there is no
      * need to repeat them here.
      */
     Elements = Info->ReturnObject->Package.Elements;
     switch (Info->ReturnObject->Package.Count)
     {
     case 0:
         Status = AE_AML_PACKAGE_LIMIT;
         break;
 
     case 1:
         if (Elements[0]->Common.Type != ACPI_TYPE_INTEGER)
         {
             Status = AE_AML_OPERAND_TYPE;
             break;
         }
 
         /* A valid _Sx_ package with one integer */
 
         *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
         *SleepTypeB = (UINT8) (Elements[0]->Integer.Value >> 8);
         break;
 
     case 2:
     default:
         if ((Elements[0]->Common.Type != ACPI_TYPE_INTEGER) ||
             (Elements[1]->Common.Type != ACPI_TYPE_INTEGER))
         {
             Status = AE_AML_OPERAND_TYPE;
             break;
         }
 
         /* A valid _Sx_ package with two integers */
 
         *SleepTypeA = (UINT8) Elements[0]->Integer.Value;
         *SleepTypeB = (UINT8) Elements[1]->Integer.Value;
         break;
     }
 
 Cleanup1:
     AcpiUtRemoveReference (Info->ReturnObject);
 
 Cleanup:
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status,
-            "While evaluating Sleep State [%s]", Info->Pathname));
+            "While evaluating Sleep State [%s]", Info->RelativePathname));
     }
 
     ACPI_FREE (Info);
     return_ACPI_STATUS (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData)
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/hardware
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/components/hardware:r247225-249698
   Merged /vendor-sys/acpica/dist/source/components/hardware:r246849-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsarguments.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsarguments.c	(nonexistent)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsarguments.c	(revision 249699)
@@ -0,0 +1,303 @@
+/******************************************************************************
+ *
+ * Module Name: nsarguments - Validation of args for ACPI predefined methods
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2013, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+
+#define _COMPONENT          ACPI_NAMESPACE
+        ACPI_MODULE_NAME    ("nsarguments")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiNsCheckArgumentTypes
+ *
+ * PARAMETERS:  Info            - Method execution information block
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Check the incoming argument count and all argument types
+ *              against the argument type list for a predefined name.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsCheckArgumentTypes (
+    ACPI_EVALUATE_INFO          *Info)
+{
+    UINT16                      ArgTypeList;
+    UINT8                       ArgCount;
+    UINT8                       ArgType;
+    UINT8                       UserArgType;
+    UINT32                      i;
+
+
+    /* If not a predefined name, cannot typecheck args */
+
+    if (!Info->Predefined)
+    {
+        return;
+    }
+
+    ArgTypeList = Info->Predefined->Info.ArgumentList;
+    ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
+
+    /* Typecheck all arguments */
+
+    for (i = 0; ((i < ArgCount) && (i < Info->ParamCount)); i++)
+    {
+        ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
+        UserArgType = Info->Parameters[i]->Common.Type;
+
+        if (UserArgType != ArgType)
+        {
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS,
+                "Argument #%u type mismatch - "
+                "Found [%s], ACPI requires [%s]", (i + 1),
+                AcpiUtGetTypeName (UserArgType),
+                AcpiUtGetTypeName (ArgType)));
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiNsCheckAcpiCompliance
+ *
+ * PARAMETERS:  Pathname        - Full pathname to the node (for error msgs)
+ *              Node            - Namespace node for the method/object
+ *              Predefined      - Pointer to entry in predefined name table
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Check that the declared parameter count (in ASL/AML) for a
+ *              predefined name is what is expected (matches what is defined in
+ *              the ACPI specification for this predefined name.)
+ *
+ ******************************************************************************/
+
+void
+AcpiNsCheckAcpiCompliance (
+    char                        *Pathname,
+    ACPI_NAMESPACE_NODE         *Node,
+    const ACPI_PREDEFINED_INFO  *Predefined)
+{
+    UINT32                      AmlParamCount;
+    UINT32                      RequiredParamCount;
+
+
+    if (!Predefined)
+    {
+        return;
+    }
+
+    /* Get the ACPI-required arg count from the predefined info table */
+
+    RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList);
+
+    /*
+     * If this object is not a control method, we can check if the ACPI
+     * spec requires that it be a method.
+     */
+    if (Node->Type != ACPI_TYPE_METHOD)
+    {
+        if (RequiredParamCount > 0)
+        {
+            /* Object requires args, must be implemented as a method */
+
+            ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                "Object (%s) must be a control method with %u arguments",
+                AcpiUtGetTypeName (Node->Type), RequiredParamCount));
+        }
+        else if (!RequiredParamCount && !Predefined->Info.ExpectedBtypes)
+        {
+            /* Object requires no args and no return value, must be a method */
+
+            ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                "Object (%s) must be a control method "
+                "with no arguments and no return value",
+                AcpiUtGetTypeName (Node->Type)));
+        }
+
+        return;
+    }
+
+    /*
+     * This is a control method.
+     * Check that the ASL/AML-defined parameter count for this method
+     * matches the ACPI-required parameter count
+     *
+     * Some methods are allowed to have a "minimum" number of args (_SCP)
+     * because their definition in ACPI has changed over time.
+     *
+     * Note: These are BIOS errors in the declaration of the object
+     */
+    AmlParamCount = Node->Object->Method.ParamCount;
+
+    if (AmlParamCount < RequiredParamCount)
+    {
+        ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+            "Insufficient arguments - "
+            "ASL declared %u, ACPI requires %u",
+            AmlParamCount, RequiredParamCount));
+    }
+    else if ((AmlParamCount > RequiredParamCount) &&
+        !(Predefined->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
+    {
+        ACPI_BIOS_ERROR_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+            "Excess arguments - "
+            "ASL declared %u, ACPI requires %u",
+            AmlParamCount, RequiredParamCount));
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiNsCheckArgumentCount
+ *
+ * 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 incoming argument count matches the declared
+ *              parameter count (in the ASL/AML) for an object.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsCheckArgumentCount (
+    char                        *Pathname,
+    ACPI_NAMESPACE_NODE         *Node,
+    UINT32                      UserParamCount,
+    const ACPI_PREDEFINED_INFO  *Predefined)
+{
+    UINT32                      AmlParamCount;
+    UINT32                      RequiredParamCount;
+
+
+    if (!Predefined)
+    {
+        /*
+         * Not a predefined name. Check the incoming user argument count
+         * against the count that is specified in the method/object.
+         */
+        if (Node->Type != ACPI_TYPE_METHOD)
+        {
+            if (UserParamCount)
+            {
+                ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                    "%u arguments were passed to a non-method ACPI object (%s)",
+                    UserParamCount, AcpiUtGetTypeName (Node->Type)));
+            }
+
+            return;
+        }
+
+        /*
+         * This is a control method. Check the parameter count.
+         * We can only check the incoming argument count against the
+         * argument count declared for the method in the ASL/AML.
+         *
+         * Emit a message if too few or too many arguments have been passed
+         * by the caller.
+         *
+         * Note: Too many arguments will 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.
+         */
+        AmlParamCount = Node->Object->Method.ParamCount;
+
+        if (UserParamCount < AmlParamCount)
+        {
+            ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                "Insufficient arguments - "
+                "Caller passed %u, method requires %u",
+                UserParamCount, AmlParamCount));
+        }
+        else if (UserParamCount > AmlParamCount)
+        {
+            ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                "Excess arguments - "
+                "Caller passed %u, method requires %u",
+                UserParamCount, AmlParamCount));
+        }
+
+        return;
+    }
+
+    /*
+     * This is a predefined name. Validate the user-supplied parameter
+     * count against the ACPI specification. We don't validate against
+     * the method itself because what is important here is that the
+     * caller is in conformance with the spec. (The arg count for the
+     * method was checked against the ACPI spec earlier.)
+     *
+     * Some methods are allowed to have a "minimum" number of args (_SCP)
+     * because their definition in ACPI has changed over time.
+     */
+    RequiredParamCount = METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList);
+
+    if (UserParamCount < RequiredParamCount)
+    {
+        ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+            "Insufficient arguments - "
+            "Caller passed %u, ACPI requires %u",
+            UserParamCount, RequiredParamCount));
+    }
+    else if ((UserParamCount > RequiredParamCount) &&
+        !(Predefined->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
+    {
+        ACPI_INFO_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+            "Excess arguments - "
+            "Caller passed %u, ACPI requires %u",
+            UserParamCount, RequiredParamCount));
+    }
+}

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsarguments.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nseval.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nseval.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nseval.c	(revision 249699)
@@ -1,488 +1,526 @@
 /*******************************************************************************
  *
  * Module Name: nseval - Object evaluation, includes control method execution
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __NSEVAL_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #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
+ *                  RelativePath    - 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;
-
-    if (!Info->ResolvedNode)
+    if (!Info->Node)
     {
         /*
-         * Get the actual namespace node for the target object if we need to.
-         * Handles these cases:
+         * Get the actual namespace node for the target object if we
+         * need to. Handles these cases:
          *
-         * 1) Null node, Pathname (absolute path)
-         * 2) Node, Pathname (path relative to Node)
-         * 3) Node, Null Pathname
+         * 1) Null node, valid pathname from root (absolute path)
+         * 2) Node and valid pathname (path relative to Node)
+         * 3) Node, Null pathname
          */
-        Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname,
-                    ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode);
+        Status = AcpiNsGetNode (Info->PrefixNode, Info->RelativePathname,
+            ACPI_NS_NO_UPSEARCH, &Info->Node);
         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.
+     * 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)
+    if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS)
     {
-        Info->ResolvedNode =
-            ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object);
+        Info->Node = ACPI_CAST_PTR (
+            ACPI_NAMESPACE_NODE, Info->Node->Object);
     }
 
-    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname,
-        Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode)));
+    /* Complete the info block initialization */
 
-    Node = Info->ResolvedNode;
+    Info->ReturnObject = NULL;
+    Info->NodeFlags = Info->Node->Flags;
+    Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node);
 
+    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n",
+        Info->RelativePathname, Info->Node,
+        AcpiNsGetAttachedObject (Info->Node)));
+
+    /* Get info if we have a predefined name (_HID, etc.) */
+
+    Info->Predefined = AcpiUtMatchPredefinedMethod (Info->Node->Name.Ascii);
+
+    /* Get the full pathname to the object, for use in warning messages */
+
+    Info->FullPathname = AcpiNsGetExternalPathname (Info->Node);
+    if (!Info->FullPathname)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /* Count the number of arguments being passed in */
+
+    Info->ParamCount = 0;
+    if (Info->Parameters)
+    {
+        while (Info->Parameters[Info->ParamCount])
+        {
+            Info->ParamCount++;
+        }
+
+        /* Warn on impossible argument count */
+
+        if (Info->ParamCount > ACPI_METHOD_NUM_ARGS)
+        {
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, ACPI_WARN_ALWAYS,
+                "Excess arguments (%u) - using only %u",
+                Info->ParamCount, ACPI_METHOD_NUM_ARGS));
+
+            Info->ParamCount = ACPI_METHOD_NUM_ARGS;
+        }
+    }
+
     /*
-     * Two major cases here:
+     * For predefined names: Check that the declared argument count
+     * matches the ACPI spec -- otherwise this is a BIOS error.
+     */
+    AcpiNsCheckAcpiCompliance (Info->FullPathname, Info->Node,
+        Info->Predefined);
+
+    /*
+     * For all names: Check that the incoming argument count for
+     * this method/object matches the actual ASL/AML definition.
+     */
+    AcpiNsCheckArgumentCount (Info->FullPathname, Info->Node,
+        Info->ParamCount, Info->Predefined);
+
+    /* For predefined names: Typecheck all incoming arguments */
+
+    AcpiNsCheckArgumentTypes (Info);
+
+    /*
+     * Three major evaluation cases:
      *
-     * 1) The object is a control method -- execute it
-     * 2) The object is not a method -- just return it's current value
+     * 1) Object types that cannot be evaluated by definition
+     * 2) The object is a control method -- execute it
+     * 3) The object is not a method -- just return it's current value
      */
-    if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD)
+    switch (AcpiNsGetType (Info->Node))
     {
+    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:
         /*
-         * 1) Object is a control method - execute it
+         * 1) Disallow evaluation of certain object types. For these,
+         *    object evaluation is undefined and not supported.
          */
+        ACPI_ERROR ((AE_INFO,
+            "%s: Evaluation of object type [%s] is not supported",
+            Info->FullPathname,
+            AcpiUtGetTypeName (Info->Node->Type)));
 
+        Status = AE_TYPE;
+        goto Cleanup;
+
+    case ACPI_TYPE_METHOD:
+        /*
+         * 2) 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);
+            ACPI_ERROR ((AE_INFO, "%s: Method has no attached sub-object",
+                Info->FullPathname));
+            Status = AE_NULL_OBJECT;
+            goto Cleanup;
         }
 
-        /* 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",
+            "**** Execute method [%s] at AML address %p length %X\n",
+            Info->FullPathname,
             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
-    {
+        break;
+
+    default:
         /*
-         * 2) Object is not a method, return its current value
-         *
-         * Disallow certain object types. For these, "evaluation" is undefined.
+         * 3) All other non-method objects -- get the current object value
          */
-        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.
+         * Some 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
+         * the Node 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.
+         * 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 */
+        /* TBD: ResolveNodeToValue has a strange interface, fix */
 
-        Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL);
+        Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->Node);
+
+        Status = AcpiExResolveNodeToValue (ACPI_CAST_INDIRECT_PTR (
+            ACPI_NAMESPACE_NODE, &Info->ReturnObject), NULL);
         AcpiExExitInterpreter ();
 
-        /*
-         * If AcpiExResolveNodeToValue() succeeded, the return value was placed
-         * in ResolvedNode.
-         */
-        if (ACPI_SUCCESS (Status))
+        if (ACPI_FAILURE (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)));
+            goto Cleanup;
         }
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returned object %p [%s]\n",
+            Info->ReturnObject,
+            AcpiUtGetObjectTypeName (Info->ReturnObject)));
+
+        Status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */
+        break;
     }
 
     /*
-     * 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.
+     * For predefined names, check the return value against the ACPI
+     * specification. Some incorrect return value types are repaired.
      */
-    (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount,
-                Status, &Info->ReturnObject);
+    (void) AcpiNsCheckReturnValue (Info->Node, Info, 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));
+        "*** Completed evaluation of object %s ***\n",
+        Info->RelativePathname));
 
+Cleanup:
     /*
      * Namespace was unlocked by the handling AcpiNs* function, so we
-     * just return
+     * just free the pathname and return
      */
+    ACPI_FREE (Info->FullPathname);
+    Info->FullPathname = NULL;
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsExecModuleCodeList
  *
  * PARAMETERS:  None
  *
  * RETURN:      None. Exceptions during method execution are ignored, since
  *              we cannot abort a table load.
  *
  * DESCRIPTION: Execute all elements of the global module-level code list.
  *              Each element is executed as a single control method.
  *
  ******************************************************************************/
 
 void
 AcpiNsExecModuleCodeList (
     void)
 {
     ACPI_OPERAND_OBJECT     *Prev;
     ACPI_OPERAND_OBJECT     *Next;
     ACPI_EVALUATE_INFO      *Info;
     UINT32                  MethodCount = 0;
 
 
     ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
 
 
     /* Exit now if the list is empty */
 
     Next = AcpiGbl_ModuleCodeList;
     if (!Next)
     {
         return_VOID;
     }
 
     /* Allocate the evaluation information block */
 
     Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
     if (!Info)
     {
         return_VOID;
     }
 
     /* Walk the list, executing each "method" */
 
     while (Next)
     {
         Prev = Next;
         Next = Next->Method.Mutex;
 
         /* Clear the link field and execute the method */
 
         Prev->Method.Mutex = NULL;
         AcpiNsExecModuleCode (Prev, Info);
         MethodCount++;
 
         /* Delete the (temporary) method object */
 
         AcpiUtRemoveReference (Prev);
     }
 
     ACPI_INFO ((AE_INFO,
         "Executed %u blocks of module-level executable AML code",
         MethodCount));
 
     ACPI_FREE (Info);
     AcpiGbl_ModuleCodeList = NULL;
     return_VOID;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsExecModuleCode
  *
  * PARAMETERS:  MethodObj           - Object container for the module-level code
  *              Info                - Info block for method evaluation
  *
  * RETURN:      None. Exceptions during method execution are ignored, since
  *              we cannot abort a table load.
  *
  * DESCRIPTION: Execute a control method containing a block of module-level
  *              executable AML code. The control method is temporarily
  *              installed to the root node, then evaluated.
  *
  ******************************************************************************/
 
 static void
 AcpiNsExecModuleCode (
     ACPI_OPERAND_OBJECT     *MethodObj,
     ACPI_EVALUATE_INFO      *Info)
 {
     ACPI_OPERAND_OBJECT     *ParentObj;
     ACPI_NAMESPACE_NODE     *ParentNode;
     ACPI_OBJECT_TYPE        Type;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (NsExecModuleCode);
 
 
     /*
      * Get the parent node. We cheat by using the NextObject field
      * of the method object descriptor.
      */
     ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
                     MethodObj->Method.NextObject);
     Type = AcpiNsGetType (ParentNode);
 
     /*
      * Get the region handler and save it in the method object. We may need
      * this if an operation region declaration causes a _REG method to be run.
      *
      * We can't do this in AcpiPsLinkModuleCode because
      * AcpiGbl_RootNode->Object is NULL at PASS1.
      */
     if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
     {
         MethodObj->Method.Dispatch.Handler =
             ParentNode->Object->Device.Handler;
     }
 
     /* Must clear NextObject (AcpiNsAttachObject needs the field) */
 
     MethodObj->Method.NextObject = NULL;
 
     /* Initialize the evaluation information block */
 
     ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
     Info->PrefixNode = ParentNode;
 
     /*
      * Get the currently attached parent object. Add a reference, because the
      * ref count will be decreased when the method object is installed to
      * the parent node.
      */
     ParentObj = AcpiNsGetAttachedObject (ParentNode);
     if (ParentObj)
     {
         AcpiUtAddReference (ParentObj);
     }
 
     /* Install the method (module-level code) in the parent node */
 
     Status = AcpiNsAttachObject (ParentNode, MethodObj,
                 ACPI_TYPE_METHOD);
     if (ACPI_FAILURE (Status))
     {
         goto Exit;
     }
 
     /* Execute the parent node as a control method */
 
     Status = AcpiNsEvaluate (Info);
 
     ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n",
         MethodObj->Method.AmlStart));
 
     /* Delete a possible implicit return value (in slack mode) */
 
     if (Info->ReturnObject)
     {
         AcpiUtRemoveReference (Info->ReturnObject);
     }
 
     /* Detach the temporary method object */
 
     AcpiNsDetachObject (ParentNode);
 
     /* Restore the original parent object */
 
     if (ParentObj)
     {
         Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
     }
     else
     {
         ParentNode->Type = (UINT8) Type;
     }
 
 Exit:
     if (ParentObj)
     {
         AcpiUtRemoveReference (ParentObj);
     }
     return_VOID;
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsinit.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsinit.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsinit.c	(revision 249699)
@@ -1,650 +1,650 @@
 /******************************************************************************
  *
  * Module Name: nsinit - namespace initialization
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #define __NSXFINIT_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #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:\n"));
 
     /* 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,
         "    Initialized %u/%u Regions %u/%u Fields %u/%u "
         "Buffers %u/%u Packages (%u nodes)\n",
         Info.OpRegionInit,  Info.OpRegionCount,
         Info.FieldInit,     Info.FieldCount,
         Info.BufferInit,    Info.BufferCount,
         Info.PackageInit,   Info.PackageCount, Info.ObjectCount));
 
     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
         "%u Control Methods found\n", Info.MethodCount));
     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
         "%u Op Regions found\n", Info.OpRegionCount));
 
     return_ACPI_STATUS (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsInitializeDevices
  *
  * PARAMETERS:  None
  *
  * RETURN:      ACPI_STATUS
  *
  * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
  *              This means running _INI on all present devices.
  *
  *              Note: We install PCI config space handler on region access,
  *              not here.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiNsInitializeDevices (
     void)
 {
     ACPI_STATUS             Status;
     ACPI_DEVICE_WALK_INFO   Info;
 
 
     ACPI_FUNCTION_TRACE (NsInitializeDevices);
 
 
     /* Init counters */
 
     Info.DeviceCount = 0;
     Info.Num_STA = 0;
     Info.Num_INI = 0;
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
         "Initializing Device/Processor/Thermal objects "
         "and executing _INI/_STA methods:\n"));
 
     /* 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->RelativePathname = METHOD_NAME__INI;
     Info.EvaluateInfo->Parameters = NULL;
     Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE;
 
     Status = AcpiNsEvaluate (Info.EvaluateInfo);
     if (ACPI_SUCCESS (Status))
     {
         Info.Num_INI++;
     }
 
     /* Walk namespace to execute all _INIs on present devices */
 
     Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
                 ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL);
 
     /*
      * Any _OSI requests should be completed by now. If the BIOS has
      * requested any Windows OSI strings, we will always truncate
      * I/O addresses to 16 bits -- for Windows compatibility.
      */
     if (AcpiGbl_OsiData >= ACPI_OSI_WIN_2000)
     {
         AcpiGbl_TruncateIoAddresses = TRUE;
     }
 
     ACPI_FREE (Info.EvaluateInfo);
     if (ACPI_FAILURE (Status))
     {
         goto ErrorExit;
     }
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
         "    Executed %u _INI methods requiring %u _STA executions "
         "(examined %u objects)\n",
         Info.Num_INI, Info.Num_STA, Info.DeviceCount));
 
     return_ACPI_STATUS (Status);
 
 
 ErrorExit:
     ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization"));
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsInitOneObject
  *
  * PARAMETERS:  ObjHandle       - Node
  *              Level           - Current nesting level
  *              Context         - Points to a init info struct
  *              ReturnValue     - Not used
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object
  *              within the  namespace.
  *
  *              Currently, the only objects that require initialization are:
  *              1) Methods
  *              2) Op Regions
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiNsInitOneObject (
     ACPI_HANDLE             ObjHandle,
     UINT32                  Level,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_OBJECT_TYPE        Type;
     ACPI_STATUS             Status = AE_OK;
     ACPI_INIT_WALK_INFO     *Info = (ACPI_INIT_WALK_INFO *) Context;
     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
     ACPI_OPERAND_OBJECT     *ObjDesc;
 
 
     ACPI_FUNCTION_NAME (NsInitOneObject);
 
 
     Info->ObjectCount++;
 
     /* And even then, we are only interested in a few object types */
 
     Type = AcpiNsGetType (ObjHandle);
     ObjDesc = AcpiNsGetAttachedObject (Node);
     if (!ObjDesc)
     {
         return (AE_OK);
     }
 
     /* Increment counters for object types we are looking for */
 
     switch (Type)
     {
     case ACPI_TYPE_REGION:
         Info->OpRegionCount++;
         break;
 
     case ACPI_TYPE_BUFFER_FIELD:
         Info->FieldCount++;
         break;
 
     case ACPI_TYPE_LOCAL_BANK_FIELD:
         Info->FieldCount++;
         break;
 
     case ACPI_TYPE_BUFFER:
         Info->BufferCount++;
         break;
 
     case ACPI_TYPE_PACKAGE:
         Info->PackageCount++;
         break;
 
     default:
 
         /* No init required, just exit now */
         return (AE_OK);
     }
 
     /* If the object is already initialized, nothing else to do */
 
     if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
     {
         return (AE_OK);
     }
 
     /* Must lock the interpreter before executing AML code */
 
     AcpiExEnterInterpreter ();
 
     /*
      * Each of these types can contain executable AML code within the
      * declaration.
      */
     switch (Type)
     {
     case ACPI_TYPE_REGION:
 
         Info->OpRegionInit++;
         Status = AcpiDsGetRegionArguments (ObjDesc);
         break;
 
     case ACPI_TYPE_BUFFER_FIELD:
 
         Info->FieldInit++;
         Status = AcpiDsGetBufferFieldArguments (ObjDesc);
         break;
 
     case ACPI_TYPE_LOCAL_BANK_FIELD:
 
         Info->FieldInit++;
         Status = AcpiDsGetBankFieldArguments (ObjDesc);
         break;
 
     case ACPI_TYPE_BUFFER:
 
         Info->BufferInit++;
         Status = AcpiDsGetBufferArguments (ObjDesc);
         break;
 
     case ACPI_TYPE_PACKAGE:
 
         Info->PackageInit++;
         Status = AcpiDsGetPackageArguments (ObjDesc);
         break;
 
     default:
         /* No other types can get here */
         break;
     }
 
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status,
             "Could not execute arguments for [%4.4s] (%s)",
             AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type)));
     }
 
     /*
      * We ignore errors from above, and always return OK, since we don't want
      * to abort the walk on any single error.
      */
     AcpiExExitInterpreter ();
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsFindIniMethods
  *
  * PARAMETERS:  ACPI_WALK_CALLBACK
  *
  * RETURN:      ACPI_STATUS
  *
  * DESCRIPTION: Called during namespace walk. Finds objects named _INI under
  *              device/processor/thermal objects, and marks the entire subtree
  *              with a SUBTREE_HAS_INI flag. This flag is used during the
  *              subsequent device initialization walk to avoid entire subtrees
  *              that do not contain an _INI.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiNsFindIniMethods (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_DEVICE_WALK_INFO   *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_NAMESPACE_NODE     *ParentNode;
 
 
     /* Keep count of device/processor/thermal objects */
 
     Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
     if ((Node->Type == ACPI_TYPE_DEVICE)    ||
         (Node->Type == ACPI_TYPE_PROCESSOR) ||
         (Node->Type == ACPI_TYPE_THERMAL))
     {
         Info->DeviceCount++;
         return (AE_OK);
     }
 
     /* We are only looking for methods named _INI */
 
     if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI))
     {
         return (AE_OK);
     }
 
     /*
      * The only _INI methods that we care about are those that are
      * present under Device, Processor, and Thermal objects.
      */
     ParentNode = Node->Parent;
     switch (ParentNode->Type)
     {
     case ACPI_TYPE_DEVICE:
     case ACPI_TYPE_PROCESSOR:
     case ACPI_TYPE_THERMAL:
 
         /* Mark parent and bubble up the INI present flag to the root */
 
         while (ParentNode)
         {
             ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI;
             ParentNode = ParentNode->Parent;
         }
         break;
 
     default:
         break;
     }
 
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsInitOneDevice
  *
  * PARAMETERS:  ACPI_WALK_CALLBACK
  *
  * RETURN:      ACPI_STATUS
  *
  * DESCRIPTION: This is called once per device soon after ACPI is enabled
  *              to initialize each device. It determines if the device is
  *              present, and if so, calls _INI.
  *
  ******************************************************************************/
 
 static ACPI_STATUS
 AcpiNsInitOneDevice (
     ACPI_HANDLE             ObjHandle,
     UINT32                  NestingLevel,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_DEVICE_WALK_INFO   *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context);
     ACPI_EVALUATE_INFO      *Info = WalkInfo->EvaluateInfo;
     UINT32                  Flags;
     ACPI_STATUS             Status;
     ACPI_NAMESPACE_NODE     *DeviceNode;
 
 
     ACPI_FUNCTION_TRACE (NsInitOneDevice);
 
 
     /* We are interested in Devices, Processors and ThermalZones only */
 
     DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
     if ((DeviceNode->Type != ACPI_TYPE_DEVICE)    &&
         (DeviceNode->Type != ACPI_TYPE_PROCESSOR) &&
         (DeviceNode->Type != ACPI_TYPE_THERMAL))
     {
         return_ACPI_STATUS (AE_OK);
     }
 
     /*
      * Because of an earlier namespace analysis, all subtrees that contain an
      * _INI method are tagged.
      *
      * If this device subtree does not contain any _INI methods, we
      * can exit now and stop traversing this entire subtree.
      */
     if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI))
     {
         return_ACPI_STATUS (AE_CTRL_DEPTH);
     }
 
     /*
      * Run _STA to determine if this device is present and functioning. We
      * must know this information for two important reasons (from ACPI spec):
      *
      * 1) We can only run _INI if the device is present.
      * 2) We must abort the device tree walk on this subtree if the device is
      *    not present and is not functional (we will not examine the children)
      *
      * The _STA method is not required to be present under the device, we
      * assume the device is present if _STA does not exist.
      */
     ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
         ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA));
 
     Status = AcpiUtExecute_STA (DeviceNode, &Flags);
     if (ACPI_FAILURE (Status))
     {
         /* Ignore error and move on to next device */
 
         return_ACPI_STATUS (AE_OK);
     }
 
     /*
      * Flags == -1 means that _STA was not found. In this case, we assume that
      * the device is both present and functional.
      *
      * From the ACPI spec, description of _STA:
      *
      * "If a device object (including the processor object) does not have an
      * _STA object, then OSPM assumes that all of the above bits are set (in
      * other words, the device is present, ..., and functioning)"
      */
     if (Flags != ACPI_UINT32_MAX)
     {
         WalkInfo->Num_STA++;
     }
 
     /*
      * Examine the PRESENT and FUNCTIONING status bits
      *
      * Note: ACPI spec does not seem to specify behavior for the present but
      * not functioning case, so we assume functioning if present.
      */
     if (!(Flags & ACPI_STA_DEVICE_PRESENT))
     {
         /* Device is not present, we must examine the Functioning bit */
 
         if (Flags & ACPI_STA_DEVICE_FUNCTIONING)
         {
             /*
              * Device is not present but is "functioning". In this case,
              * we will not run _INI, but we continue to examine the children
              * of this device.
              *
              * From the ACPI spec, description of _STA: (Note - no mention
              * of whether to run _INI or not on the device in question)
              *
              * "_STA may return bit 0 clear (not present) with bit 3 set
              * (device is functional). This case is used to indicate a valid
              * device for which no device driver should be loaded (for example,
              * a bridge device.) Children of this device may be present and
              * valid. OSPM should continue enumeration below a device whose
              * _STA returns this bit combination"
              */
             return_ACPI_STATUS (AE_OK);
         }
         else
         {
             /*
              * Device is not present and is not functioning. We must abort the
              * walk of this subtree immediately -- don't look at the children
              * of such a device.
              *
              * From the ACPI spec, description of _INI:
              *
              * "If the _STA method indicates that the device is not present,
              * OSPM will not run the _INI and will not examine the children
              * of the device for _INI methods"
              */
             return_ACPI_STATUS (AE_CTRL_DEPTH);
         }
     }
 
     /*
      * The device is present or is assumed present if no _STA exists.
      * Run the _INI if it exists (not required to exist)
      *
      * Note: We know there is an _INI within this subtree, but it may not be
      * under this particular device, it may be lower in the branch.
      */
     ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (
         ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI));
 
     Info->PrefixNode = DeviceNode;
-    Info->Pathname = METHOD_NAME__INI;
+    Info->RelativePathname = METHOD_NAME__INI;
     Info->Parameters = NULL;
     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
 
     Status = AcpiNsEvaluate (Info);
     if (ACPI_SUCCESS (Status))
     {
         WalkInfo->Num_INI++;
     }
 
 #ifdef ACPI_DEBUG_OUTPUT
     else if (Status != AE_NOT_FOUND)
     {
         /* Ignore error and move on to next device */
 
-        char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode);
+        char *ScopeName = AcpiNsGetExternalPathname (Info->Node);
 
         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);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nspredef.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nspredef.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nspredef.c	(revision 249699)
@@ -1,531 +1,407 @@
 /******************************************************************************
  *
  * Module Name: nspredef - Validation of ACPI predefined methods and objects
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define ACPI_CREATE_PREDEFINED_TABLE
 
 #include 
 #include 
 #include 
 #include 
 
 
 #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.
+ *     ASL is validated against the ACPI specification.
  *  2) The type of the return object (if any) is validated against the ACPI
- *      specification.
+ *     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.
+ *     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
 AcpiNsCheckReference (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     ACPI_OPERAND_OBJECT         *ReturnObject);
 
 static UINT32
 AcpiNsGetBitmappedType (
     ACPI_OPERAND_OBJECT         *ReturnObject);
 
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiNsCheckPredefinedNames
+ * FUNCTION:    AcpiNsCheckReturnValue
  *
  * PARAMETERS:  Node            - Namespace node for the method/object
+ *              Info            - Method execution information block
  *              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.
+ * DESCRIPTION: Check the value returned from a predefined name.
  *
  ******************************************************************************/
 
 ACPI_STATUS
-AcpiNsCheckPredefinedNames (
+AcpiNsCheckReturnValue (
     ACPI_NAMESPACE_NODE         *Node,
+    ACPI_EVALUATE_INFO          *Info,
     UINT32                      UserParamCount,
     ACPI_STATUS                 ReturnStatus,
     ACPI_OPERAND_OBJECT         **ReturnObjectPtr)
 {
-    ACPI_STATUS                 Status = AE_OK;
+    ACPI_STATUS                 Status;
     const ACPI_PREDEFINED_INFO  *Predefined;
-    char                        *Pathname;
-    ACPI_PREDEFINED_DATA        *Data;
 
 
-    /* Match the name for this method/object against the predefined list */
-
-    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
-
-    /* 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 */
 
+    Predefined = Info->Predefined;
     if (!Predefined)
     {
-        goto Cleanup;
+        return (AE_OK);
     }
 
     /*
      * 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))
+    if ((ReturnStatus != AE_OK) &&
+        (ReturnStatus != AE_CTRL_RETURN_VALUE))
     {
-        goto Cleanup;
+        return (AE_OK);
     }
 
     /*
      * Return value validation and possible repair.
      *
      * 1) Don't perform return value validation/repair if this feature
      * has been disabled via a global option.
      *
      * 2) We have a return value, but if one wasn't expected, just exit,
      * this is not a problem. For example, if the "Implicit Return"
      * feature is enabled, methods will always return a value.
      *
      * 3) If the return value can be of any type, then we cannot perform
      * any validation, just exit.
      */
     if (AcpiGbl_DisableAutoRepair ||
         (!Predefined->Info.ExpectedBtypes) ||
         (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL))
     {
-        goto Cleanup;
+        return (AE_OK);
     }
 
-    /* Create the parameter data block for object validation */
-
-    Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA));
-    if (!Data)
-    {
-        goto Cleanup;
-    }
-    Data->Predefined = Predefined;
-    Data->Node = Node;
-    Data->NodeFlags = Node->Flags;
-    Data->Pathname = Pathname;
-
     /*
      * Check that the type of the main return object is what is expected
      * for this predefined name
      */
-    Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr,
-                Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
+    Status = AcpiNsCheckObjectType (Info, ReturnObjectPtr,
+        Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
     if (ACPI_FAILURE (Status))
     {
         goto Exit;
     }
 
     /*
      * For returned Package objects, check the type of all sub-objects.
      * Note: Package may have been newly created by call above.
      */
     if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE)
     {
-        Data->ParentPackage = *ReturnObjectPtr;
-        Status = AcpiNsCheckPackage (Data, ReturnObjectPtr);
+        Info->ParentPackage = *ReturnObjectPtr;
+        Status = AcpiNsCheckPackage (Info, 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);
+    Status = AcpiNsComplexRepairs (Info, 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))
+    if (ACPI_FAILURE (Status) ||
+       (Info->ReturnFlags & 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.ArgumentList & METHOD_ARG_MASK;
-    RequiredParamsOld = Predefined->Info.ArgumentList >> METHOD_ARG_BIT_WIDTH;
-
-    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:    AcpiNsCheckObjectType
  *
- * PARAMETERS:  Data            - Pointer to validation data structure
+ * PARAMETERS:  Info            - Method execution information block
  *              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.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiNsCheckObjectType (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     ACPI_OPERAND_OBJECT         **ReturnObjectPtr,
     UINT32                      ExpectedBtypes,
     UINT32                      PackageIndex)
 {
     ACPI_OPERAND_OBJECT         *ReturnObject = *ReturnObjectPtr;
     ACPI_STATUS                 Status = AE_OK;
     char                        TypeBuffer[48]; /* Room for 5 types */
 
 
     /* A Namespace node should not get here, but make sure */
 
     if (ReturnObject &&
         ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED)
     {
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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)
      */
-    Data->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject);
-    if (Data->ReturnBtype == ACPI_RTYPE_ANY)
+    Info->ReturnBtype = AcpiNsGetBitmappedType (ReturnObject);
+    if (Info->ReturnBtype == ACPI_RTYPE_ANY)
     {
         /* Not one of the supported objects, must be incorrect */
         goto TypeErrorExit;
     }
 
     /* For reference objects, check that the reference type is correct */
 
-    if ((Data->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE)
+    if ((Info->ReturnBtype & ExpectedBtypes) == ACPI_RTYPE_REFERENCE)
     {
-        Status = AcpiNsCheckReference (Data, ReturnObject);
+        Status = AcpiNsCheckReference (Info, ReturnObject);
         return (Status);
     }
 
     /* Attempt simple repair of the returned object if necessary */
 
-    Status = AcpiNsSimpleRepair (Data, ExpectedBtypes,
-                PackageIndex, ReturnObjectPtr);
-    return (Status);
+    Status = AcpiNsSimpleRepair (Info, ExpectedBtypes,
+        PackageIndex, ReturnObjectPtr);
+    if (ACPI_SUCCESS (Status))
+    {
+        return (AE_OK); /* Successful repair */
+    }
 
 
 TypeErrorExit:
 
     /* Create a string with all expected types for this predefined object */
 
     AcpiUtGetExpectedReturnTypes (TypeBuffer, ExpectedBtypes);
 
     if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
     {
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
             "Return type mismatch - found %s, expected %s",
             AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer));
     }
     else
     {
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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
+ * PARAMETERS:  Info            - Method execution information block
  *              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_EVALUATE_INFO          *Info,
     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,
+    ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
         "Return type mismatch - unexpected reference object type [%s] %2.2X",
         AcpiUtGetReferenceName (ReturnObject),
         ReturnObject->Reference.Class));
 
     return (AE_AML_OPERAND_TYPE);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsGetBitmappedType
  *
  * PARAMETERS:  ReturnObject    - Object returned from method/obj evaluation
  *
  * RETURN:      Object return type. ACPI_RTYPE_ANY indicates that the object
  *              type is not supported. ACPI_RTYPE_NONE indicates that no
  *              object was returned (ReturnObject is NULL).
  *
  * DESCRIPTION: Convert object type into a bitmapped object return type.
  *
  ******************************************************************************/
 
 static UINT32
 AcpiNsGetBitmappedType (
     ACPI_OPERAND_OBJECT         *ReturnObject)
 {
     UINT32                      ReturnBtype;
 
 
     if (!ReturnObject)
     {
         return (ACPI_RTYPE_NONE);
     }
 
     /* Map ACPI_OBJECT_TYPE to internal bitmapped type */
 
     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 */
 
         ReturnBtype = ACPI_RTYPE_ANY;
         break;
     }
 
     return (ReturnBtype);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsprepkg.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsprepkg.c	(revision 249699)
@@ -1,646 +1,647 @@
 /******************************************************************************
  *
  * Module Name: nsprepkg - Validation of package objects for predefined names
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #include 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_NAMESPACE
         ACPI_MODULE_NAME    ("nsprepkg")
 
 
 /* Local prototypes */
 
 static ACPI_STATUS
 AcpiNsCheckPackageList (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     const ACPI_PREDEFINED_INFO  *Package,
     ACPI_OPERAND_OBJECT         **Elements,
     UINT32                      Count);
 
 static ACPI_STATUS
 AcpiNsCheckPackageElements (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     ACPI_OPERAND_OBJECT         **Elements,
     UINT8                       Type1,
     UINT32                      Count1,
     UINT8                       Type2,
     UINT32                      Count2,
     UINT32                      StartIndex);
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsCheckPackage
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiNsCheckPackage (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     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;
+    Package = Info->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));
+        Info->FullPathname, 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);
+    AcpiNsRemoveNullElements (Info, Package->RetInfo.Type, ReturnObject);
 
     /* Extract package count and elements array */
 
     Elements = ReturnObject->Package.Elements;
     Count = ReturnObject->Package.Count;
 
     /*
      * Most packages must have at least one element. The only exception
      * is the variable-length package (ACPI_PTYPE1_VAR).
      */
     if (!Count)
     {
         if (Package->RetInfo.Type == ACPI_PTYPE1_VAR)
         {
             return (AE_OK);
         }
 
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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));
+                Info->FullPathname, Count, ExpectedCount));
         }
 
         /* Validate all elements of the returned package */
 
-        Status = AcpiNsCheckPackageElements (Data, Elements,
+        Status = AcpiNsCheckPackageElements (Info, 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,
+            Status = AcpiNsCheckObjectType (Info, 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,
+                Status = AcpiNsCheckObjectType (Info, Elements,
                             Package->RetInfo3.ObjectType[i], i);
                 if (ACPI_FAILURE (Status))
                 {
                     return (Status);
                 }
             }
             else
             {
                 /* These are the optional package elements */
 
-                Status = AcpiNsCheckObjectType (Data, Elements,
+                Status = AcpiNsCheckObjectType (Info, 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,
+        Status = AcpiNsCheckObjectType (Info, Elements,
                     ACPI_RTYPE_INTEGER, 0);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
         Elements++;
         Count--;
 
         /* Examine the sub-packages */
 
-        Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+        Status = AcpiNsCheckPackageList (Info, Package, Elements, Count);
         break;
 
 
     case ACPI_PTYPE2_PKG_COUNT:
 
         /* First element is the (Integer) count of sub-packages to follow */
 
-        Status = AcpiNsCheckObjectType (Data, Elements,
+        Status = AcpiNsCheckObjectType (Info, 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);
+        Status = AcpiNsCheckPackageList (Info, Package, Elements, Count);
         break;
 
 
     case ACPI_PTYPE2:
     case ACPI_PTYPE2_FIXED:
     case ACPI_PTYPE2_MIN:
     case ACPI_PTYPE2_COUNT:
     case ACPI_PTYPE2_FIX_VAR:
 
         /*
          * These types all return a single Package that consists of a
          * variable number of sub-Packages.
          *
          * First, ensure that the first element is a sub-Package. If not,
          * the BIOS may have incorrectly returned the object as a single
          * package instead of a Package of Packages (a common error if
          * there is only one entry). We may be able to repair this by
          * wrapping the returned Package with a new outer Package.
          */
         if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE))
         {
             /* Create the new outer package and populate it */
 
-            Status = AcpiNsWrapWithPackage (Data, ReturnObject, ReturnObjectPtr);
+            Status = AcpiNsWrapWithPackage (Info, ReturnObject, 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);
+        Status = AcpiNsCheckPackageList (Info, Package, Elements, Count);
         break;
 
 
     default:
 
         /* Should not get here if predefined info table is correct */
 
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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,
+    ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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
+ * PARAMETERS:  Info            - Method execution information block
  *              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,
+    ACPI_EVALUATE_INFO          *Info,
     const ACPI_PREDEFINED_INFO  *Package,
     ACPI_OPERAND_OBJECT         **Elements,
     UINT32                      Count)
 {
     ACPI_OPERAND_OBJECT         *SubPackage;
     ACPI_OPERAND_OBJECT         **SubElements;
     ACPI_STATUS                 Status;
     UINT32                      ExpectedCount;
     UINT32                      i;
     UINT32                      j;
 
 
     /*
      * Validate each sub-Package in the parent Package
      *
      * NOTE: assumes list of sub-packages contains no NULL elements.
      * Any NULL elements should have been removed by earlier call
      * to AcpiNsRemoveNullElements.
      */
     for (i = 0; i < Count; i++)
     {
         SubPackage = *Elements;
         SubElements = SubPackage->Package.Elements;
-        Data->ParentPackage = SubPackage;
+        Info->ParentPackage = SubPackage;
 
         /* Each sub-object must be of type Package */
 
-        Status = AcpiNsCheckObjectType (Data, &SubPackage,
+        Status = AcpiNsCheckObjectType (Info, &SubPackage,
                     ACPI_RTYPE_PACKAGE, i);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
         /* Examine the different types of expected sub-packages */
 
-        Data->ParentPackage = SubPackage;
+        Info->ParentPackage = SubPackage;
         switch (Package->RetInfo.Type)
         {
         case ACPI_PTYPE2:
         case ACPI_PTYPE2_PKG_COUNT:
         case ACPI_PTYPE2_REV_FIXED:
 
             /* Each subpackage has a fixed number of elements */
 
             ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
             if (SubPackage->Package.Count < ExpectedCount)
             {
                 goto PackageTooSmall;
             }
 
-            Status = AcpiNsCheckPackageElements (Data, SubElements,
+            Status = AcpiNsCheckPackageElements (Info, SubElements,
                         Package->RetInfo.ObjectType1,
                         Package->RetInfo.Count1,
                         Package->RetInfo.ObjectType2,
                         Package->RetInfo.Count2, 0);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
             break;
 
 
         case ACPI_PTYPE2_FIX_VAR:
             /*
              * Each subpackage has a fixed number of elements and an
              * optional element
              */
             ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
             if (SubPackage->Package.Count < ExpectedCount)
             {
                 goto PackageTooSmall;
             }
 
-            Status = AcpiNsCheckPackageElements (Data, SubElements,
+            Status = AcpiNsCheckPackageElements (Info, SubElements,
                         Package->RetInfo.ObjectType1,
                         Package->RetInfo.Count1,
                         Package->RetInfo.ObjectType2,
                         SubPackage->Package.Count - Package->RetInfo.Count1, 0);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
             break;
 
 
         case ACPI_PTYPE2_FIXED:
 
             /* Each sub-package has a fixed length */
 
             ExpectedCount = Package->RetInfo2.Count;
             if (SubPackage->Package.Count < ExpectedCount)
             {
                 goto PackageTooSmall;
             }
 
             /* Check the type of each sub-package element */
 
             for (j = 0; j < ExpectedCount; j++)
             {
-                Status = AcpiNsCheckObjectType (Data, &SubElements[j],
+                Status = AcpiNsCheckObjectType (Info, &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,
+            Status = AcpiNsCheckPackageElements (Info, SubElements,
                         Package->RetInfo.ObjectType1,
                         SubPackage->Package.Count, 0, 0, 0);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
             break;
 
 
         case ACPI_PTYPE2_COUNT:
 
             /*
              * First element is the (Integer) count of elements, including
              * the count field (the ACPI name is NumElements)
              */
-            Status = AcpiNsCheckObjectType (Data, SubElements,
+            Status = AcpiNsCheckObjectType (Info, SubElements,
                         ACPI_RTYPE_INTEGER, 0);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
             }
 
             /*
              * Make sure package is large enough for the Count and is
              * is as large as the minimum size
              */
             ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
             if (SubPackage->Package.Count < ExpectedCount)
             {
                 goto PackageTooSmall;
             }
             if (SubPackage->Package.Count < Package->RetInfo.Count1)
             {
                 ExpectedCount = Package->RetInfo.Count1;
                 goto PackageTooSmall;
             }
             if (ExpectedCount == 0)
             {
                 /*
                  * Either the NumEntries element was originally zero or it was
                  * a NULL element and repaired to an Integer of value zero.
                  * In either case, repair it by setting NumEntries to be the
                  * actual size of the subpackage.
                  */
                 ExpectedCount = SubPackage->Package.Count;
                 (*SubElements)->Integer.Value = ExpectedCount;
             }
 
             /* Check the type of each sub-package element */
 
-            Status = AcpiNsCheckPackageElements (Data, (SubElements + 1),
+            Status = AcpiNsCheckPackageElements (Info, (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,
+    ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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
+ * PARAMETERS:  Info            - Method execution information block
  *              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_EVALUATE_INFO          *Info,
     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,
+        Status = AcpiNsCheckObjectType (Info, ThisElement,
                     Type1, i + StartIndex);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
         ThisElement++;
     }
 
     for (i = 0; i < Count2; i++)
     {
-        Status = AcpiNsCheckObjectType (Data, ThisElement,
+        Status = AcpiNsCheckObjectType (Info, ThisElement,
                     Type2, (i + Count1 + StartIndex));
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
         ThisElement++;
     }
 
     return (AE_OK);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair.c	(revision 249699)
@@ -1,616 +1,616 @@
 /******************************************************************************
  *
  * Module Name: nsrepair - Repair for objects returned by predefined methods
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __NSREPAIR_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #define _COMPONENT          ACPI_NAMESPACE
         ACPI_MODULE_NAME    ("nsrepair")
 
 
 /*******************************************************************************
  *
  * This module attempts to repair or convert objects returned by the
  * predefined methods to an object type that is expected, as per the ACPI
  * specification. The need for this code is dictated by the many machines that
  * return incorrect types for the standard predefined methods. Performing these
  * conversions here, in one place, eliminates the need for individual ACPI
  * device drivers to do the same. Note: Most of these conversions are different
  * than the internal object conversion routines used for implicit object
  * conversion.
  *
  * The following conversions can be performed as necessary:
  *
  * Integer -> String
  * Integer -> Buffer
  * String  -> Integer
  * String  -> Buffer
  * Buffer  -> Integer
  * Buffer  -> String
  * Buffer  -> Package of Integers
  * Package -> Package of one Package
  *
  * Additional conversions that are available:
  *  Convert a null return or zero return value to an EndTag descriptor
  *  Convert an ASCII string to a Unicode buffer
  *
  * An incorrect standalone object is wrapped with required outer package
  *
  * Additional possible repairs:
  * Required package elements that are NULL replaced by Integer/String/Buffer
  *
  ******************************************************************************/
 
 
 /* Local prototypes */
 
 static const ACPI_SIMPLE_REPAIR_INFO *
 AcpiNsMatchSimpleRepair (
     ACPI_NAMESPACE_NODE     *Node,
     UINT32                  ReturnBtype,
     UINT32                  PackageIndex);
 
 
 /*
  * Special but simple repairs for some names.
  *
  * 2nd argument: Unexpected types that can be repaired
  */
 static const ACPI_SIMPLE_REPAIR_INFO    AcpiObjectRepairInfo[] =
 {
     /* Resource descriptor conversions */
 
     { "_CRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
                 ACPI_NOT_PACKAGE_ELEMENT,
                 AcpiNsConvertToResource },
     { "_DMA", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
                 ACPI_NOT_PACKAGE_ELEMENT,
                 AcpiNsConvertToResource },
     { "_PRS", ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | ACPI_RTYPE_NONE,
                 ACPI_NOT_PACKAGE_ELEMENT,
                 AcpiNsConvertToResource },
 
     /* Unicode conversions */
 
     { "_MLS", ACPI_RTYPE_STRING, 1,
                 AcpiNsConvertToUnicode },
     { "_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER,
                 ACPI_NOT_PACKAGE_ELEMENT,
                 AcpiNsConvertToUnicode },
     { {0,0,0,0}, 0, 0, NULL } /* Table terminator */
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsSimpleRepair
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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
 AcpiNsSimpleRepair (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT32                  ExpectedBtypes,
     UINT32                  PackageIndex,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_OPERAND_OBJECT     *NewObject = NULL;
     ACPI_STATUS             Status;
     const ACPI_SIMPLE_REPAIR_INFO   *Predefined;
 
 
     ACPI_FUNCTION_NAME (NsSimpleRepair);
 
 
     /*
      * Special repairs for certain names that are in the repair table.
      * Check if this name is in the list of repairable names.
      */
-    Predefined = AcpiNsMatchSimpleRepair (Data->Node,
-        Data->ReturnBtype, PackageIndex);
+    Predefined = AcpiNsMatchSimpleRepair (Info->Node,
+        Info->ReturnBtype, PackageIndex);
     if (Predefined)
     {
         if (!ReturnObject)
         {
-            ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname,
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname,
                 ACPI_WARN_ALWAYS, "Missing expected return value"));
         }
 
         Status = Predefined->ObjectConverter (ReturnObject, &NewObject);
         if (ACPI_FAILURE (Status))
         {
             /* A fatal error occurred during a conversion */
 
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "During return object analysis"));
             return (Status);
         }
         if (NewObject)
         {
             goto ObjectRepaired;
         }
     }
 
     /*
      * Do not perform simple object repair unless the return type is not
      * expected.
      */
-    if (Data->ReturnBtype & ExpectedBtypes)
+    if (Info->ReturnBtype & ExpectedBtypes)
     {
         return (AE_OK);
     }
 
     /*
      * 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 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 (ExpectedBtypes && (!(ExpectedBtypes & ACPI_RTYPE_NONE)))
         {
-            ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname,
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname,
                 ACPI_WARN_ALWAYS, "Missing expected return value"));
 
             return (AE_AML_NO_RETURN_VALUE);
         }
     }
 
     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)
     {
         /*
          * A package is expected. We will wrap the existing object with a
          * new package object. It is often the case that if a variable-length
          * package is required, but there is only a single object needed, the
          * BIOS will return that object instead of wrapping it with a Package
          * object. Note: after the wrapping, the package will be validated
          * for correct contents (expected object type or types).
          */
-        Status = AcpiNsWrapWithPackage (Data, ReturnObject, &NewObject);
+        Status = AcpiNsWrapWithPackage (Info, ReturnObject, &NewObject);
         if (ACPI_SUCCESS (Status))
         {
             /*
              * The original object just had its reference count
              * incremented for being inserted into the new package.
              */
             *ReturnObjectPtr = NewObject;       /* New Package object */
-            Data->Flags |= ACPI_OBJECT_REPAIRED;
+            Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
             return (AE_OK);
         }
     }
 
     /* We cannot repair this object */
 
     return (AE_AML_OPERAND_TYPE);
 
 
 ObjectRepaired:
 
     /* Object was successfully repaired */
 
     if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
     {
         /*
          * The original object is a package element. We need to
          * decrement the reference count of the original object,
          * for removing it from the package.
          *
          * However, if the original object was just wrapped with a
          * package object as part of the repair, we don't need to
          * change the reference count.
          */
-        if (!(Data->Flags & ACPI_OBJECT_WRAPPED))
+        if (!(Info->ReturnFlags & ACPI_OBJECT_WRAPPED))
         {
             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 Package index %u\n",
-            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
+            Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject),
             AcpiUtGetObjectTypeName (NewObject), PackageIndex));
     }
     else
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
             "%s: Converted %s to expected %s\n",
-            Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
+            Info->FullPathname, AcpiUtGetObjectTypeName (ReturnObject),
             AcpiUtGetObjectTypeName (NewObject)));
     }
 
     /* Delete old object, install the new return object */
 
     AcpiUtRemoveReference (ReturnObject);
     *ReturnObjectPtr = NewObject;
-    Data->Flags |= ACPI_OBJECT_REPAIRED;
+    Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsMatchSimpleRepair
  *
  * PARAMETERS:  Node                - Namespace node for the method/object
  *              ReturnBtype         - Object type that was returned
  *              PackageIndex        - Index of object within parent package (if
  *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
  *                                    otherwise)
  *
  * RETURN:      Pointer to entry in repair table. NULL indicates not found.
  *
  * DESCRIPTION: Check an object name against the repairable object list.
  *
  *****************************************************************************/
 
 static const ACPI_SIMPLE_REPAIR_INFO *
 AcpiNsMatchSimpleRepair (
     ACPI_NAMESPACE_NODE     *Node,
     UINT32                  ReturnBtype,
     UINT32                  PackageIndex)
 {
     const ACPI_SIMPLE_REPAIR_INFO   *ThisName;
 
 
     /* Search info table for a repairable predefined method/object name */
 
     ThisName = AcpiObjectRepairInfo;
     while (ThisName->ObjectConverter)
     {
         if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Name))
         {
             /* Check if we can actually repair this name/type combination */
 
             if ((ReturnBtype & ThisName->UnexpectedBtypes) &&
                 (PackageIndex == ThisName->PackageIndex))
             {
                 return (ThisName);
             }
 
             return (NULL);
         }
         ThisName++;
     }
 
     return (NULL); /* Name was not found in the repair table */
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsRepairNullElement
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              ExpectedBtypes      - Object types expected
  *              PackageIndex        - Index of object within parent package (if
  *                                    applicable - ACPI_NOT_PACKAGE_ELEMENT
  *                                    otherwise)
  *              ReturnObjectPtr     - Pointer to the object returned from the
  *                                    evaluation of a method or object
  *
  * RETURN:      Status. AE_OK if repair was successful.
  *
  * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiNsRepairNullElement (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT32                  ExpectedBtypes,
     UINT32                  PackageIndex,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_OPERAND_OBJECT     *NewObject;
 
 
     ACPI_FUNCTION_NAME (NsRepairNullElement);
 
 
     /* No repair needed if return object is non-NULL */
 
     if (ReturnObject)
     {
         return (AE_OK);
     }
 
     /*
      * Attempt to repair a NULL element of a Package object. This applies to
      * predefined names that return a fixed-length package and each element
      * is required. It does not apply to variable-length packages where NULL
      * elements are allowed, especially at the end of the package.
      */
     if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
     {
         /* Need an Integer - create a zero-value integer */
 
         NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
     }
     else if (ExpectedBtypes & ACPI_RTYPE_STRING)
     {
         /* Need a String - create a NULL string */
 
         NewObject = AcpiUtCreateStringObject (0);
     }
     else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
     {
         /* Need a Buffer - create a zero-length buffer */
 
         NewObject = AcpiUtCreateBufferObject (0);
     }
     else
     {
         /* Error for all other expected types */
 
         return (AE_AML_OPERAND_TYPE);
     }
 
     if (!NewObject)
     {
         return (AE_NO_MEMORY);
     }
 
     /* Set the reference count according to the parent Package object */
 
-    NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
+    NewObject->Common.ReferenceCount = Info->ParentPackage->Common.ReferenceCount;
 
     ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
         "%s: Converted NULL package element to expected %s at index %u\n",
-         Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
+         Info->FullPathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
 
     *ReturnObjectPtr = NewObject;
-    Data->Flags |= ACPI_OBJECT_REPAIRED;
+    Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRemoveNullElements
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              PackageType         - An AcpiReturnPackageTypes value
  *              ObjDesc             - A Package object
  *
  * RETURN:      None.
  *
  * DESCRIPTION: Remove all NULL package elements from packages that contain
  *              a variable number of sub-packages. For these types of
  *              packages, NULL elements can be safely removed.
  *
  *****************************************************************************/
 
 void
 AcpiNsRemoveNullElements (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT8                   PackageType,
     ACPI_OPERAND_OBJECT     *ObjDesc)
 {
     ACPI_OPERAND_OBJECT     **Source;
     ACPI_OPERAND_OBJECT     **Dest;
     UINT32                  Count;
     UINT32                  NewCount;
     UINT32                  i;
 
 
     ACPI_FUNCTION_NAME (NsRemoveNullElements);
 
 
     /*
      * We can safely remove all NULL elements from these package types:
      * PTYPE1_VAR packages contain a variable number of simple data types.
      * PTYPE2 packages contain a variable number of sub-packages.
      */
     switch (PackageType)
     {
     case ACPI_PTYPE1_VAR:
     case ACPI_PTYPE2:
     case ACPI_PTYPE2_COUNT:
     case ACPI_PTYPE2_PKG_COUNT:
     case ACPI_PTYPE2_FIXED:
     case ACPI_PTYPE2_MIN:
     case ACPI_PTYPE2_REV_FIXED:
     case ACPI_PTYPE2_FIX_VAR:
         break;
 
     default:
     case ACPI_PTYPE1_FIXED:
     case ACPI_PTYPE1_OPTION:
         return;
     }
 
     Count = ObjDesc->Package.Count;
     NewCount = Count;
 
     Source = ObjDesc->Package.Elements;
     Dest = Source;
 
     /* Examine all elements of the package object, remove nulls */
 
     for (i = 0; i < Count; i++)
     {
         if (!*Source)
         {
             NewCount--;
         }
         else
         {
             *Dest = *Source;
             Dest++;
         }
         Source++;
     }
 
     /* Update parent package if any null elements were removed */
 
     if (NewCount < Count)
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
             "%s: Found and removed %u NULL elements\n",
-            Data->Pathname, (Count - NewCount)));
+            Info->FullPathname, (Count - NewCount)));
 
         /* NULL terminate list and update the package count */
 
         *Dest = NULL;
         ObjDesc->Package.Count = NewCount;
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiNsWrapWithPackage
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              OriginalObject      - Pointer to the object to repair.
  *              ObjDescPtr          - The new package object is returned here
  *
  * RETURN:      Status, new object in *ObjDescPtr
  *
  * DESCRIPTION: Repair a common problem with objects that are defined to
  *              return a variable-length Package of sub-objects. If there is
  *              only one sub-object, some BIOS code mistakenly simply declares
  *              the single object instead of a Package with one sub-object.
  *              This function attempts to repair this error by wrapping a
  *              Package object around the original object, creating the
  *              correct and expected Package with one sub-object.
  *
  *              Names that can be repaired in this manner include:
  *              _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
  *              _BCL, _DOD, _FIX, _Sx
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiNsWrapWithPackage (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ObjDescPtr)
 {
     ACPI_OPERAND_OBJECT     *PkgObjDesc;
 
 
     ACPI_FUNCTION_NAME (NsWrapWithPackage);
 
 
     /*
      * Create the new outer package and populate it. The new package will
      * have a single element, the lone sub-object.
      */
     PkgObjDesc = AcpiUtCreatePackageObject (1);
     if (!PkgObjDesc)
     {
         return (AE_NO_MEMORY);
     }
 
     PkgObjDesc->Package.Elements[0] = OriginalObject;
 
     ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
         "%s: Wrapped %s with expected Package object\n",
-        Data->Pathname, AcpiUtGetObjectTypeName (OriginalObject)));
+        Info->FullPathname, AcpiUtGetObjectTypeName (OriginalObject)));
 
     /* Return the new object in the object pointer */
 
     *ObjDescPtr = PkgObjDesc;
-    Data->Flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
+    Info->ReturnFlags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
     return (AE_OK);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair2.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsrepair2.c	(revision 249699)
@@ -1,827 +1,828 @@
 /******************************************************************************
  *
  * Module Name: nsrepair2 - Repair for objects returned by specific
  *                          predefined methods
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __NSREPAIR2_C__
 
 #include 
 #include 
 #include 
 
 #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_EVALUATE_INFO      *Info,
     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 *
 AcpiNsMatchComplexRepair (
     ACPI_NAMESPACE_NODE     *Node);
 
 static ACPI_STATUS
 AcpiNsRepair_ALR (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsRepair_CID (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsRepair_FDE (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsRepair_HID (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsRepair_PSS (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsRepair_TSS (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 static ACPI_STATUS
 AcpiNsCheckSortedList (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     *ReturnObject,
     UINT32                  ExpectedCount,
     UINT32                  SortIndex,
     UINT8                   SortDirection,
     char                    *SortKeyName);
 
 static void
 AcpiNsSortList (
     ACPI_OPERAND_OBJECT     **Elements,
     UINT32                  Count,
     UINT32                  Index,
     UINT8                   SortDirection);
 
 /* Values for SortDirection above */
 
 #define ACPI_SORT_ASCENDING     0
 #define ACPI_SORT_DESCENDING    1
 
 
 /*
  * This table contains the names of the predefined methods for which we can
  * perform more complex repairs.
  *
  * As necessary:
  *
  * _ALR: Sort the list ascending by AmbientIlluminance
  * _CID: Strings: uppercase all, remove any leading asterisk
  * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
  * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
  * _HID: Strings: uppercase all, remove any leading asterisk
  * _PSS: Sort the list descending by Power
  * _TSS: Sort the list descending by Power
  *
  * Names that must be packages, but cannot be sorted:
  *
  * _BCL: Values are tied to the Package index where they appear, and cannot
  * be moved or sorted. These index values are used for _BQC and _BCM.
  * However, we can fix the case where a buffer is returned, by converting
  * it to a Package of integers.
  */
 static const ACPI_REPAIR_INFO       AcpiNsRepairableNames[] =
 {
     {"_ALR", AcpiNsRepair_ALR},
     {"_CID", AcpiNsRepair_CID},
     {"_FDE", AcpiNsRepair_FDE},
     {"_GTM", AcpiNsRepair_FDE},     /* _GTM has same repair as _FDE */
     {"_HID", AcpiNsRepair_HID},
     {"_PSS", AcpiNsRepair_PSS},
     {"_TSS", AcpiNsRepair_TSS},
     {{0,0,0,0}, NULL}               /* Table terminator */
 };
 
 
 #define ACPI_FDE_FIELD_COUNT        5
 #define ACPI_FDE_BYTE_BUFFER_SIZE   5
 #define ACPI_FDE_DWORD_BUFFER_SIZE  (ACPI_FDE_FIELD_COUNT * sizeof (UINT32))
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsComplexRepairs
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     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 = AcpiNsMatchComplexRepair (Node);
     if (!Predefined)
     {
         return (ValidateStatus);
     }
 
-    Status = Predefined->RepairFunction (Data, ReturnObjectPtr);
+    Status = Predefined->RepairFunction (Info, ReturnObjectPtr);
     return (Status);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsMatchComplexRepair
  *
  * 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 *
 AcpiNsMatchComplexRepair (
     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
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_STATUS             Status;
 
 
-    Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1,
+    Status = AcpiNsCheckSortedList (Info, ReturnObject, 2, 1,
                 ACPI_SORT_ASCENDING, "AmbientIlluminance");
 
     return (Status);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRepair_FDE
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     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,
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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));
+            Info->FullPathname));
         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;
+    Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRepair_CID
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              ReturnObjectPtr     - Pointer to the object returned from the
  *                                    evaluation of a method or object
  *
  * RETURN:      Status. AE_OK if object is OK or was repaired successfully
  *
  * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
  *              letters are uppercase and that there is no leading asterisk.
  *              If a Package, ensure same for all string elements.
  *
  *****************************************************************************/
 
 static ACPI_STATUS
 AcpiNsRepair_CID (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_STATUS             Status;
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_OPERAND_OBJECT     **ElementPtr;
     ACPI_OPERAND_OBJECT     *OriginalElement;
     UINT16                  OriginalRefCount;
     UINT32                  i;
 
 
     /* Check for _CID as a simple string */
 
     if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
     {
-        Status = AcpiNsRepair_HID (Data, ReturnObjectPtr);
+        Status = AcpiNsRepair_HID (Info, ReturnObjectPtr);
         return (Status);
     }
 
     /* Exit if not a Package */
 
     if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
     {
         return (AE_OK);
     }
 
     /* Examine each element of the _CID package */
 
     ElementPtr = ReturnObject->Package.Elements;
     for (i = 0; i < ReturnObject->Package.Count; i++)
     {
         OriginalElement = *ElementPtr;
         OriginalRefCount = OriginalElement->Common.ReferenceCount;
 
-        Status = AcpiNsRepair_HID (Data, ElementPtr);
+        Status = AcpiNsRepair_HID (Info, ElementPtr);
         if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
         /* Take care with reference counts */
 
         if (OriginalElement != *ElementPtr)
         {
             /* Element was replaced */
 
             (*ElementPtr)->Common.ReferenceCount =
                 OriginalRefCount;
 
             AcpiUtRemoveReference (OriginalElement);
         }
 
         ElementPtr++;
     }
 
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRepair_HID
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              ReturnObjectPtr     - Pointer to the object returned from the
  *                                    evaluation of a method or object
  *
  * RETURN:      Status. AE_OK if object is OK or was repaired successfully
  *
  * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
  *              letters are uppercase and that there is no leading asterisk.
  *
  *****************************************************************************/
 
 static ACPI_STATUS
 AcpiNsRepair_HID (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_OPERAND_OBJECT     *NewString;
     char                    *Source;
     char                    *Dest;
 
 
     ACPI_FUNCTION_NAME (NsRepair_HID);
 
 
     /* We only care about string _HID objects (not integers) */
 
     if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
     {
         return (AE_OK);
     }
 
     if (ReturnObject->String.Length == 0)
     {
-        ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+        ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
             "Invalid zero-length _HID or _CID string"));
 
         /* Return AE_OK anyway, let driver handle it */
 
-        Data->Flags |= ACPI_OBJECT_REPAIRED;
+        Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
         return (AE_OK);
     }
 
     /* It is simplest to always create a new string object */
 
     NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
     if (!NewString)
     {
         return (AE_NO_MEMORY);
     }
 
     /*
      * Remove a leading asterisk if present. For some unknown reason, there
      * are many machines in the field that contains IDs like this.
      *
      * Examples: "*PNP0C03", "*ACPI0003"
      */
     Source = ReturnObject->String.Pointer;
     if (*Source == '*')
     {
         Source++;
         NewString->String.Length--;
 
         ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
-            "%s: Removed invalid leading asterisk\n", Data->Pathname));
+            "%s: Removed invalid leading asterisk\n", Info->FullPathname));
     }
 
     /*
      * Copy and uppercase the string. From the ACPI 5.0 specification:
      *
      * A valid PNP ID must be of the form "AAA####" where A is an uppercase
      * letter and # is a hex digit. A valid ACPI ID must be of the form
      * "NNNN####" where N is an uppercase letter or decimal digit, and
      * # is a hex digit.
      */
     for (Dest = NewString->String.Pointer; *Source; Dest++, Source++)
     {
         *Dest = (char) ACPI_TOUPPER (*Source);
     }
 
     AcpiUtRemoveReference (ReturnObject);
     *ReturnObjectPtr = NewString;
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRepair_TSS
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr)
 {
     ACPI_OPERAND_OBJECT     *ReturnObject = *ReturnObjectPtr;
     ACPI_STATUS             Status;
     ACPI_NAMESPACE_NODE     *Node;
 
 
     /*
      * We can only sort the _TSS return package if there is no _PSS in the
      * same scope. This is because if _PSS is present, the ACPI specification
      * dictates that the _TSS Power Dissipation field is to be ignored, and
      * therefore some BIOSs leave garbage values in the _TSS Power field(s).
      * In this case, it is best to just return the _TSS package as-is.
      * (May, 2011)
      */
-    Status = AcpiNsGetNode (Data->Node, "^_PSS", ACPI_NS_NO_UPSEARCH, &Node);
+    Status = AcpiNsGetNode (Info->Node, "^_PSS",
+        ACPI_NS_NO_UPSEARCH, &Node);
     if (ACPI_SUCCESS (Status))
     {
         return (AE_OK);
     }
 
-    Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1,
+    Status = AcpiNsCheckSortedList (Info, ReturnObject, 5, 1,
                 ACPI_SORT_DESCENDING, "PowerDissipation");
 
     return (Status);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsRepair_PSS
  *
- * PARAMETERS:  Data                - Pointer to validation data structure
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     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,
+    Status =AcpiNsCheckSortedList (Info, 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,
+            ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->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
+ * PARAMETERS:  Info                - Method execution information block
  *              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_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     *ReturnObject,
     UINT32                  ExpectedCount,
     UINT32                  SortIndex,
     UINT8                   SortDirection,
     char                    *SortKeyName)
 {
     UINT32                  OuterElementCount;
     ACPI_OPERAND_OBJECT     **OuterElements;
     ACPI_OPERAND_OBJECT     **Elements;
     ACPI_OPERAND_OBJECT     *ObjDesc;
     UINT32                  i;
     UINT32                  PreviousValue;
 
 
     ACPI_FUNCTION_NAME (NsCheckSortedList);
 
 
     /* The top-level object must be a package */
 
     if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
     {
         return (AE_AML_OPERAND_TYPE);
     }
 
     /*
      * NOTE: assumes list of sub-packages contains no NULL elements.
      * Any NULL elements should have been removed by earlier call
      * to AcpiNsRemoveNullElements.
      */
     OuterElements = ReturnObject->Package.Elements;
     OuterElementCount = ReturnObject->Package.Count;
     if (!OuterElementCount)
     {
         return (AE_AML_PACKAGE_LIMIT);
     }
 
     PreviousValue = 0;
     if (SortDirection == ACPI_SORT_DESCENDING)
     {
         PreviousValue = ACPI_UINT32_MAX;
     }
 
     /* Examine each subpackage */
 
     for (i = 0; i < OuterElementCount; i++)
     {
         /* Each element of the top-level package must also be a package */
 
         if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE)
         {
             return (AE_AML_OPERAND_TYPE);
         }
 
         /* Each sub-package must have the minimum length */
 
         if ((*OuterElements)->Package.Count < ExpectedCount)
         {
             return (AE_AML_PACKAGE_LIMIT);
         }
 
         Elements = (*OuterElements)->Package.Elements;
         ObjDesc = Elements[SortIndex];
 
         if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
         {
             return (AE_AML_OPERAND_TYPE);
         }
 
         /*
          * The list must be sorted in the specified order. If we detect a
          * discrepancy, sort the entire list.
          */
         if (((SortDirection == ACPI_SORT_ASCENDING) &&
                 (ObjDesc->Integer.Value < PreviousValue)) ||
             ((SortDirection == ACPI_SORT_DESCENDING) &&
                 (ObjDesc->Integer.Value > PreviousValue)))
         {
             AcpiNsSortList (ReturnObject->Package.Elements,
                 OuterElementCount, SortIndex, SortDirection);
 
-            Data->Flags |= ACPI_OBJECT_REPAIRED;
+            Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
 
             ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
                 "%s: Repaired unsorted list - now sorted by %s\n",
-                Data->Pathname, SortKeyName));
+                Info->FullPathname, SortKeyName));
             return (AE_OK);
         }
 
         PreviousValue = (UINT32) ObjDesc->Integer.Value;
         OuterElements++;
     }
 
     return (AE_OK);
 }
 
 
 /******************************************************************************
  *
  * FUNCTION:    AcpiNsSortList
  *
  * PARAMETERS:  Elements            - Package object element list
  *              Count               - Element count for above
  *              Index               - Sort by which package element
  *              SortDirection       - Ascending or Descending sort
  *
  * RETURN:      None
  *
  * DESCRIPTION: Sort the objects that are in a package element list.
  *
  * NOTE: Assumes that all NULL elements have been removed from the package,
  *       and that all elements have been verified to be of type Integer.
  *
  *****************************************************************************/
 
 static void
 AcpiNsSortList (
     ACPI_OPERAND_OBJECT     **Elements,
     UINT32                  Count,
     UINT32                  Index,
     UINT8                   SortDirection)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc1;
     ACPI_OPERAND_OBJECT     *ObjDesc2;
     ACPI_OPERAND_OBJECT     *TempObj;
     UINT32                  i;
     UINT32                  j;
 
 
     /* Simple bubble sort */
 
     for (i = 1; i < Count; i++)
     {
         for (j = (Count - 1); j >= i; j--)
         {
             ObjDesc1 = Elements[j-1]->Package.Elements[Index];
             ObjDesc2 = Elements[j]->Package.Elements[Index];
 
             if (((SortDirection == ACPI_SORT_ASCENDING) &&
                     (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) ||
 
                 ((SortDirection == ACPI_SORT_DESCENDING) &&
                     (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value)))
             {
                 TempObj = Elements[j-1];
                 Elements[j-1] = Elements[j];
                 Elements[j] = TempObj;
             }
         }
     }
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsxfeval.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsxfeval.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace/nsxfeval.c	(revision 249699)
@@ -1,958 +1,1059 @@
 /*******************************************************************************
  *
  * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
  *                         ACPI Object evaluation interfaces
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #define __NSXFEVAL_C__
 
 #include 
 #include 
 #include 
 #include 
 
 
 #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
+     * Get the actual namespace node for the target object.
+     * Handles these cases:
+     *
+     * 1) Null node, valid pathname from root (absolute path)
+     * 2) Node and valid pathname (path relative to Node)
+     * 3) Node, Null pathname
      */
+    if ((Pathname) &&
+        (ACPI_IS_ROOT_PREFIX (Pathname[0])))
+    {
+        /* The path is fully qualified, just evaluate by name */
+
+        Info->PrefixNode = NULL;
+    }
+    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;
+        goto Cleanup;
+    }
+
+    Info->RelativePathname = Pathname;
+
+    /*
+     * Convert all external objects passed as arguments to the
+     * internal version(s).
+     */
     if (ExternalParams && ExternalParams->Count)
     {
+        Info->ParamCount = (UINT16) ExternalParams->Count;
+
+        /* Warn on impossible argument count */
+
+        if (Info->ParamCount > ACPI_METHOD_NUM_ARGS)
+        {
+            ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS,
+                "Excess arguments (%u) - using only %u",
+                Info->ParamCount, ACPI_METHOD_NUM_ARGS));
+
+            Info->ParamCount = ACPI_METHOD_NUM_ARGS;
+        }
+
         /*
          * 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 *));
+            ((ACPI_SIZE) Info->ParamCount + 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++)
+        for (i = 0; i < Info->ParamCount; i++)
         {
             Status = AcpiUtCopyEobjectToIobject (
-                        &ExternalParams->Pointer[i], &Info->Parameters[i]);
+                &ExternalParams->Pointer[i], &Info->Parameters[i]);
             if (ACPI_FAILURE (Status))
             {
                 goto Cleanup;
             }
         }
-        Info->Parameters[ExternalParams->Count] = NULL;
+
+        Info->Parameters[Info->ParamCount] = NULL;
     }
 
+
+#if 0
+
     /*
-     * Three major cases:
-     * 1) Fully qualified pathname
-     * 2) No handle, not fully qualified pathname (error)
-     * 3) Valid handle
+     * Begin incoming argument count analysis. Check for too few args
+     * and too many args.
      */
-    if ((Pathname) &&
-        (ACPI_IS_ROOT_PREFIX (Pathname[0])))
-    {
-        /* The path is fully qualified, just evaluate by name */
 
-        Info->PrefixNode = NULL;
-        Status = AcpiNsEvaluate (Info);
-    }
-    else if (!Handle)
+    switch (AcpiNsGetType (Info->Node))
     {
+    case ACPI_TYPE_METHOD:
+
+        /* Check incoming argument count against the method definition */
+
+        if (Info->ObjDesc->Method.ParamCount > Info->ParamCount)
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Insufficient arguments (%u) - %u are required",
+                Info->ParamCount,
+                Info->ObjDesc->Method.ParamCount));
+
+            Status = AE_MISSING_ARGUMENTS;
+            goto Cleanup;
+        }
+
+        else if (Info->ObjDesc->Method.ParamCount < Info->ParamCount)
+        {
+            ACPI_WARNING ((AE_INFO,
+                "Excess arguments (%u) - only %u are required",
+                Info->ParamCount,
+                Info->ObjDesc->Method.ParamCount));
+
+            /* Just pass the required number of arguments */
+
+            Info->ParamCount = Info->ObjDesc->Method.ParamCount;
+        }
+
         /*
-         * A handle is optional iff a fully qualified pathname is specified.
-         * Since we've already handled fully qualified names above, this is
-         * an error
+         * Any incoming external objects to be passed as arguments to the
+         * method must be converted to internal objects
          */
-        if (!Pathname)
+        if (Info->ParamCount)
         {
-            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                "Both Handle and Pathname are NULL"));
+            /*
+             * 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) Info->ParamCount + 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 < Info->ParamCount; i++)
+            {
+                Status = AcpiUtCopyEobjectToIobject (
+                    &ExternalParams->Pointer[i], &Info->Parameters[i]);
+                if (ACPI_FAILURE (Status))
+                {
+                    goto Cleanup;
+                }
+            }
+
+            Info->Parameters[Info->ParamCount] = NULL;
         }
-        else
+        break;
+
+    default:
+
+        /* Warn if arguments passed to an object that is not a method */
+
+        if (Info->ParamCount)
         {
-            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
-                "Null Handle with relative pathname [%s]", Pathname));
+            ACPI_WARNING ((AE_INFO,
+                "%u arguments were passed to a non-method ACPI object",
+                Info->ParamCount));
         }
-
-        Status = AE_BAD_PARAMETER;
+        break;
     }
-    else
-    {
-        /* We have a namespace a node and a possible relative path */
 
-        Status = AcpiNsEvaluate (Info);
-    }
+#endif
+
+
+    /* Now we can evaluate the object */
+
+    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_ACPI_STATUS (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_PNP_DEVICE_ID      *Hid;
     ACPI_PNP_DEVICE_ID_LIST *Cid;
     UINT32                  i;
     BOOLEAN                 Found;
     int                     NoMatch;
 
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     Node = AcpiNsValidateHandle (ObjHandle);
     Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     if (!Node)
     {
         return (AE_BAD_PARAMETER);
     }
 
     /*
      * First, filter based on the device HID and CID.
      *
      * 01/2010: For this case where a specific HID is requested, we don't
      * want to run _STA until we have an actual HID match. Thus, we will
      * not unnecessarily execute _STA on devices for which the caller
      * doesn't care about. Previously, _STA was executed unconditionally
      * on all devices found here.
      *
      * A side-effect of this change is that now we will continue to search
      * for a matching HID even under device trees where the parent device
      * would have returned a _STA that indicates it is not present or
      * not functioning (thus aborting the search on that branch).
      */
     if (Info->Hid != NULL)
     {
         Status = AcpiUtExecute_HID (Node, &Hid);
         if (Status == AE_NOT_FOUND)
         {
             return (AE_OK);
         }
         else if (ACPI_FAILURE (Status))
         {
             return (AE_CTRL_DEPTH);
         }
 
         NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
         ACPI_FREE (Hid);
 
         if (NoMatch)
         {
             /*
              * HID does not match, attempt match within the
              * list of Compatible IDs (CIDs)
              */
             Status = AcpiUtExecute_CID (Node, &Cid);
             if (Status == AE_NOT_FOUND)
             {
                 return (AE_OK);
             }
             else if (ACPI_FAILURE (Status))
             {
                 return (AE_CTRL_DEPTH);
             }
 
             /* Walk the CID list */
 
             Found = FALSE;
             for (i = 0; i < Cid->Count; i++)
             {
                 if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0)
                 {
                     /* Found a matching CID */
 
                     Found = TRUE;
                     break;
                 }
             }
 
             ACPI_FREE (Cid);
             if (!Found)
             {
                 return (AE_OK);
             }
         }
     }
 
     /* Run _STA to determine if device is present */
 
     Status = AcpiUtExecute_STA (Node, &Flags);
     if (ACPI_FAILURE (Status))
     {
         return (AE_CTRL_DEPTH);
     }
 
     if (!(Flags & ACPI_STA_DEVICE_PRESENT) &&
         !(Flags & ACPI_STA_DEVICE_FUNCTIONING))
     {
         /*
          * Don't examine the children of the device only when the
          * device is neither present nor functional. See ACPI spec,
          * description of _STA for more information.
          */
         return (AE_CTRL_DEPTH);
     }
 
     /* We have a valid device, invoke the user function */
 
     Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context,
                 ReturnValue);
     return (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiGetDevices
  *
  * PARAMETERS:  HID                 - HID to search for. Can be NULL.
  *              UserFunction        - Called when a matching object is found
  *              Context             - Passed to user function
  *              ReturnValue         - Location where return value of
  *                                    UserFunction is put if terminated early
  *
  * RETURNS      Return value from the UserFunction if terminated early.
  *              Otherwise, returns NULL.
  *
  * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
  *              starting (and ending) at the object specified by StartHandle.
  *              The UserFunction is called whenever an object of type
  *              Device is found. If the user function returns
  *              a non-zero value, the search is terminated immediately and this
  *              value is returned to the caller.
  *
  *              This is a wrapper for WalkNamespace, but the callback performs
  *              additional filtering. Please see AcpiNsGetDeviceCallback.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiGetDevices (
     char                    *HID,
     ACPI_WALK_CALLBACK      UserFunction,
     void                    *Context,
     void                    **ReturnValue)
 {
     ACPI_STATUS             Status;
     ACPI_GET_DEVICES_INFO   Info;
 
 
     ACPI_FUNCTION_TRACE (AcpiGetDevices);
 
 
     /* Parameter validation */
 
     if (!UserFunction)
     {
         return_ACPI_STATUS (AE_BAD_PARAMETER);
     }
 
     /*
      * We're going to call their callback from OUR callback, so we need
      * to know what it is, and their context parameter.
      */
     Info.Hid          = HID;
     Info.Context      = Context;
     Info.UserFunction = UserFunction;
 
     /*
      * Lock the namespace around the walk.
      * The namespace will be unlocked/locked around each call
      * to the user function - since this function
      * must be allowed to make Acpi calls itself.
      */
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
                 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
                 AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue);
 
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return_ACPI_STATUS (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiGetDevices)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiAttachData
  *
  * PARAMETERS:  ObjHandle           - Namespace node
  *              Handler             - Handler for this attachment
  *              Data                - Pointer to data to be attached
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiAttachData (
     ACPI_HANDLE             ObjHandle,
     ACPI_OBJECT_HANDLER     Handler,
     void                    *Data)
 {
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
 
 
     /* Parameter validation */
 
     if (!ObjHandle  ||
         !Handler    ||
         !Data)
     {
         return (AE_BAD_PARAMETER);
     }
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     /* Convert and validate the handle */
 
     Node = AcpiNsValidateHandle (ObjHandle);
     if (!Node)
     {
         Status = AE_BAD_PARAMETER;
         goto UnlockAndExit;
     }
 
     Status = AcpiNsAttachData (Node, Handler, Data);
 
 UnlockAndExit:
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiAttachData)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiDetachData
  *
  * PARAMETERS:  ObjHandle           - Namespace node handle
  *              Handler             - Handler used in call to AcpiAttachData
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Remove data that was previously attached to a node.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiDetachData (
     ACPI_HANDLE             ObjHandle,
     ACPI_OBJECT_HANDLER     Handler)
 {
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
 
 
     /* Parameter validation */
 
     if (!ObjHandle  ||
         !Handler)
     {
         return (AE_BAD_PARAMETER);
     }
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     /* Convert and validate the handle */
 
     Node = AcpiNsValidateHandle (ObjHandle);
     if (!Node)
     {
         Status = AE_BAD_PARAMETER;
         goto UnlockAndExit;
     }
 
     Status = AcpiNsDetachData (Node, Handler);
 
 UnlockAndExit:
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiDetachData)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiGetData
  *
  * PARAMETERS:  ObjHandle           - Namespace node
  *              Handler             - Handler used in call to AttachData
  *              Data                - Where the data is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiGetData (
     ACPI_HANDLE             ObjHandle,
     ACPI_OBJECT_HANDLER     Handler,
     void                    **Data)
 {
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
 
 
     /* Parameter validation */
 
     if (!ObjHandle  ||
         !Handler    ||
         !Data)
     {
         return (AE_BAD_PARAMETER);
     }
 
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     /* Convert and validate the handle */
 
     Node = AcpiNsValidateHandle (ObjHandle);
     if (!Node)
     {
         Status = AE_BAD_PARAMETER;
         goto UnlockAndExit;
     }
 
     Status = AcpiNsGetAttachedData (Node, Handler, Data);
 
 UnlockAndExit:
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return (Status);
 }
 
 ACPI_EXPORT_SYMBOL (AcpiGetData)
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/namespace
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/components/namespace:r249197-249698
   Merged /vendor-sys/acpica/dist/source/components/namespace:r249111-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser/psxface.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser/psxface.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser/psxface.c	(revision 249699)
@@ -1,440 +1,440 @@
 /******************************************************************************
  *
  * Module Name: psxface - Parser external interfaces
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __PSXFACE_C__
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 
 #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))
+        (AcpiGbl_TraceMethodName != Info->Node->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))
+        (AcpiGbl_TraceMethodName != Info->Node->Name.Integer))
     {
         goto Exit;
     }
 
     /* Disable further tracing if type is one-shot */
 
     if (AcpiGbl_TraceFlags & 1)
     {
         AcpiGbl_TraceMethodName = 0;
         AcpiGbl_TraceDbgLevel = 0;
         AcpiGbl_TraceDbgLayer = 0;
     }
 
     AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
     AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
 
 Exit:
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiPsExecuteMethod
  *
  * PARAMETERS:  Info            - Method info block, contains:
  *                  Node            - Method Node to execute
  *                  ObjDesc         - Method object
  *                  Parameters      - List of parameters to pass to the method,
  *                                    terminated by NULL. Params itself may be
  *                                    NULL if no parameters are being passed.
  *                  ReturnObject    - Where to put method's return value (if
  *                                    any). If NULL, no value is returned.
  *                  ParameterType   - Type of Parameter list
  *                  ReturnObject    - Where to put method's return value (if
  *                                    any). If NULL, no value is returned.
  *                  PassNumber      - Parse or execute pass
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Execute a control method
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiPsExecuteMethod (
     ACPI_EVALUATE_INFO      *Info)
 {
     ACPI_STATUS             Status;
     ACPI_PARSE_OBJECT       *Op;
     ACPI_WALK_STATE         *WalkState;
 
 
     ACPI_FUNCTION_TRACE (PsExecuteMethod);
 
 
     /* Quick validation of DSDT header */
 
     AcpiTbCheckDsdtHeader ();
 
     /* Validate the Info and method Node */
 
-    if (!Info || !Info->ResolvedNode)
+    if (!Info || !Info->Node)
     {
         return_ACPI_STATUS (AE_NULL_ENTRY);
     }
 
     /* Init for new method, wait on concurrency semaphore */
 
-    Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
+    Status = AcpiDsBeginMethodExecution (Info->Node, 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));
+        Info->Node->Name.Ascii, Info->Node, 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,
+    Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node,
                 Info->ObjDesc->Method.AmlStart,
                 Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
     if (ACPI_FAILURE (Status))
     {
         AcpiDsDeleteWalkState (WalkState);
         goto Cleanup;
     }
 
     if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
     {
         WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
     }
 
     /* Invoke an internal method if necessary */
 
     if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
     {
         Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
         Info->ReturnObject = WalkState->ReturnDesc;
 
         /* Cleanup states */
 
         AcpiDsScopeStackClear (WalkState);
         AcpiPsCleanupScope (&WalkState->ParserState);
         AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
         AcpiDsDeleteWalkState (WalkState);
         goto Cleanup;
     }
 
     /*
      * Start method evaluation with an implicit return of zero.
      * This is done for Windows compatibility.
      */
     if (AcpiGbl_EnableInterpreterSlack)
     {
         WalkState->ImplicitReturnObj =
             AcpiUtCreateIntegerObject ((UINT64) 0);
         if (!WalkState->ImplicitReturnObj)
         {
             Status = AE_NO_MEMORY;
             AcpiDsDeleteWalkState (WalkState);
             goto Cleanup;
         }
     }
 
     /* Parse the AML */
 
     Status = AcpiPsParseAml (WalkState);
 
     /* WalkState was deleted by ParseAml */
 
 Cleanup:
     AcpiPsDeleteParseTree (Op);
 
     /* End optional tracing */
 
     AcpiPsStopTrace (Info);
 
     /* Take away the extra reference that we gave the parameters above */
 
     AcpiPsUpdateParameterList (Info, REF_DECREMENT);
 
     /* Exit now if error above */
 
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * If the method has returned an object, signal this to the caller with
      * a control exception code
      */
     if (Info->ReturnObject)
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
             Info->ReturnObject));
         ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
 
         Status = AE_CTRL_RETURN_VALUE;
     }
 
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiPsUpdateParameterList
  *
  * PARAMETERS:  Info            - See ACPI_EVALUATE_INFO
  *                                (Used: ParameterType and Parameters)
  *              Action          - Add or Remove reference
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Update reference count on all method parameter objects
  *
  ******************************************************************************/
 
 static void
 AcpiPsUpdateParameterList (
     ACPI_EVALUATE_INFO      *Info,
     UINT16                  Action)
 {
     UINT32                  i;
 
 
     if (Info->Parameters)
     {
         /* Update reference count for each parameter */
 
         for (i = 0; Info->Parameters[i]; i++)
         {
             /* Ignore errors, just do them all */
 
             (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
         }
     }
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/parser
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/components/parser:r246849-249661
   Merged /head/sys/contrib/dev/acpica/components/parser:r247225-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources/rsutils.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources/rsutils.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources/rsutils.c	(revision 249699)
@@ -1,861 +1,861 @@
 /*******************************************************************************
  *
  * Module Name: rsutils - Utilities for the resource manager
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #define __RSUTILS_C__
 
 #include 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_RESOURCES
         ACPI_MODULE_NAME    ("rsutils")
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsDecodeBitmask
  *
  * PARAMETERS:  Mask            - Bitmask to decode
  *              List            - Where the converted list is returned
  *
  * RETURN:      Count of bits set (length of list)
  *
  * DESCRIPTION: Convert a bit mask into a list of values
  *
  ******************************************************************************/
 
 UINT8
 AcpiRsDecodeBitmask (
     UINT16                  Mask,
     UINT8                   *List)
 {
     UINT8                   i;
     UINT8                   BitCount;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     /* Decode the mask bits */
 
     for (i = 0, BitCount = 0; Mask; i++)
     {
         if (Mask & 0x0001)
         {
             List[BitCount] = i;
             BitCount++;
         }
 
         Mask >>= 1;
     }
 
     return (BitCount);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsEncodeBitmask
  *
  * PARAMETERS:  List            - List of values to encode
  *              Count           - Length of list
  *
  * RETURN:      Encoded bitmask
  *
  * DESCRIPTION: Convert a list of values to an encoded bitmask
  *
  ******************************************************************************/
 
 UINT16
 AcpiRsEncodeBitmask (
     UINT8                   *List,
     UINT8                   Count)
 {
     UINT32                  i;
     UINT16                  Mask;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     /* Encode the list into a single bitmask */
 
     for (i = 0, Mask = 0; i < Count; i++)
     {
         Mask |= (0x1 << List[i]);
     }
 
     return (Mask);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsMoveData
  *
  * PARAMETERS:  Destination         - Pointer to the destination descriptor
  *              Source              - Pointer to the source descriptor
  *              ItemCount           - How many items to move
  *              MoveType            - Byte width
  *
  * RETURN:      None
  *
  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
  *              alignment issues and endian issues if necessary, as configured
  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
  *
  ******************************************************************************/
 
 void
 AcpiRsMoveData (
     void                    *Destination,
     void                    *Source,
     UINT16                  ItemCount,
     UINT8                   MoveType)
 {
     UINT32                  i;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     /* One move per item */
 
     for (i = 0; i < ItemCount; i++)
     {
         switch (MoveType)
         {
         /*
          * For the 8-bit case, we can perform the move all at once
          * since there are no alignment or endian issues
          */
         case ACPI_RSC_MOVE8:
         case ACPI_RSC_MOVE_GPIO_RES:
         case ACPI_RSC_MOVE_SERIAL_VEN:
         case ACPI_RSC_MOVE_SERIAL_RES:
             ACPI_MEMCPY (Destination, Source, ItemCount);
             return;
 
         /*
          * 16-, 32-, and 64-bit cases must use the move macros that perform
          * endian conversion and/or accommodate hardware that cannot perform
          * misaligned memory transfers
          */
         case ACPI_RSC_MOVE16:
         case ACPI_RSC_MOVE_GPIO_PIN:
             ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
                                 &ACPI_CAST_PTR (UINT16, Source)[i]);
             break;
 
         case ACPI_RSC_MOVE32:
             ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
                                 &ACPI_CAST_PTR (UINT32, Source)[i]);
             break;
 
         case ACPI_RSC_MOVE64:
             ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
                                 &ACPI_CAST_PTR (UINT64, Source)[i]);
             break;
 
         default:
             return;
         }
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsSetResourceLength
  *
  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
  *                                    the header and length fields.
  *              Aml                 - Pointer to the raw AML descriptor
  *
  * RETURN:      None
  *
  * DESCRIPTION: Set the ResourceLength field of an AML
  *              resource descriptor, both Large and Small descriptors are
  *              supported automatically. Note: Descriptor Type field must
  *              be valid.
  *
  ******************************************************************************/
 
 void
 AcpiRsSetResourceLength (
     ACPI_RSDESC_SIZE        TotalLength,
     AML_RESOURCE            *Aml)
 {
     ACPI_RS_LENGTH          ResourceLength;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     /* Length is the total descriptor length minus the header length */
 
     ResourceLength = (ACPI_RS_LENGTH)
         (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
 
     /* Length is stored differently for large and small descriptors */
 
     if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
     {
         /* Large descriptor -- bytes 1-2 contain the 16-bit length */
 
         ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength);
     }
     else
     {
         /* Small descriptor -- bits 2:0 of byte 0 contain the length */
 
         Aml->SmallHeader.DescriptorType = (UINT8)
 
             /* Clear any existing length, preserving descriptor type bits */
 
             ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
 
             | ResourceLength);
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsSetResourceHeader
  *
  * PARAMETERS:  DescriptorType      - Byte to be inserted as the type
  *              TotalLength         - Length of the AML descriptor, including
  *                                    the header and length fields.
  *              Aml                 - Pointer to the raw AML descriptor
  *
  * RETURN:      None
  *
  * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
  *              resource descriptor, both Large and Small descriptors are
  *              supported automatically
  *
  ******************************************************************************/
 
 void
 AcpiRsSetResourceHeader (
     UINT8                   DescriptorType,
     ACPI_RSDESC_SIZE        TotalLength,
     AML_RESOURCE            *Aml)
 {
     ACPI_FUNCTION_ENTRY ();
 
 
     /* Set the Resource Type */
 
     Aml->SmallHeader.DescriptorType = DescriptorType;
 
     /* Set the Resource Length */
 
     AcpiRsSetResourceLength (TotalLength, Aml);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsStrcpy
  *
  * PARAMETERS:  Destination         - Pointer to the destination string
  *              Source              - Pointer to the source string
  *
  * RETURN:      String length, including NULL terminator
  *
  * DESCRIPTION: Local string copy that returns the string length, saving a
  *              strcpy followed by a strlen.
  *
  ******************************************************************************/
 
 static UINT16
 AcpiRsStrcpy (
     char                    *Destination,
     char                    *Source)
 {
     UINT16                  i;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     for (i = 0; Source[i]; i++)
     {
         Destination[i] = Source[i];
     }
 
     Destination[i] = 0;
 
     /* Return string length including the NULL terminator */
 
     return ((UINT16) (i + 1));
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetResourceSource
  *
  * PARAMETERS:  ResourceLength      - Length field of the descriptor
  *              MinimumLength       - Minimum length of the descriptor (minus
  *                                    any optional fields)
  *              ResourceSource      - Where the ResourceSource is returned
  *              Aml                 - Pointer to the raw AML descriptor
  *              StringPtr           - (optional) where to store the actual
  *                                    ResourceSource string
  *
  * RETURN:      Length of the string plus NULL terminator, rounded up to native
  *              word boundary
  *
  * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
  *              to an internal resource descriptor
  *
  ******************************************************************************/
 
 ACPI_RS_LENGTH
 AcpiRsGetResourceSource (
     ACPI_RS_LENGTH          ResourceLength,
     ACPI_RS_LENGTH          MinimumLength,
     ACPI_RESOURCE_SOURCE    *ResourceSource,
     AML_RESOURCE            *Aml,
     char                    *StringPtr)
 {
     ACPI_RSDESC_SIZE        TotalLength;
     UINT8                   *AmlResourceSource;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
     AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
 
     /*
      * ResourceSource is present if the length of the descriptor is longer than
      * the minimum length.
      *
      * Note: Some resource descriptors will have an additional null, so
      * we add 1 to the minimum length.
      */
     if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
     {
         /* Get the ResourceSourceIndex */
 
         ResourceSource->Index = AmlResourceSource[0];
 
         ResourceSource->StringPtr = StringPtr;
         if (!StringPtr)
         {
             /*
              * String destination pointer is not specified; Set the String
              * pointer to the end of the current ResourceSource structure.
              */
             ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource,
                 sizeof (ACPI_RESOURCE_SOURCE));
         }
 
         /*
          * In order for the Resource length to be a multiple of the native
          * word, calculate the length of the string (+1 for NULL terminator)
          * and expand to the next word multiple.
          *
          * Zero the entire area of the buffer.
          */
         TotalLength = (UINT32) ACPI_STRLEN (
             ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
         TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
 
         ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength);
 
         /* Copy the ResourceSource string to the destination */
 
         ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr,
             ACPI_CAST_PTR (char, &AmlResourceSource[1]));
 
         return ((ACPI_RS_LENGTH) TotalLength);
     }
 
     /* ResourceSource is not present */
 
     ResourceSource->Index = 0;
     ResourceSource->StringLength = 0;
     ResourceSource->StringPtr = NULL;
     return (0);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsSetResourceSource
  *
  * PARAMETERS:  Aml                 - Pointer to the raw AML descriptor
  *              MinimumLength       - Minimum length of the descriptor (minus
  *                                    any optional fields)
  *              ResourceSource      - Internal ResourceSource
 
  *
  * RETURN:      Total length of the AML descriptor
  *
  * DESCRIPTION: Convert an optional ResourceSource from internal format to a
  *              raw AML resource descriptor
  *
  ******************************************************************************/
 
 ACPI_RSDESC_SIZE
 AcpiRsSetResourceSource (
     AML_RESOURCE            *Aml,
     ACPI_RS_LENGTH          MinimumLength,
     ACPI_RESOURCE_SOURCE    *ResourceSource)
 {
     UINT8                   *AmlResourceSource;
     ACPI_RSDESC_SIZE        DescriptorLength;
 
 
     ACPI_FUNCTION_ENTRY ();
 
 
     DescriptorLength = MinimumLength;
 
     /* Non-zero string length indicates presence of a ResourceSource */
 
     if (ResourceSource->StringLength)
     {
         /* Point to the end of the AML descriptor */
 
         AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
 
         /* Copy the ResourceSourceIndex */
 
         AmlResourceSource[0] = (UINT8) ResourceSource->Index;
 
         /* Copy the ResourceSource string */
 
         ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
             ResourceSource->StringPtr);
 
         /*
          * Add the length of the string (+ 1 for null terminator) to the
          * final descriptor length
          */
         DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1);
     }
 
     /* Return the new total length of the AML descriptor */
 
     return (DescriptorLength);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetPrtMethodData
  *
  * PARAMETERS:  Node            - Device node
  *              RetBuffer       - Pointer to a buffer structure for the
  *                                results
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get the _PRT value of an object
  *              contained in an object specified by the handle passed in
  *
  *              If the function fails an appropriate status will be returned
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiRsGetPrtMethodData (
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_BUFFER             *RetBuffer)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
 
 
     /* Parameters guaranteed valid by caller */
 
     /* Execute the method, no parameters */
 
     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
                 ACPI_BTYPE_PACKAGE, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * Create a resource linked list from the byte stream buffer that comes
      * back from the _CRS method execution.
      */
     Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
 
     /* On exit, we must delete the object returned by EvaluateObject */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetCrsMethodData
  *
  * PARAMETERS:  Node            - Device node
  *              RetBuffer       - Pointer to a buffer structure for the
  *                                results
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get the _CRS value of an object
  *              contained in an object specified by the handle passed in
  *
  *              If the function fails an appropriate status will be returned
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiRsGetCrsMethodData (
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_BUFFER             *RetBuffer)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
 
 
     /* Parameters guaranteed valid by caller */
 
     /* Execute the method, no parameters */
 
     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
                 ACPI_BTYPE_BUFFER, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * Make the call to create a resource linked list from the
      * byte stream buffer that comes back from the _CRS method
      * execution.
      */
     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
     /* On exit, we must delete the object returned by evaluateObject */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetPrsMethodData
  *
  * PARAMETERS:  Node            - Device node
  *              RetBuffer       - Pointer to a buffer structure for the
  *                                results
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get the _PRS value of an object
  *              contained in an object specified by the handle passed in
  *
  *              If the function fails an appropriate status will be returned
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiRsGetPrsMethodData (
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_BUFFER             *RetBuffer)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
 
 
     /* Parameters guaranteed valid by caller */
 
     /* Execute the method, no parameters */
 
     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
                 ACPI_BTYPE_BUFFER, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * Make the call to create a resource linked list from the
      * byte stream buffer that comes back from the _CRS method
      * execution.
      */
     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
     /* On exit, we must delete the object returned by evaluateObject */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetAeiMethodData
  *
  * PARAMETERS:  Node            - Device node
  *              RetBuffer       - Pointer to a buffer structure for the
  *                                results
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get the _AEI value of an object
  *              contained in an object specified by the handle passed in
  *
  *              If the function fails an appropriate status will be returned
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiRsGetAeiMethodData (
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_BUFFER             *RetBuffer)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
 
 
     /* Parameters guaranteed valid by caller */
 
     /* Execute the method, no parameters */
 
     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
                 ACPI_BTYPE_BUFFER, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /*
      * Make the call to create a resource linked list from the
      * byte stream buffer that comes back from the _CRS method
      * execution.
      */
     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 
     /* On exit, we must delete the object returned by evaluateObject */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiRsGetMethodData
  *
  * PARAMETERS:  Handle          - Handle to the containing object
  *              Path            - Path to method, relative to Handle
  *              RetBuffer       - Pointer to a buffer structure for the
  *                                results
  *
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
  *              object contained in an object specified by the handle passed in
  *
  *              If the function fails an appropriate status will be returned
  *              and the contents of the callers buffer is undefined.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiRsGetMethodData (
     ACPI_HANDLE             Handle,
     char                    *Path,
     ACPI_BUFFER             *RetBuffer)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (RsGetMethodData);
 
 
     /* Parameters guaranteed valid by caller */
 
     /* Execute the method, no parameters */
 
     Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, 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->RelativePathname = 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);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/resources
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/components/resources:r246849-249661
   Merged /head/sys/contrib/dev/acpica/components/resources:r247225-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/uteval.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/uteval.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/uteval.c	(revision 249699)
@@ -1,370 +1,370 @@
 /******************************************************************************
  *
  * Module Name: uteval - Object evaluation
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __UTEVAL_C__
 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_UTILITIES
         ACPI_MODULE_NAME    ("uteval")
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtEvaluateObject
  *
  * PARAMETERS:  PrefixNode          - Starting node
  *              Path                - Path to object from starting node
  *              ExpectedReturnTypes - Bitmap of allowed return types
  *              ReturnDesc          - Where a return value is stored
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
  *              return object. Common code that simplifies accessing objects
  *              that have required return objects of fixed types.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtEvaluateObject (
     ACPI_NAMESPACE_NODE     *PrefixNode,
     char                    *Path,
     UINT32                  ExpectedReturnBtypes,
     ACPI_OPERAND_OBJECT     **ReturnDesc)
 {
     ACPI_EVALUATE_INFO      *Info;
     ACPI_STATUS             Status;
     UINT32                  ReturnBtype;
 
 
     ACPI_FUNCTION_TRACE (UtEvaluateObject);
 
 
     /* Allocate the evaluation information block */
 
     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
     if (!Info)
     {
         return_ACPI_STATUS (AE_NO_MEMORY);
     }
 
     Info->PrefixNode = PrefixNode;
-    Info->Pathname = Path;
+    Info->RelativePathname = Path;
 
     /* Evaluate the object/method */
 
     Status = AcpiNsEvaluate (Info);
     if (ACPI_FAILURE (Status))
     {
         if (Status == AE_NOT_FOUND)
         {
             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
                 AcpiUtGetNodeName (PrefixNode), Path));
         }
         else
         {
             ACPI_ERROR_METHOD ("Method execution failed",
                 PrefixNode, Path, Status);
         }
 
         goto Cleanup;
     }
 
     /* Did we get a return object? */
 
     if (!Info->ReturnObject)
     {
         if (ExpectedReturnBtypes)
         {
             ACPI_ERROR_METHOD ("No object was returned from",
                 PrefixNode, Path, AE_NOT_EXIST);
 
             Status = AE_NOT_EXIST;
         }
 
         goto Cleanup;
     }
 
     /* Map the return object type to the bitmapped type */
 
     switch ((Info->ReturnObject)->Common.Type)
     {
     case ACPI_TYPE_INTEGER:
         ReturnBtype = ACPI_BTYPE_INTEGER;
         break;
 
     case ACPI_TYPE_BUFFER:
         ReturnBtype = ACPI_BTYPE_BUFFER;
         break;
 
     case ACPI_TYPE_STRING:
         ReturnBtype = ACPI_BTYPE_STRING;
         break;
 
     case ACPI_TYPE_PACKAGE:
         ReturnBtype = ACPI_BTYPE_PACKAGE;
         break;
 
     default:
         ReturnBtype = 0;
         break;
     }
 
     if ((AcpiGbl_EnableInterpreterSlack) &&
         (!ExpectedReturnBtypes))
     {
         /*
          * We received a return object, but one was not expected. This can
          * happen frequently if the "implicit return" feature is enabled.
          * Just delete the return object and return AE_OK.
          */
         AcpiUtRemoveReference (Info->ReturnObject);
         goto Cleanup;
     }
 
     /* Is the return object one of the expected types? */
 
     if (!(ExpectedReturnBtypes & ReturnBtype))
     {
         ACPI_ERROR_METHOD ("Return object type is incorrect",
             PrefixNode, Path, AE_TYPE);
 
         ACPI_ERROR ((AE_INFO,
             "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
             Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
             ExpectedReturnBtypes));
 
         /* On error exit, we must delete the return object */
 
         AcpiUtRemoveReference (Info->ReturnObject);
         Status = AE_TYPE;
         goto Cleanup;
     }
 
     /* Object type is OK, return it */
 
     *ReturnDesc = Info->ReturnObject;
 
 Cleanup:
     ACPI_FREE (Info);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtEvaluateNumericObject
  *
  * PARAMETERS:  ObjectName          - Object name to be evaluated
  *              DeviceNode          - Node for the device
  *              Value               - Where the value is returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
  *              and stores result in *Value.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtEvaluateNumericObject (
     char                    *ObjectName,
     ACPI_NAMESPACE_NODE     *DeviceNode,
     UINT64                  *Value)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
 
 
     Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
                 ACPI_BTYPE_INTEGER, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
 
     /* Get the returned Integer */
 
     *Value = ObjDesc->Integer.Value;
 
     /* On exit, we must delete the return object */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtExecute_STA
  *
  * PARAMETERS:  DeviceNode          - Node for the device
  *              Flags               - Where the status flags are returned
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Executes _STA for selected device and stores results in
  *              *Flags.
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtExecute_STA (
     ACPI_NAMESPACE_NODE     *DeviceNode,
     UINT32                  *Flags)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
 
 
     ACPI_FUNCTION_TRACE (UtExecute_STA);
 
 
     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
                 ACPI_BTYPE_INTEGER, &ObjDesc);
     if (ACPI_FAILURE (Status))
     {
         if (AE_NOT_FOUND == Status)
         {
             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
                 "_STA on %4.4s was not found, assuming device is present\n",
                 AcpiUtGetNodeName (DeviceNode)));
 
             *Flags = ACPI_UINT32_MAX;
             Status = AE_OK;
         }
 
         return_ACPI_STATUS (Status);
     }
 
     /* Extract the status flags */
 
     *Flags = (UINT32) ObjDesc->Integer.Value;
 
     /* On exit, we must delete the return object */
 
     AcpiUtRemoveReference (ObjDesc);
     return_ACPI_STATUS (Status);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtExecutePowerMethods
  *
  * PARAMETERS:  DeviceNode          - Node for the device
  *              MethodNames         - Array of power method names
  *              MethodCount         - Number of methods to execute
  *              OutValues           - Where the power method values are returned
  *
  * RETURN:      Status, OutValues
  *
  * DESCRIPTION: Executes the specified power methods for the device and returns
  *              the result(s).
  *
  *              NOTE: Internal function, no parameter validation
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtExecutePowerMethods (
     ACPI_NAMESPACE_NODE     *DeviceNode,
     const char              **MethodNames,
     UINT8                   MethodCount,
     UINT8                   *OutValues)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_STATUS             Status;
     ACPI_STATUS             FinalStatus = AE_NOT_FOUND;
     UINT32                  i;
 
 
     ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
 
 
     for (i = 0; i < MethodCount; i++)
     {
         /*
          * Execute the power method (_SxD or _SxW). The only allowable
          * return type is an Integer.
          */
         Status = AcpiUtEvaluateObject (DeviceNode,
                     ACPI_CAST_PTR (char, MethodNames[i]),
                     ACPI_BTYPE_INTEGER, &ObjDesc);
         if (ACPI_SUCCESS (Status))
         {
             OutValues[i] = (UINT8) ObjDesc->Integer.Value;
 
             /* Delete the return object */
 
             AcpiUtRemoveReference (ObjDesc);
             FinalStatus = AE_OK;            /* At least one value is valid */
             continue;
         }
 
         OutValues[i] = ACPI_UINT8_MAX;
         if (Status == AE_NOT_FOUND)
         {
             continue; /* Ignore if not found */
         }
 
         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
             ACPI_CAST_PTR (char, MethodNames[i]),
             AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
     }
 
     return_ACPI_STATUS (FinalStatus);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utosi.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utosi.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utosi.c	(revision 249699)
@@ -1,441 +1,441 @@
 /******************************************************************************
  *
  * Module Name: utosi - Support for the _OSI predefined control method
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __UTOSI_C__
 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_UTILITIES
         ACPI_MODULE_NAME    ("utosi")
 
 /*
  * Strings supported by the _OSI predefined control method (which is
  * implemented internally within this module.)
  *
  * March 2009: Removed "Linux" as this host no longer wants to respond true
  * for this string. Basically, the only safe OS strings are windows-related
  * and in many or most cases represent the only test path within the
  * BIOS-provided ASL code.
  *
  * The last element of each entry is used to track the newest version of
  * Windows that the BIOS has requested.
  */
 static ACPI_INTERFACE_INFO    AcpiDefaultSupportedInterfaces[] =
 {
     /* Operating System Vendor Strings */
 
     {"Windows 2000",        NULL, 0, ACPI_OSI_WIN_2000},         /* Windows 2000 */
     {"Windows 2001",        NULL, 0, ACPI_OSI_WIN_XP},           /* Windows XP */
     {"Windows 2001 SP1",    NULL, 0, ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
     {"Windows 2001.1",      NULL, 0, ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
     {"Windows 2001 SP2",    NULL, 0, ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
     {"Windows 2001.1 SP1",  NULL, 0, ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
     {"Windows 2006",        NULL, 0, ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
     {"Windows 2006.1",      NULL, 0, ACPI_OSI_WINSRV_2008},      /* Windows Server 2008 - Added 09/2009 */
     {"Windows 2006 SP1",    NULL, 0, ACPI_OSI_WIN_VISTA_SP1},    /* Windows Vista SP1 - Added 09/2009 */
     {"Windows 2006 SP2",    NULL, 0, ACPI_OSI_WIN_VISTA_SP2},    /* Windows Vista SP2 - Added 09/2010 */
     {"Windows 2009",        NULL, 0, ACPI_OSI_WIN_7},            /* Windows 7 and Server 2008 R2 - Added 09/2009 */
     {"Windows 2012",        NULL, 0, ACPI_OSI_WIN_8},            /* Windows 8 and Server 2012 - Added 08/2012 */
 
     /* Feature Group Strings */
 
     {"Extended Address Space Descriptor", NULL, 0, 0}
 
     /*
      * All "optional" feature group strings (features that are implemented
      * by the host) should be dynamically added by the host via
      * AcpiInstallInterface and should not be manually added here.
      *
      * Examples of optional feature group strings:
      *
      * "Module Device"
      * "Processor Device"
      * "3.0 Thermal Model"
      * "3.0 _SCP Extensions"
      * "Processor Aggregator Device"
      */
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtInitializeInterfaces
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Initialize the global _OSI supported interfaces list
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtInitializeInterfaces (
     void)
 {
     ACPI_STATUS             Status;
     UINT32                  i;
 
 
     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
 
     /* Link the static list of supported interfaces */
 
     for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
     {
         AcpiDefaultSupportedInterfaces[i].Next =
             &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
     }
 
     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtInterfaceTerminate
  *
  * PARAMETERS:  None
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Delete all interfaces in the global list. Sets
  *              AcpiGbl_SupportedInterfaces to NULL.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtInterfaceTerminate (
     void)
 {
     ACPI_STATUS             Status;
     ACPI_INTERFACE_INFO     *NextInterface;
 
 
     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
     NextInterface = AcpiGbl_SupportedInterfaces;
     while (NextInterface)
     {
         AcpiGbl_SupportedInterfaces = NextInterface->Next;
 
         /* Only interfaces added at runtime can be freed */
 
         if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
         {
             ACPI_FREE (NextInterface->Name);
             ACPI_FREE (NextInterface);
         }
 
         NextInterface = AcpiGbl_SupportedInterfaces;
     }
 
     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtInstallInterface
  *
  * PARAMETERS:  InterfaceName       - The interface to install
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Install the interface into the global interface list.
  *              Caller MUST hold AcpiGbl_OsiMutex
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtInstallInterface (
     ACPI_STRING             InterfaceName)
 {
     ACPI_INTERFACE_INFO     *InterfaceInfo;
 
 
     /* Allocate info block and space for the name string */
 
     InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
     if (!InterfaceInfo)
     {
         return (AE_NO_MEMORY);
     }
 
     InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
     if (!InterfaceInfo->Name)
     {
         ACPI_FREE (InterfaceInfo);
         return (AE_NO_MEMORY);
     }
 
     /* Initialize new info and insert at the head of the global list */
 
     ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
     InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
     InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
 
     AcpiGbl_SupportedInterfaces = InterfaceInfo;
     return (AE_OK);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtRemoveInterface
  *
  * PARAMETERS:  InterfaceName       - The interface to remove
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Remove the interface from the global interface list.
  *              Caller MUST hold AcpiGbl_OsiMutex
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtRemoveInterface (
     ACPI_STRING             InterfaceName)
 {
     ACPI_INTERFACE_INFO     *PreviousInterface;
     ACPI_INTERFACE_INFO     *NextInterface;
 
 
     PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
     while (NextInterface)
     {
         if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
         {
             /* Found: name is in either the static list or was added at runtime */
 
             if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
             {
                 /* Interface was added dynamically, remove and free it */
 
                 if (PreviousInterface == NextInterface)
                 {
                     AcpiGbl_SupportedInterfaces = NextInterface->Next;
                 }
                 else
                 {
                     PreviousInterface->Next = NextInterface->Next;
                 }
 
                 ACPI_FREE (NextInterface->Name);
                 ACPI_FREE (NextInterface);
             }
             else
             {
                 /*
                  * Interface is in static list. If marked invalid, then it
                  * does not actually exist. Else, mark it invalid.
                  */
                 if (NextInterface->Flags & ACPI_OSI_INVALID)
                 {
                     return (AE_NOT_EXIST);
                 }
 
                 NextInterface->Flags |= ACPI_OSI_INVALID;
             }
 
             return (AE_OK);
         }
 
         PreviousInterface = NextInterface;
         NextInterface = NextInterface->Next;
     }
 
     /* Interface was not found */
 
     return (AE_NOT_EXIST);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtGetInterface
  *
  * PARAMETERS:  InterfaceName       - The interface to find
  *
  * RETURN:      ACPI_INTERFACE_INFO if found. NULL if not found.
  *
  * DESCRIPTION: Search for the specified interface name in the global list.
  *              Caller MUST hold AcpiGbl_OsiMutex
  *
  ******************************************************************************/
 
 ACPI_INTERFACE_INFO *
 AcpiUtGetInterface (
     ACPI_STRING             InterfaceName)
 {
     ACPI_INTERFACE_INFO     *NextInterface;
 
 
     NextInterface = AcpiGbl_SupportedInterfaces;
     while (NextInterface)
     {
         if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
         {
             return (NextInterface);
         }
 
         NextInterface = NextInterface->Next;
     }
 
     return (NULL);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtOsiImplementation
  *
  * PARAMETERS:  WalkState           - Current walk state
  *
  * RETURN:      Status
  *
  * DESCRIPTION: Implementation of the _OSI predefined control method. When
  *              an invocation of _OSI is encountered in the system AML,
  *              control is transferred to this function.
  *
  ******************************************************************************/
 
 ACPI_STATUS
 AcpiUtOsiImplementation (
     ACPI_WALK_STATE         *WalkState)
 {
     ACPI_OPERAND_OBJECT     *StringDesc;
     ACPI_OPERAND_OBJECT     *ReturnDesc;
     ACPI_INTERFACE_INFO     *InterfaceInfo;
     ACPI_INTERFACE_HANDLER  InterfaceHandler;
     ACPI_STATUS             Status;
     UINT32                  ReturnValue;
 
 
     ACPI_FUNCTION_TRACE (UtOsiImplementation);
 
 
     /* Validate the string input argument (from the AML caller) */
 
     StringDesc = WalkState->Arguments[0].Object;
     if (!StringDesc ||
         (StringDesc->Common.Type != ACPI_TYPE_STRING))
     {
         return_ACPI_STATUS (AE_TYPE);
     }
 
     /* Create a return object */
 
     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
     if (!ReturnDesc)
     {
         return_ACPI_STATUS (AE_NO_MEMORY);
     }
 
     /* Default return value is 0, NOT SUPPORTED */
 
     ReturnValue = 0;
     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
     if (ACPI_FAILURE (Status))
     {
-        AcpiUtDeleteObjectDesc (ReturnDesc);
+        AcpiUtRemoveReference (ReturnDesc);
         return_ACPI_STATUS (Status);
     }
 
     /* Lookup the interface in the global _OSI list */
 
     InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
     if (InterfaceInfo &&
         !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
     {
         /*
          * The interface is supported.
          * Update the OsiData if necessary. We keep track of the latest
          * version of Windows that has been requested by the BIOS.
          */
         if (InterfaceInfo->Value > AcpiGbl_OsiData)
         {
             AcpiGbl_OsiData = InterfaceInfo->Value;
         }
 
         ReturnValue = ACPI_UINT32_MAX;
     }
 
     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
 
     /*
      * Invoke an optional _OSI interface handler. The host OS may wish
      * to do some interface-specific handling. For example, warn about
      * certain interfaces or override the true/false support value.
      */
     InterfaceHandler = AcpiGbl_InterfaceHandler;
     if (InterfaceHandler)
     {
         ReturnValue = InterfaceHandler (
             StringDesc->String.Pointer, ReturnValue);
     }
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
         "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
 
     /* Complete the return object */
 
     ReturnDesc->Integer.Value = ReturnValue;
     WalkState->ReturnDesc = ReturnDesc;
     return_ACPI_STATUS (AE_OK);
 }
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utpredef.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utpredef.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utpredef.c	(revision 249699)
@@ -1,451 +1,452 @@
 /******************************************************************************
  *
  * Module Name: utpredef - support functions for predefined names
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __UTPREDEF_C__
 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_UTILITIES
         ACPI_MODULE_NAME    ("utpredef")
 
 
 /*
  * 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   *UtRtypeNames[] =
 {
     "/Integer",
     "/String",
     "/Buffer",
     "/Package",
     "/Reference",
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtGetNextPredefinedMethod
  *
  * PARAMETERS:  ThisName            - Entry in the predefined method/name table
  *
  * RETURN:      Pointer to next entry in predefined table.
  *
  * DESCRIPTION: Get the next entry in the predefine method table. Handles the
  *              cases where a package info entry follows a method name that
  *              returns a package.
  *
  ******************************************************************************/
 
 const ACPI_PREDEFINED_INFO *
 AcpiUtGetNextPredefinedMethod (
     const ACPI_PREDEFINED_INFO  *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->Info.ExpectedBtypes != ACPI_RTYPE_ALL))
     {
         ThisName++;
     }
 
     ThisName++;
     return (ThisName);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtMatchPredefinedMethod
  *
  * PARAMETERS:  Name                - Name to find
  *
  * 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 *
 AcpiUtMatchPredefinedMethod (
     char                        *Name)
 {
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     /* Quick check for a predefined name, first character must be underscore */
 
     if (Name[0] != '_')
     {
         return (NULL);
     }
 
     /* Search info table for a predefined method/object name */
 
     ThisName = AcpiGbl_PredefinedMethods;
     while (ThisName->Info.Name[0])
     {
         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
         {
             return (ThisName);
         }
 
         ThisName = AcpiUtGetNextPredefinedMethod (ThisName);
     }
 
     return (NULL); /* Not found */
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtGetExpectedReturnTypes
  *
  * PARAMETERS:  Buffer              - Where the formatted string is returned
  *              ExpectedBTypes      - Bitfield of expected data types
  *
  * RETURN:      Formatted string in Buffer.
  *
  * DESCRIPTION: Format the expected object types into a printable string.
  *
  ******************************************************************************/
 
 void
 AcpiUtGetExpectedReturnTypes (
     char                    *Buffer,
     UINT32                  ExpectedBtypes)
 {
     UINT32                  ThisRtype;
     UINT32                  i;
     UINT32                  j;
 
 
+    if (!ExpectedBtypes)
+    {
+        ACPI_STRCPY (Buffer, "NONE");
+        return;
+    }
+
     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, &UtRtypeNames[i][j]);
             j = 0;              /* Use name separator from now on */
         }
 
         ThisRtype <<= 1;    /* Next Rtype */
     }
 }
 
 
 /*******************************************************************************
  *
  * The remaining functions are used by iASL and AcpiHelp only
  *
  ******************************************************************************/
 
 #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
 #include 
 #include 
 
 /* Local prototypes */
 
 static UINT32
 AcpiUtGetArgumentTypes (
     char                    *Buffer,
     UINT16                  ArgumentTypes);
 
 
 /* Types that can be returned externally by a predefined name */
 
 static const char   *UtExternalTypeNames[] = /* Indexed by ACPI_TYPE_* */
 {
     ", UNSUPPORTED-TYPE",
     ", Integer",
     ", String",
     ", Buffer",
     ", Package"
 };
 
 /* Bit widths for resource descriptor predefined names */
 
 static const char   *UtResourceTypeNames[] =
 {
     "/1",
     "/2",
     "/3",
     "/8",
     "/16",
     "/32",
     "/64",
     "/variable",
 };
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtMatchResourceName
  *
  * PARAMETERS:  Name                - Name to find
  *
  * RETURN:      Pointer to entry in the resource table. NULL indicates not
  *              found.
  *
  * DESCRIPTION: Check an object name against the predefined resource
  *              descriptor object list.
  *
  ******************************************************************************/
 
 const ACPI_PREDEFINED_INFO *
 AcpiUtMatchResourceName (
     char                        *Name)
 {
     const ACPI_PREDEFINED_INFO  *ThisName;
 
 
     /* Quick check for a predefined name, first character must be underscore */
 
     if (Name[0] != '_')
     {
         return (NULL);
     }
 
     /* Search info table for a predefined method/object name */
 
     ThisName = AcpiGbl_ResourceNames;
     while (ThisName->Info.Name[0])
     {
         if (ACPI_COMPARE_NAME (Name, ThisName->Info.Name))
         {
             return (ThisName);
         }
 
         ThisName++;
     }
 
     return (NULL); /* Not found */
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtDisplayPredefinedMethod
  *
  * PARAMETERS:  Buffer              - Scratch buffer for this function
  *              ThisName            - Entry in the predefined method/name table
  *              MultiLine           - TRUE if output should be on >1 line
  *
  * RETURN:      None
  *
  * DESCRIPTION: Display information about a predefined method. Number and
  *              type of the input arguments, and expected type(s) for the
  *              return value, if any.
  *
  ******************************************************************************/
 
 void
 AcpiUtDisplayPredefinedMethod (
     char                        *Buffer,
     const ACPI_PREDEFINED_INFO  *ThisName,
     BOOLEAN                     MultiLine)
 {
     UINT32                      ArgCount;
 
     /*
      * Get the argument count and the string buffer
      * containing all argument types
      */
     ArgCount = AcpiUtGetArgumentTypes (Buffer,
         ThisName->Info.ArgumentList);
 
     if (MultiLine)
     {
         printf ("      ");
     }
 
     printf ("%4.4s    Requires %s%u argument%s",
         ThisName->Info.Name,
         (ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM) ?
             "(at least) " : "",
         ArgCount, ArgCount != 1 ? "s" : "");
 
     /* Display the types for any arguments */
 
     if (ArgCount > 0)
     {
         printf (" (%s)", Buffer);
     }
 
     if (MultiLine)
     {
         printf ("\n    ");
     }
 
     /* Get the return value type(s) allowed */
 
     if (ThisName->Info.ExpectedBtypes)
     {
         AcpiUtGetExpectedReturnTypes (Buffer, ThisName->Info.ExpectedBtypes);
         printf ("  Return value types: %s\n", Buffer);
     }
     else
     {
         printf ("  No return value\n");
     }
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtGetArgumentTypes
  *
  * PARAMETERS:  Buffer              - Where to return the formatted types
  *              ArgumentTypes       - Types field for this method
  *
  * RETURN:      Count - the number of arguments required for this method
  *
  * DESCRIPTION: Format the required data types for this method (Integer,
  *              String, Buffer, or Package) and return the required argument
  *              count.
  *
  ******************************************************************************/
 
 static UINT32
 AcpiUtGetArgumentTypes (
     char                    *Buffer,
     UINT16                  ArgumentTypes)
 {
     UINT16                  ThisArgumentType;
     UINT16                  SubIndex;
     UINT16                  ArgCount;
     UINT32                  i;
 
 
     *Buffer = 0;
     SubIndex = 2;
 
     /* First field in the types list is the count of args to follow */
 
-    ArgCount = (ArgumentTypes & METHOD_ARG_MASK);
-    ArgumentTypes >>= METHOD_ARG_BIT_WIDTH;
-
+    ArgCount = METHOD_GET_ARG_COUNT (ArgumentTypes);
     if (ArgCount > METHOD_PREDEF_ARGS_MAX)
     {
         printf ("**** Invalid argument count (%u) "
             "in predefined info structure\n", ArgCount);
         return (ArgCount);
     }
 
     /* Get each argument from the list, convert to ascii, store to buffer */
 
     for (i = 0; i < ArgCount; i++)
     {
-        ThisArgumentType = (ArgumentTypes & METHOD_ARG_MASK);
+        ThisArgumentType = METHOD_GET_NEXT_TYPE (ArgumentTypes);
+
         if (!ThisArgumentType || (ThisArgumentType > METHOD_MAX_ARG_TYPE))
         {
             printf ("**** Invalid argument type (%u) "
                 "in predefined info structure\n", ThisArgumentType);
             return (ArgCount);
         }
 
         strcat (Buffer, UtExternalTypeNames[ThisArgumentType] + SubIndex);
-
-        /* Shift to next argument type field */
-
-        ArgumentTypes >>= METHOD_ARG_BIT_WIDTH;
         SubIndex = 0;
     }
 
     return (ArgCount);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtGetResourceBitWidth
  *
  * PARAMETERS:  Buffer              - Where the formatted string is returned
  *              Types               - Bitfield of expected data types
  *
  * RETURN:      Count of return types. Formatted string in Buffer.
  *
  * DESCRIPTION: Format the resource bit widths into a printable string.
  *
  ******************************************************************************/
 
 UINT32
 AcpiUtGetResourceBitWidth (
     char                    *Buffer,
     UINT16                  Types)
 {
     UINT32                  i;
     UINT16                  SubIndex;
     UINT32                  Found;
 
 
     *Buffer = 0;
     SubIndex = 1;
     Found = 0;
 
     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++)
     {
         if (Types & 1)
         {
             strcat (Buffer, &(UtResourceTypeNames[i][SubIndex]));
             SubIndex = 0;
             Found++;
         }
 
         Types >>= 1;
     }
 
     return (Found);
 }
 #endif
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utxferror.c
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utxferror.c	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities/utxferror.c	(revision 249699)
@@ -1,564 +1,613 @@
 /*******************************************************************************
  *
  * Module Name: utxferror - Various error/warning output functions
  *
  ******************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #define __UTXFERROR_C__
 
 #include 
 #include 
 #include 
 
 
 #define _COMPONENT          ACPI_UTILITIES
         ACPI_MODULE_NAME    ("utxferror")
 
 /*
  * This module is used for the in-kernel ACPICA as well as the ACPICA
  * tools/applications.
  *
  * For the iASL compiler case, the output is redirected to stderr so that
  * any of the various ACPI errors and warnings do not appear in the output
  * files, for either the compiler or disassembler portions of the tool.
  */
 #ifdef ACPI_ASL_COMPILER
 #include 
 
 extern FILE                 *AcpiGbl_OutputFile;
 
 #define ACPI_MSG_REDIRECT_BEGIN \
     FILE                    *OutputFile = AcpiGbl_OutputFile; \
     AcpiOsRedirectOutput (stderr);
 
 #define ACPI_MSG_REDIRECT_END \
     AcpiOsRedirectOutput (OutputFile);
 
 #else
 /*
  * non-iASL case - no redirection, nothing to do
  */
 #define ACPI_MSG_REDIRECT_BEGIN
 #define ACPI_MSG_REDIRECT_END
 #endif
 
 /*
  * Common message prefixes
  */
 #define ACPI_MSG_ERROR          "ACPI Error: "
 #define ACPI_MSG_EXCEPTION      "ACPI Exception: "
 #define ACPI_MSG_WARNING        "ACPI Warning: "
 #define ACPI_MSG_INFO           "ACPI: "
 
-#define ACPI_MSG_BIOS_ERROR     "ACPI BIOS Bug: Error: "
-#define ACPI_MSG_BIOS_WARNING   "ACPI BIOS Bug: Warning: "
+#define ACPI_MSG_BIOS_ERROR     "ACPI BIOS Error (bug): "
+#define ACPI_MSG_BIOS_WARNING   "ACPI BIOS Warning (bug): "
 
 /*
  * Common message suffix
  */
 #define ACPI_MSG_SUFFIX \
     AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiError
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print "ACPI Error" message with module/line/version info
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_ERROR);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiError)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiException
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Status              - Status to be formatted
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
  *              and decoded ACPI_STATUS.
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiException (
     const char              *ModuleName,
     UINT32                  LineNumber,
     ACPI_STATUS             Status,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiException)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiWarning
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiWarning (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_WARNING);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiWarning)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiInfo
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print generic "ACPI:" information message. There is no
  *              module/line/version info in order to keep the message simple.
  *
  * TBD: ModuleName and LineNumber args are not needed, should be removed.
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiInfo (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 #ifdef _KERNEL
     /* Temporarily hide too verbose printfs. */
     if (!bootverbose)
 	return;
 #endif
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_INFO);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     AcpiOsPrintf ("\n");
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiInfo)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiBiosError
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
  *              info
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiBiosError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_BIOS_ERROR);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiBiosError)
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiBiosWarning
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Format              - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
  *              info
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiBiosWarning (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_BIOS_WARNING);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 
     ACPI_MSG_REDIRECT_END;
 }
 
 ACPI_EXPORT_SYMBOL (AcpiBiosWarning)
 
 
 /*
  * The remainder of this module contains internal error functions that may
  * be configured out.
  */
 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtPredefinedWarning
  *
  * PARAMETERS:  ModuleName      - Caller's module name (for error output)
  *              LineNumber      - Caller's line number (for error output)
  *              Pathname        - Full pathname to the node
  *              NodeFlags       - From Namespace node for the method/object
  *              Format          - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Warnings for the predefined validation module. Messages are
  *              only emitted the first time a problem with a particular
  *              method/object is detected. This prevents a flood of error
  *              messages for methods that are repeatedly evaluated.
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiUtPredefinedWarning (
     const char              *ModuleName,
     UINT32                  LineNumber,
     char                    *Pathname,
     UINT8                   NodeFlags,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     /*
      * Warning messages for this method/object will be disabled after the
      * first time a validation fails or an object is successfully repaired.
      */
     if (NodeFlags & ANOBJ_EVALUATED)
     {
         return;
     }
 
-    AcpiOsPrintf (ACPI_MSG_WARNING "For %s: ", Pathname);
+    AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtPredefinedInfo
  *
  * PARAMETERS:  ModuleName      - Caller's module name (for error output)
  *              LineNumber      - Caller's line number (for error output)
  *              Pathname        - Full pathname to the node
  *              NodeFlags       - From Namespace node for the method/object
  *              Format          - Printf format string + additional args
  *
  * RETURN:      None
  *
  * DESCRIPTION: Info messages for the predefined validation module. Messages
  *              are only emitted the first time a problem with a particular
  *              method/object is detected. This prevents a flood of
  *              messages for methods that are repeatedly evaluated.
  *
  ******************************************************************************/
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiUtPredefinedInfo (
     const char              *ModuleName,
     UINT32                  LineNumber,
     char                    *Pathname,
     UINT8                   NodeFlags,
     const char              *Format,
     ...)
 {
     va_list                 ArgList;
 
 
     /*
      * Warning messages for this method/object will be disabled after the
      * first time a validation fails or an object is successfully repaired.
      */
     if (NodeFlags & ANOBJ_EVALUATED)
     {
         return;
     }
 
-    AcpiOsPrintf (ACPI_MSG_INFO "For %s: ", Pathname);
+    AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname);
+
+    va_start (ArgList, Format);
+    AcpiOsVprintf (Format, ArgList);
+    ACPI_MSG_SUFFIX;
+    va_end (ArgList);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiUtPredefinedBiosError
+ *
+ * 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: BIOS error message for predefined names. 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
+AcpiUtPredefinedBiosError (
+    const char              *ModuleName,
+    UINT32                  LineNumber,
+    char                    *Pathname,
+    UINT8                   NodeFlags,
+    const char              *Format,
+    ...)
+{
+    va_list                 ArgList;
+
+
+    /*
+     * Warning messages for this method/object will be disabled after the
+     * first time a validation fails or an object is successfully repaired.
+     */
+    if (NodeFlags & ANOBJ_EVALUATED)
+    {
+        return;
+    }
+
+    AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname);
 
     va_start (ArgList, Format);
     AcpiOsVprintf (Format, ArgList);
     ACPI_MSG_SUFFIX;
     va_end (ArgList);
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtNamespaceError
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              InternalName        - Name or path of the namespace node
  *              LookupStatus        - Exception code from NS lookup
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print error message with the full pathname for the NS node.
  *
  ******************************************************************************/
 
 void
 AcpiUtNamespaceError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *InternalName,
     ACPI_STATUS             LookupStatus)
 {
     ACPI_STATUS             Status;
     UINT32                  BadName;
     char                    *Name = NULL;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_ERROR);
 
     if (LookupStatus == AE_BAD_CHARACTER)
     {
         /* There is a non-ascii character in the name */
 
         ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
         AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName);
     }
     else
     {
         /* Convert path to external format */
 
         Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
                     InternalName, NULL, &Name);
 
         /* Print target name */
 
         if (ACPI_SUCCESS (Status))
         {
             AcpiOsPrintf ("[%s]", Name);
         }
         else
         {
             AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
         }
 
         if (Name)
         {
             ACPI_FREE (Name);
         }
     }
 
     AcpiOsPrintf (" Namespace lookup failure, %s",
         AcpiFormatException (LookupStatus));
 
     ACPI_MSG_SUFFIX;
     ACPI_MSG_REDIRECT_END;
 }
 
 
 /*******************************************************************************
  *
  * FUNCTION:    AcpiUtMethodError
  *
  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
  *              LineNumber          - Caller's line number (for error output)
  *              Message             - Error message to use on failure
  *              PrefixNode          - Prefix relative to the path
  *              Path                - Path to the node (optional)
  *              MethodStatus        - Execution status
  *
  * RETURN:      None
  *
  * DESCRIPTION: Print error message with the full pathname for the method.
  *
  ******************************************************************************/
 
 void
 AcpiUtMethodError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Message,
     ACPI_NAMESPACE_NODE     *PrefixNode,
     const char              *Path,
     ACPI_STATUS             MethodStatus)
 {
     ACPI_STATUS             Status;
     ACPI_NAMESPACE_NODE     *Node = PrefixNode;
 
 
     ACPI_MSG_REDIRECT_BEGIN;
     AcpiOsPrintf (ACPI_MSG_ERROR);
 
     if (Path)
     {
         Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
                     &Node);
         if (ACPI_FAILURE (Status))
         {
             AcpiOsPrintf ("[Could not get node by pathname]");
         }
     }
 
     AcpiNsPrintNodePathname (Node, Message);
     AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
 
     ACPI_MSG_SUFFIX;
     ACPI_MSG_REDIRECT_END;
 }
 
 #endif /* ACPI_NO_ERROR_MESSAGES */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/components/utilities
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica/components/utilities:r249197-249698
   Merged /vendor-sys/acpica/dist/source/components/utilities:r249112-249661
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acconfig.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acconfig.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acconfig.h	(revision 249699)
@@ -1,233 +1,233 @@
 /******************************************************************************
  *
  * Name: acconfig.h - Global configuration constants
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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
 
 /*
  * Generate a version of ACPICA that only supports "reduced hardware"
  * platforms (as defined in ACPI 5.0). Set to TRUE to generate a specialized
  * version of ACPICA that ONLY supports the ACPI 5.0 "reduced hardware"
  * model. In other words, no ACPI hardware is supported.
  *
  * If TRUE, this means no support for the following:
  *      PM Event and Control registers
  *      SCI interrupt (and handler)
  *      Fixed Events
  *      General Purpose Events (GPEs)
  *      Global Lock
  *      ACPI PM timer
  *      FACS table (Waking vectors and Global Lock)
  */
 #define ACPI_REDUCED_HARDWARE           FALSE
 
 
 /******************************************************************************
  *
  * Subsystem Constants
  *
  *****************************************************************************/
 
 /* Version of ACPI supported */
 
 #define ACPI_CA_SUPPORT_LEVEL           5
 
 /* 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
 
 /* Maximum sleep allowed via Sleep() operator */
 
 #define ACPI_MAX_SLEEP                  2000    /* 2000 millisec == two seconds */
 
 /* Address Range lists are per-SpaceId (Memory and I/O only) */
 
 #define ACPI_ADDRESS_RANGE_MAX          2
 
 
 /******************************************************************************
  *
  * 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_USER_REGION_BEGIN          0x80
 
 /* Maximum SpaceIds for Operation Regions */
 
 #define ACPI_MAX_ADDRESS_SPACE          255
 #define ACPI_NUM_DEFAULT_SPACES         4
 
 /* 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, GSBus and IPMI bidirectional buffer size */
 
 #define ACPI_SMBUS_BUFFER_SIZE          34
 #define ACPI_GSBUS_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          ACPI_METHOD_NUM_ARGS + 2 /* Max command line arguments */
+#define ACPI_DEBUGGER_MAX_ARGS          ACPI_METHOD_NUM_ARGS + 4 /* Max command line arguments */
 #define ACPI_DB_LINE_BUFFER_SIZE        512
 
 #define ACPI_DEBUGGER_COMMAND_PROMPT    '-'
 #define ACPI_DEBUGGER_EXECUTE_PROMPT    '%'
 
 
 #endif /* _ACCONFIG_H */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/aclocal.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/aclocal.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/aclocal.h	(revision 249699)
@@ -1,1369 +1,1349 @@
 /******************************************************************************
  *
  * Name: aclocal.h - Internal data types used across the ACPI subsystem
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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                 0x81
 
 
 /* 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
 
 
 /* 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      *Parent;        /* Parent node */
     struct acpi_namespace_node      *Child;         /* First child */
     struct acpi_namespace_node      *Peer;          /* First peer */
 
     /*
      * 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_RESERVED                  0x01    /* Available for use */
 #define ANOBJ_TEMPORARY                 0x02    /* Node is create by a method and is temporary */
 #define ANOBJ_METHOD_ARG                0x04    /* Node is a method argument */
 #define ANOBJ_METHOD_LOCAL              0x08    /* Node is a method local */
 #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_REFERENCED             0x80    /* iASL only: Object was referenced */
 
 
 /* Internal ACPI table management - master table list */
 
 typedef struct acpi_table_list
 {
     ACPI_TABLE_DESC                 *Tables;            /* Table descriptor array */
     UINT32                          CurrentTableCount;  /* Tables currently in the array */
     UINT32                          MaxTableCount;      /* Max tables array will hold */
     UINT8                           Flags;
 
 } ACPI_TABLE_LIST;
 
 /* 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;
     ACPI_NAMESPACE_NODE             *ConnectionNode;
     UINT8                           *ResourceBuffer;
     UINT32                          BankValue;
     UINT32                          FieldBitPosition;
     UINT32                          FieldBitLength;
     UINT16                          ResourceLength;
     UINT8                           FieldFlags;
     UINT8                           Attribute;
     UINT8                           FieldType;
     UINT8                           AccessLength;
 
 } 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
 
 #pragma pack(1)
 
 /*
  * 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];
     UINT16                      ArgumentList;
     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,
  * ACPI_PTYPE2_FIX_VAR
  */
 typedef struct acpi_package_info
 {
     UINT8                       Type;
     UINT8                       ObjectType1;
     UINT8                       Count1;
     UINT8                       ObjectType2;
     UINT8                       Count2;
     UINT16                      Reserved;
 
 } ACPI_PACKAGE_INFO;
 
 /* Used for ACPI_PTYPE2_FIXED */
 
 typedef struct acpi_package_info2
 {
     UINT8                       Type;
     UINT8                       Count;
     UINT8                       ObjectType[4];
     UINT8                       Reserved;
 
 } ACPI_PACKAGE_INFO2;
 
 /* Used for ACPI_PTYPE1_OPTION */
 
 typedef struct acpi_package_info3
 {
     UINT8                       Type;
     UINT8                       Count;
     UINT8                       ObjectType[2];
     UINT8                       TailObjectType;
     UINT16                      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;
 
 /* Reset to default packing */
 
 #pragma pack()
 
 
-/* Data block used during object validation */
-
-typedef struct acpi_predefined_data
-{
-    char                        *Pathname;
-    const ACPI_PREDEFINED_INFO  *Predefined;
-    union acpi_operand_object   *ParentPackage;
-    ACPI_NAMESPACE_NODE         *Node;
-    UINT32                      Flags;
-    UINT32                      ReturnBtype;
-    UINT8                       NodeFlags;
-
-} ACPI_PREDEFINED_DATA;
-
-/* Defines for Flags field above */
-
-#define ACPI_OBJECT_REPAIRED    1
-#define ACPI_OBJECT_WRAPPED     2
-
-
 /* Return object auto-repair info */
 
 typedef ACPI_STATUS (*ACPI_OBJECT_CONVERTER) (
     union acpi_operand_object   *OriginalObject,
     union acpi_operand_object   **ConvertedObject);
 
 typedef struct acpi_simple_repair_info
 {
     char                        Name[ACPI_NAME_SIZE];
     UINT32                      UnexpectedBtypes;
     UINT32                      PackageIndex;
     ACPI_OBJECT_CONVERTER       ObjectConverter;
 
 } ACPI_SIMPLE_REPAIR_INFO;
 
 
 /*
  * 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_gpe_handler_info
 {
     ACPI_GPE_HANDLER                Address;        /* Address of handler, if any */
     void                            *Context;       /* Context to be passed to handler */
     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level (saved) */
     UINT8                           OriginalFlags;  /* Original (pre-handler) GPE info */
     BOOLEAN                         OriginallyEnabled; /* True if GPE was originally enabled */
 
 } ACPI_GPE_HANDLER_INFO;
 
 /* Notify info for implicit notify, multiple device objects */
 
 typedef struct acpi_gpe_notify_info
 {
     ACPI_NAMESPACE_NODE             *DeviceNode;    /* Device to be notified */
     struct acpi_gpe_notify_info     *Next;
 
 } ACPI_GPE_NOTIFY_INFO;
 
 /*
  * GPE dispatch info. At any time, the GPE can have at most one type
  * of dispatch - Method, Handler, or Implicit Notify.
  */
 typedef union acpi_gpe_dispatch_info
 {
     ACPI_NAMESPACE_NODE             *MethodNode;    /* Method node for this GPE level */
     ACPI_GPE_HANDLER_INFO           *Handler;       /* Installed GPE handler */
     ACPI_GPE_NOTIFY_INFO            *NotifyList;    /* List of _PRW devices for implicit notifies */
 
 } 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, Handler, or NotifyList */
     struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
     UINT8                           Flags;          /* Misc info about this GPE */
     UINT8                           GpeNumber;      /* This GPE */
     UINT8                           RuntimeCount;   /* References to a run GPE */
 
 } ACPI_GPE_EVENT_INFO;
 
 /* 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 */
     UINT16                          GpeCount;       /* Number of individual GPEs in block */
     UINT8                           BlockBaseNumber;/* Base GPE number for this block */
     BOOLEAN                         Initialized;    /* TRUE if this block is initialized */
 
 } ACPI_GPE_BLOCK_INFO;
 
 /* 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;
     UINT16                          Count;
     ACPI_OWNER_ID                   OwnerId;
     BOOLEAN                         ExecuteByOwnerId;
 
 } 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);
 
 
 /* Global handlers for AML Notifies */
 
 typedef struct acpi_global_notify_handler
 {
     ACPI_NOTIFY_HANDLER             Handler;
     void                            *Context;
 
 } ACPI_GLOBAL_NOTIFY_HANDLER;
 
 /*
  * Notify info - used to pass info to the deferred notify
  * handler/dispatcher.
  */
 typedef struct acpi_notify_info
 {
     ACPI_STATE_COMMON
     UINT8                           HandlerListId;
     ACPI_NAMESPACE_NODE             *Node;
     union acpi_operand_object       *HandlerListHead;
     ACPI_GLOBAL_NOTIFY_HANDLER      *Global;
 
 } 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);
 
 /* Address Range info block */
 
 typedef struct acpi_address_range
 {
     struct acpi_address_range   *Next;
     ACPI_NAMESPACE_NODE         *RegionNode;
     ACPI_PHYSICAL_ADDRESS       StartAddress;
     ACPI_PHYSICAL_ADDRESS       EndAddress;
 
 } ACPI_ADDRESS_RANGE;
 
 
 /*****************************************************************************
  *
  * 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;
 
 /* Structure for Resource Tag information */
 
 typedef struct acpi_tag_info
 {
     UINT32                          BitOffset;
     UINT32                          BitLength;
 
 } ACPI_TAG_INFO;
 
 /* Value associated with the parse object */
 
 typedef union acpi_parse_value
 {
     UINT64                          Integer;        /* Integer constant (Up to 64 bits) */
     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_TAG_INFO                   Tag;            /* Resource descriptor tag info  */
 
 } 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) */
 
 
 /* Flags for DisasmFlags field  above */
 
 #define ACPI_DASM_BUFFER                0x00        /* Buffer is a simple data buffer */
 #define ACPI_DASM_RESOURCE              0x01        /* Buffer is a Resource Descriptor */
 #define ACPI_DASM_STRING                0x02        /* Buffer is a ASCII string */
 #define ACPI_DASM_UNICODE               0x03        /* Buffer is a Unicode string */
 #define ACPI_DASM_PLD_METHOD            0x04        /* Buffer is a _PLD method bit-packed buffer */
 #define ACPI_DASM_EISAID                0x05        /* Integer is an EISAID */
 #define ACPI_DASM_MATCHOP               0x06        /* Parent opcode is a Match() operator */
 #define ACPI_DASM_LNOT_PREFIX           0x07        /* Start of a LNotEqual (etc.) pair of opcodes */
 #define ACPI_DASM_LNOT_SUFFIX           0x08        /* End  of a LNotEqual (etc.) pair of opcodes */
 #define ACPI_DASM_IGNORE                0x09        /* Not used at this time */
 
 /*
  * 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_PREDEF_CHECKED     0x08
 #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_PCIEXP_WAKE_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_VISTA_SP2          0x0A
 #define ACPI_OSI_WIN_7                  0x0B
 #define ACPI_OSI_WIN_8                  0x0C
 
 #define ACPI_ALWAYS_ILLEGAL             0x00
 
 typedef struct acpi_interface_info
 {
     char                        *Name;
     struct acpi_interface_info  *Next;
     UINT8                       Flags;
     UINT8                       Value;
 
 } ACPI_INTERFACE_INFO;
 
 #define ACPI_OSI_INVALID                0x01
 #define ACPI_OSI_DYNAMIC                0x02
 
 typedef struct acpi_port_info
 {
     char                    *Name;
     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_FIXED_DMA            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_GPIO                 0x8C
 #define ACPI_RESOURCE_NAME_SERIAL_BUS           0x8E
 #define ACPI_RESOURCE_NAME_LARGE_MAX            0x8E
 
 
 /*****************************************************************************
  *
  * 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;
     BOOLEAN                     Resolved;
 
 } ACPI_EXTERNAL_LIST;
 
 /* Values for Flags field above */
 
 #define ACPI_IPATH_ALLOCATED    0x01
 
 
 typedef struct acpi_external_file
 {
     char                        *Path;
     struct acpi_external_file   *Next;
 
 } ACPI_EXTERNAL_FILE;
 
 
 /*****************************************************************************
  *
  * Debugger
  *
  ****************************************************************************/
 
 typedef struct acpi_db_method_info
 {
     ACPI_HANDLE                     Method;
     ACPI_HANDLE                     MainThreadGate;
     ACPI_HANDLE                     ThreadCompleteGate;
     ACPI_HANDLE                     InfoGate;
     ACPI_THREAD_ID                  *Threads;
     UINT32                          NumThreads;
     UINT32                          NumCreated;
     UINT32                          NumCompleted;
 
     char                            *Name;
     UINT32                          Flags;
     UINT32                          NumLoops;
     char                            Pathname[128];
     char                            **Args;
     ACPI_OBJECT_TYPE                *Types;
 
     /*
      * 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;
     ACPI_OBJECT_TYPE                ArgTypes[4];
     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
 
 
 /*****************************************************************************
  *
  * Info/help support
  *
  ****************************************************************************/
 
 typedef struct ah_predefined_name
 {
     char            *Name;
     char            *Description;
 #ifndef ACPI_ASL_COMPILER
     char            *Action;
 #endif
 
 } AH_PREDEFINED_NAME;
 
 #endif /* __ACLOCAL_H__ */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acmacros.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acmacros.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acmacros.h	(revision 249699)
@@ -1,456 +1,458 @@
 /******************************************************************************
  *
  * Name: acmacros.h - C macros for the entire subsystem.
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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_CAST8(ptr)                 ACPI_CAST_PTR (UINT8, (ptr))
 #define ACPI_CAST16(ptr)                ACPI_CAST_PTR (UINT16, (ptr))
 #define ACPI_CAST32(ptr)                ACPI_CAST_PTR (UINT32, (ptr))
 #define ACPI_CAST64(ptr)                ACPI_CAST_PTR (UINT64, (ptr))
 #define ACPI_GET8(ptr)                  (*ACPI_CAST8 (ptr))
 #define ACPI_GET16(ptr)                 (*ACPI_CAST16 (ptr))
 #define ACPI_GET32(ptr)                 (*ACPI_CAST32 (ptr))
 #define ACPI_GET64(ptr)                 (*ACPI_CAST64 (ptr))
 #define ACPI_SET8(ptr, val)             (*ACPI_CAST8 (ptr) = (UINT8) (val))
 #define ACPI_SET16(ptr, val)            (*ACPI_CAST16 (ptr) = (UINT16) (val))
 #define ACPI_SET32(ptr, val)            (*ACPI_CAST32 (ptr) = (UINT32) (val))
 #define ACPI_SET64(ptr, val)            (*ACPI_CAST64 (ptr) = (UINT64) (val))
 
 /*
  * 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_UINT64_MAX) << ((UINT32) (position))))
 #define ACPI_MASK_BITS_BELOW(position)      ((ACPI_UINT64_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))
 
 /* Generic bitfield macros and masks */
 
 #define ACPI_GET_BITS(SourcePtr, Position, Mask) \
     ((*SourcePtr >> Position) & Mask)
 
 #define ACPI_SET_BITS(TargetPtr, Position, Mask, Value) \
     (*TargetPtr |= ((Value & Mask) << Position))
 
 #define ACPI_1BIT_MASK      0x00000001
 #define ACPI_2BIT_MASK      0x00000003
 #define ACPI_3BIT_MASK      0x00000007
 #define ACPI_4BIT_MASK      0x0000000F
 #define ACPI_5BIT_MASK      0x0000001F
 #define ACPI_6BIT_MASK      0x0000003F
 #define ACPI_7BIT_MASK      0x0000007F
 #define ACPI_8BIT_MASK      0x000000FF
 #define ACPI_16BIT_MASK     0x0000FFFF
 #define ACPI_24BIT_MASK     0x00FFFFFF
 
 /* Macros to extract flag bits from position zero */
 
 #define ACPI_GET_1BIT_FLAG(Value)                   ((Value) & ACPI_1BIT_MASK)
 #define ACPI_GET_2BIT_FLAG(Value)                   ((Value) & ACPI_2BIT_MASK)
 #define ACPI_GET_3BIT_FLAG(Value)                   ((Value) & ACPI_3BIT_MASK)
 #define ACPI_GET_4BIT_FLAG(Value)                   ((Value) & ACPI_4BIT_MASK)
 
 /* Macros to extract flag bits from position one and above */
 
 #define ACPI_EXTRACT_1BIT_FLAG(Field, Position)     (ACPI_GET_1BIT_FLAG ((Field) >> Position))
 #define ACPI_EXTRACT_2BIT_FLAG(Field, Position)     (ACPI_GET_2BIT_FLAG ((Field) >> Position))
 #define ACPI_EXTRACT_3BIT_FLAG(Field, Position)     (ACPI_GET_3BIT_FLAG ((Field) >> Position))
 #define ACPI_EXTRACT_4BIT_FLAG(Field, Position)     (ACPI_GET_4BIT_FLAG ((Field) >> Position))
 
 /* ACPI Pathname helpers */
 
 #define ACPI_IS_ROOT_PREFIX(c)      ((c) == (UINT8) 0x5C) /* Backslash */
 #define ACPI_IS_PARENT_PREFIX(c)    ((c) == (UINT8) 0x5E) /* Carat */
 #define ACPI_IS_PATH_SEPARATOR(c)   ((c) == (UINT8) 0x2E) /* Period (dot) */
 
 /*
  * An object of type ACPI_NAMESPACE_NODE can appear in some contexts
  * where a pointer to an object of type ACPI_OPERAND_OBJECT can also
  * appear. This macro is used to distinguish them.
  *
  * The "DescriptorType" field is the second field in both structures.
  */
 #define ACPI_GET_DESCRIPTOR_PTR(d)      (((ACPI_DESCRIPTOR *)(void *)(d))->Common.CommonPointer)
 #define ACPI_SET_DESCRIPTOR_PTR(d, p)   (((ACPI_DESCRIPTOR *)(void *)(d))->Common.CommonPointer = (p))
 #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)      AcpiUtNamespaceError (AE_INFO, s, e);
-#define ACPI_ERROR_METHOD(s, n, p, e)   AcpiUtMethodError (AE_INFO, s, n, p, e);
-#define ACPI_WARN_PREDEFINED(plist)     AcpiUtPredefinedWarning plist
-#define ACPI_INFO_PREDEFINED(plist)     AcpiUtPredefinedInfo plist
+#define ACPI_ERROR_NAMESPACE(s, e)          AcpiUtNamespaceError (AE_INFO, s, e);
+#define ACPI_ERROR_METHOD(s, n, p, e)       AcpiUtMethodError (AE_INFO, s, n, p, e);
+#define ACPI_WARN_PREDEFINED(plist)         AcpiUtPredefinedWarning plist
+#define ACPI_INFO_PREDEFINED(plist)         AcpiUtPredefinedInfo plist
+#define ACPI_BIOS_ERROR_PREDEFINED(plist)   AcpiUtPredefinedBiosError 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)
+#define ACPI_BIOS_ERROR_PREDEFINED(plist)
 
 #endif /* ACPI_NO_ERROR_MESSAGES */
 
 #if (!ACPI_REDUCED_HARDWARE)
 #define ACPI_HW_OPTIONAL_FUNCTION(addr)     addr
 #else
 #define ACPI_HW_OPTIONAL_FUNCTION(addr)     NULL
 #endif
 
 
 /*
  * Some code only gets executed when the debugger is built in.
  * Note that this is entirely independent of whether the
  * 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 */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acnamesp.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acnamesp.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acnamesp.h	(revision 249699)
@@ -1,515 +1,530 @@
 /******************************************************************************
  *
  * Name: acnamesp.h - Namespace subcomponent prototypes and defines
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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);
 
 
 /*
  * nsconvert - Dynamic object conversion routines
  */
 ACPI_STATUS
 AcpiNsConvertToInteger (
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 ACPI_STATUS
 AcpiNsConvertToString (
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 ACPI_STATUS
 AcpiNsConvertToBuffer (
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 ACPI_STATUS
 AcpiNsConvertToUnicode (
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 ACPI_STATUS
 AcpiNsConvertToResource (
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 
 /*
  * 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
+ * nsarguments - Argument count/type checking for predefined/reserved names
  */
-ACPI_STATUS
-AcpiNsCheckPredefinedNames (
-    ACPI_NAMESPACE_NODE     *Node,
-    UINT32                  UserParamCount,
-    ACPI_STATUS             ReturnStatus,
-    ACPI_OPERAND_OBJECT     **ReturnObject);
-
 void
-AcpiNsCheckParameterCount (
+AcpiNsCheckArgumentCount (
     char                        *Pathname,
     ACPI_NAMESPACE_NODE         *Node,
     UINT32                      UserParamCount,
     const ACPI_PREDEFINED_INFO  *Info);
 
+void
+AcpiNsCheckAcpiCompliance (
+    char                        *Pathname,
+    ACPI_NAMESPACE_NODE         *Node,
+    const ACPI_PREDEFINED_INFO  *Predefined);
+
+void
+AcpiNsCheckArgumentTypes (
+    ACPI_EVALUATE_INFO          *Info);
+
+
+/*
+ * nspredef - Return value checking for predefined/reserved names
+ */
 ACPI_STATUS
+AcpiNsCheckReturnValue (
+    ACPI_NAMESPACE_NODE         *Node,
+    ACPI_EVALUATE_INFO          *Info,
+    UINT32                      UserParamCount,
+    ACPI_STATUS                 ReturnStatus,
+    ACPI_OPERAND_OBJECT         **ReturnObject);
+
+ACPI_STATUS
 AcpiNsCheckObjectType (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     ACPI_OPERAND_OBJECT         **ReturnObjectPtr,
     UINT32                      ExpectedBtypes,
     UINT32                      PackageIndex);
 
 
 /*
  * nsprepkg - Validation of predefined name packages
  */
 ACPI_STATUS
 AcpiNsCheckPackage (
-    ACPI_PREDEFINED_DATA        *Data,
+    ACPI_EVALUATE_INFO          *Info,
     ACPI_OPERAND_OBJECT         **ReturnObjectPtr);
 
 
 /*
  * 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
 AcpiNsSimpleRepair (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT32                  ExpectedBtypes,
     UINT32                  PackageIndex,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 ACPI_STATUS
 AcpiNsWrapWithPackage (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ObjDescPtr);
 
 ACPI_STATUS
 AcpiNsRepairNullElement (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT32                  ExpectedBtypes,
     UINT32                  PackageIndex,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 void
 AcpiNsRemoveNullElements (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     UINT8                   PackageType,
     ACPI_OPERAND_OBJECT     *ObjDesc);
 
 
 /*
  * nsrepair2 - Return object repair for specific
  * predefined methods/objects
  */
 ACPI_STATUS
 AcpiNsComplexRepairs (
-    ACPI_PREDEFINED_DATA    *Data,
+    ACPI_EVALUATE_INFO      *Info,
     ACPI_NAMESPACE_NODE     *Node,
     ACPI_STATUS             ValidateStatus,
     ACPI_OPERAND_OBJECT     **ReturnObjectPtr);
 
 
 /*
  * 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
  */
 ACPI_OBJECT_TYPE
 AcpiNsGetType (
     ACPI_NAMESPACE_NODE     *Node);
 
 UINT32
 AcpiNsLocal (
     ACPI_OBJECT_TYPE        Type);
 
 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);
 
 #endif /* __ACNAMESP_H__ */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acoutput.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acoutput.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acoutput.h	(revision 249699)
@@ -1,473 +1,467 @@
 /******************************************************************************
  *
  * Name: acoutput.h -- debug output
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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 DT_COMPILER                 0x00010000
 #define ASL_PREPROCESSOR            0x00020000
 
 #define ACPI_ALL_COMPONENTS         0x0001FFFF
 #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)
 /*
  * The module name is used primarily for error and debug messages.
  * The __FILE__ macro is not very useful for this, because it
  * usually includes the entire pathname to the module making the
  * debug output difficult to read.
  */
 #define ACPI_MODULE_NAME(Name)          static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name;
 #else
 /*
  * For the no-debug and no-error-msg cases, we must at least define
  * a null module name.
  */
 #define ACPI_MODULE_NAME(Name)
 #define _AcpiModuleName ""
 #endif
 
 /*
  * 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
 #define ACPI_BIOS_WARNING(plist)        AcpiBiosWarning plist
 #define ACPI_BIOS_ERROR(plist)          AcpiBiosError plist
 #define ACPI_DEBUG_OBJECT(obj,l,i)      AcpiExDoDebugObject(obj,l,i)
 
 #else
 
 /* No error messages */
 
 #define ACPI_INFO(plist)
 #define ACPI_WARNING(plist)
 #define ACPI_EXCEPTION(plist)
 #define ACPI_ERROR(plist)
 #define ACPI_BIOS_WARNING(plist)
 #define ACPI_BIOS_ERROR(plist)
 #define ACPI_DEBUG_OBJECT(obj,l,i)
 
 #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
 
 /* Check if debug output is currently dynamically enabled */
 
 #define ACPI_IS_DEBUG_ENABLED(Level, Component) \
     ((Level & AcpiDbgLevel) && (Component & AcpiDbgLayer))
 
 /*
  * 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
  *
  * November 2012: Moved the runtime check for whether to actually emit the
  * debug message outside of the print function itself. This improves overall
  * performance at a relatively small code cost. Implementation involves the
  * use of variadic macros supported by C99.
  *
  * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from
  * complaining about these constructs. On other compilers the do...while
  * adds some extra code, so this feature is optional.
  */
 #ifdef ACPI_USE_DO_WHILE_0
 #define ACPI_DO_WHILE0(a)               do a while(0)
 #else
 #define ACPI_DO_WHILE0(a)               a
 #endif
 
 /* DEBUG_PRINT functions */
 
 #define ACPI_DEBUG_PRINT(plist)         ACPI_ACTUAL_DEBUG plist
 #define ACPI_DEBUG_PRINT_RAW(plist)     ACPI_ACTUAL_DEBUG_RAW plist
 
 /* Helper macros for DEBUG_PRINT */
 
 #define ACPI_DO_DEBUG_PRINT(Function, Level, Line, Filename, Modulename, Component, ...) \
     ACPI_DO_WHILE0 ({ \
         if (ACPI_IS_DEBUG_ENABLED (Level, Component)) \
         { \
             Function (Level, Line, Filename, Modulename, Component, __VA_ARGS__); \
         } \
     })
 
 #define ACPI_ACTUAL_DEBUG(Level, Line, Filename, Modulename, Component, ...) \
     ACPI_DO_DEBUG_PRINT (AcpiDebugPrint, Level, Line, \
         Filename, Modulename, Component, __VA_ARGS__)
 
 #define ACPI_ACTUAL_DEBUG_RAW(Level, Line, Filename, Modulename, Component, ...) \
     ACPI_DO_DEBUG_PRINT (AcpiDebugPrintRaw, Level, Line, \
         Filename, Modulename, Component, __VA_ARGS__)
 
 
 /*
  * Function entry tracing
  *
  * The name of the function is emitted as a local variable that is
  * intended to be used by both the entry trace and the exit trace.
  */
 
 /* Helper macro */
 
 #define ACPI_TRACE_ENTRY(Name, Function, Type, Param) \
     ACPI_FUNCTION_NAME (Name) \
     Function (ACPI_DEBUG_PARAMETERS, (Type) (Param))
 
 /* The actual entry trace macros */
 
 #define ACPI_FUNCTION_TRACE(Name) \
     ACPI_FUNCTION_NAME(Name) \
     AcpiUtTrace (ACPI_DEBUG_PARAMETERS)
 
 #define ACPI_FUNCTION_TRACE_PTR(Name, Pointer) \
     ACPI_TRACE_ENTRY (Name, AcpiUtTracePtr, void *, Pointer)
 
 #define ACPI_FUNCTION_TRACE_U32(Name, Value) \
     ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, UINT32, Value)
 
 #define ACPI_FUNCTION_TRACE_STR(Name, String) \
     ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, char *, String)
 
 #define ACPI_FUNCTION_ENTRY() \
     AcpiUtTrackStackPtr()
 
 
 /*
  * Function exit tracing
  *
  * These macros include a return statement. This is usually considered
  * bad form, but having a separate exit macro before the actual return
  * 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.
  *
  * 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.)
  */
 
 /* Exit trace helper macro */
 
 #ifndef ACPI_SIMPLE_RETURN_MACROS
 
 #define ACPI_TRACE_EXIT(Function, Type, Param) \
     ACPI_DO_WHILE0 ({ \
         register Type _Param = (Type) (Param); \
         Function (ACPI_DEBUG_PARAMETERS, _Param); \
         return (_Param); \
     })
 
 #else /* Use original less-safe macros */
 
 #define ACPI_TRACE_EXIT(Function, Type, Param) \
     ACPI_DO_WHILE0 ({ \
         Function (ACPI_DEBUG_PARAMETERS, (Type) (Param)); \
         return (Param); \
     })
 
 #endif /* ACPI_SIMPLE_RETURN_MACROS */
 
 /* The actual exit macros */
 
 #define return_VOID \
     ACPI_DO_WHILE0 ({ \
         AcpiUtExit (ACPI_DEBUG_PARAMETERS); \
         return; \
     })
 
 #define return_ACPI_STATUS(Status) \
     ACPI_TRACE_EXIT (AcpiUtStatusExit, ACPI_STATUS, Status)
 
 #define return_PTR(Pointer) \
     ACPI_TRACE_EXIT (AcpiUtPtrExit, void *, Pointer)
 
 #define return_VALUE(Value) \
     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT64, Value)
 
 #define return_UINT32(Value) \
     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT32, Value)
 
 #define return_UINT8(Value) \
     ACPI_TRACE_EXIT (AcpiUtValueExit, UINT8, Value)
 
 /* 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)          AcpiUtDebugDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
 
 #else /* ACPI_DEBUG_OUTPUT */
 /*
  * 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)
 #define ACPI_DEBUG_EXEC(a)
 #define ACPI_DEBUG_ONLY_MEMBERS(a)
+#define ACPI_FUNCTION_NAME(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 ACPI_IS_DEBUG_ENABLED(Level, Component) 0
 
 /* Return macros must have a return statement at the minimum */
 
 #define return_VOID                     return
 #define return_ACPI_STATUS(s)           return(s)
 #define return_PTR(s)                   return(s)
 #define return_VALUE(s)                 return(s)
 #define return_UINT8(s)                 return(s)
 #define return_UINT32(s)                return(s)
 
 #endif /* ACPI_DEBUG_OUTPUT */
 
 
 #endif /* __ACOUTPUT_H__ */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpixf.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpixf.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpixf.h	(revision 249699)
@@ -1,822 +1,822 @@
 /******************************************************************************
  *
  * Name: acpixf.h - External interfaces to the ACPI subsystem
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 
 #ifndef __ACXFACE_H__
 #define __ACXFACE_H__
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20130328
+#define ACPI_CA_VERSION                 0x20130418
 
 #include 
 #include 
 #include 
 #include 
 
 /*
  * Globals that are publically available
  */
 extern UINT32               AcpiCurrentGpeCount;
 extern ACPI_TABLE_FADT      AcpiGbl_FADT;
 extern BOOLEAN              AcpiGbl_SystemAwakeAndRunning;
 extern BOOLEAN              AcpiGbl_ReducedHardware;        /* ACPI 5.0 */
 
 /* 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_UseDefaultRegisterWidths;
 extern ACPI_NAME            AcpiGbl_TraceMethodName;
 extern UINT32               AcpiGbl_TraceFlags;
 extern UINT8                AcpiGbl_EnableAmlDebugObject;
 extern UINT8                AcpiGbl_CopyDsdtLocally;
 extern UINT8                AcpiGbl_TruncateIoAddresses;
 extern UINT8                AcpiGbl_DisableAutoRepair;
 
 
 /*
  * Hardware-reduced prototypes. All interfaces that use these macros will
  * be configured out of the ACPICA build if the ACPI_REDUCED_HARDWARE flag
  * is set to TRUE.
  */
 #if (!ACPI_REDUCED_HARDWARE)
 #define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \
     Prototype;
 
 #define ACPI_HW_DEPENDENT_RETURN_OK(Prototype) \
     Prototype;
 
 #define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \
     Prototype;
 
 #else
 #define ACPI_HW_DEPENDENT_RETURN_STATUS(Prototype) \
     static ACPI_INLINE Prototype {return(AE_NOT_CONFIGURED);}
 
 #define ACPI_HW_DEPENDENT_RETURN_OK(Prototype) \
     static ACPI_INLINE Prototype {return(AE_OK);}
 
 #define ACPI_HW_DEPENDENT_RETURN_VOID(Prototype) \
     static ACPI_INLINE Prototype {}
 
 #endif /* !ACPI_REDUCED_HARDWARE */
 
 
 /*
  * Initialization
  */
 ACPI_STATUS
 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);
 
 
 /*
  * Miscellaneous global interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiEnable (
     void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiDisable (
     void))
 
 ACPI_STATUS
 AcpiSubsystemStatus (
     void);
 
 ACPI_STATUS
 AcpiGetSystemInfo (
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiGetStatistics (
     ACPI_STATISTICS         *Stats);
 
 const char *
 AcpiFormatException (
     ACPI_STATUS             Exception);
 
 ACPI_STATUS
 AcpiPurgeCachedObjects (
     void);
 
 ACPI_STATUS
 AcpiInstallInterface (
     ACPI_STRING             InterfaceName);
 
 ACPI_STATUS
 AcpiRemoveInterface (
     ACPI_STRING             InterfaceName);
 
 UINT32
 AcpiCheckAddressRange (
     ACPI_ADR_SPACE_TYPE     SpaceId,
     ACPI_PHYSICAL_ADDRESS   Address,
     ACPI_SIZE               Length,
     BOOLEAN                 Warn);
 
 ACPI_STATUS
 AcpiDecodePldBuffer (
     UINT8                   *InBuffer,
     ACPI_SIZE               Length,
     ACPI_PLD_INFO           **ReturnBuffer);
 
 /*
  * ACPI Memory management
  */
 void *
 AcpiAllocate (
     UINT32                  Size);
 
 void *
 AcpiCallocate (
     UINT32                  Size);
 
 void
 AcpiFree (
     void                    *Address);
 
 
 /*
  * ACPI table load/unload interfaces
  */
 ACPI_STATUS
 AcpiLoadTable (
     ACPI_TABLE_HEADER       *Table);
 
 ACPI_STATUS
 AcpiUnloadParentTable (
     ACPI_HANDLE             Object);
 
 ACPI_STATUS
 AcpiLoadTables (
     void);
 
 
 /*
  * ACPI table manipulation interfaces
  */
 ACPI_STATUS
 AcpiReallocateRootTable (
     void);
 
 ACPI_STATUS
 AcpiFindRootPointer (
     ACPI_SIZE               *RsdpAddress);
 
 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             Object,
     UINT32                  NameType,
     ACPI_BUFFER             *RetPathPtr);
 
 ACPI_STATUS
 AcpiGetHandle (
     ACPI_HANDLE             Parent,
     ACPI_STRING             Pathname,
     ACPI_HANDLE             *RetHandle);
 
 ACPI_STATUS
 AcpiAttachData (
     ACPI_HANDLE             Object,
     ACPI_OBJECT_HANDLER     Handler,
     void                    *Data);
 
 ACPI_STATUS
 AcpiDetachData (
     ACPI_HANDLE             Object,
     ACPI_OBJECT_HANDLER     Handler);
 
 ACPI_STATUS
 AcpiGetData (
     ACPI_HANDLE             Object,
     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             Object,
     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_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiInstallGlobalEventHandler (
     ACPI_GBL_EVENT_HANDLER  Handler,
     void                    *Context))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiInstallFixedEventHandler (
     UINT32                  AcpiEvent,
     ACPI_EVENT_HANDLER      Handler,
     void                    *Context))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiRemoveFixedEventHandler (
     UINT32                  AcpiEvent,
     ACPI_EVENT_HANDLER      Handler))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiInstallGpeHandler (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber,
     UINT32                  Type,
     ACPI_GPE_HANDLER        Address,
     void                    *Context))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiRemoveGpeHandler (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber,
     ACPI_GPE_HANDLER        Address))
 
 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
 AcpiInstallExceptionHandler (
     ACPI_EXCEPTION_HANDLER  Handler);
 
 ACPI_STATUS
 AcpiInstallInterfaceHandler (
     ACPI_INTERFACE_HANDLER  Handler);
 
 
 /*
  * Global Lock interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiAcquireGlobalLock (
     UINT16                  Timeout,
     UINT32                  *Handle))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiReleaseGlobalLock (
     UINT32                  Handle))
 
 
 /*
  * Interfaces to AML mutex objects
  */
 ACPI_STATUS
 AcpiAcquireMutex (
     ACPI_HANDLE             Handle,
     ACPI_STRING             Pathname,
     UINT16                  Timeout);
 
 ACPI_STATUS
 AcpiReleaseMutex (
     ACPI_HANDLE             Handle,
     ACPI_STRING             Pathname);
 
 
 /*
  * Fixed Event interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiEnableEvent (
     UINT32                  Event,
     UINT32                  Flags))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiDisableEvent (
     UINT32                  Event,
     UINT32                  Flags))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiClearEvent (
     UINT32                  Event))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetEventStatus (
     UINT32                  Event,
     ACPI_EVENT_STATUS       *EventStatus))
 
 
 /*
  * General Purpose Event (GPE) Interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiUpdateAllGpes (
     void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiEnableGpe (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiDisableGpe (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiClearGpe (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiSetGpe (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber,
     UINT8                   Action))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiFinishGpe (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiSetupGpeForWake (
     ACPI_HANDLE             ParentDevice,
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiSetGpeWakeMask (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber,
     UINT8                   Action))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetGpeStatus (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber,
     ACPI_EVENT_STATUS       *EventStatus))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiDisableAllGpes (
     void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiEnableAllRuntimeGpes (
     void))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetGpeDevice (
     UINT32                  GpeIndex,
     ACPI_HANDLE             *GpeDevice))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiInstallGpeBlock (
     ACPI_HANDLE             GpeDevice,
     ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
     UINT32                  RegisterCount,
     UINT32                  InterruptNumber))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 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             Device,
     char                    *Name,
     ACPI_VENDOR_UUID        *Uuid,
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiGetCurrentResources (
     ACPI_HANDLE             Device,
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiGetPossibleResources (
     ACPI_HANDLE             Device,
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiGetEventResources (
     ACPI_HANDLE             DeviceHandle,
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiWalkResourceBuffer (
     ACPI_BUFFER                 *Buffer,
     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
     void                        *Context);
 
 ACPI_STATUS
 AcpiWalkResources (
     ACPI_HANDLE                 Device,
     char                        *Name,
     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
     void                        *Context);
 
 ACPI_STATUS
 AcpiSetCurrentResources (
     ACPI_HANDLE             Device,
     ACPI_BUFFER             *InBuffer);
 
 ACPI_STATUS
 AcpiGetIrqRoutingTable (
     ACPI_HANDLE             Device,
     ACPI_BUFFER             *RetBuffer);
 
 ACPI_STATUS
 AcpiResourceToAddress64 (
     ACPI_RESOURCE           *Resource,
     ACPI_RESOURCE_ADDRESS64 *Out);
 
 ACPI_STATUS
 AcpiBufferToResource (
     UINT8                   *AmlBuffer,
     UINT16                  AmlBufferLength,
     ACPI_RESOURCE           **ResourcePtr);
 
 
 /*
  * 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_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiReadBitRegister (
     UINT32                  RegisterId,
     UINT32                  *ReturnValue))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiWriteBitRegister (
     UINT32                  RegisterId,
     UINT32                  Value))
 
 
 /*
  * Sleep/Wake interfaces
  */
 ACPI_STATUS
 AcpiGetSleepTypeData (
     UINT8                   SleepState,
     UINT8                   *Slp_TypA,
     UINT8                   *Slp_TypB);
 
 ACPI_STATUS
 AcpiEnterSleepStatePrep (
     UINT8                   SleepState);
 
 ACPI_STATUS
 AcpiEnterSleepState (
     UINT8                   SleepState);
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiEnterSleepStateS4bios (
     void))
 
 ACPI_STATUS
 AcpiLeaveSleepStatePrep (
     UINT8                   SleepState);
 
 ACPI_STATUS
 AcpiLeaveSleepState (
     UINT8                   SleepState);
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiSetFirmwareWakingVector (
     UINT32                  PhysicalAddress))
 
 #if ACPI_MACHINE_WIDTH == 64
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiSetFirmwareWakingVector64 (
     UINT64                  PhysicalAddress))
 #endif
 
 
 /*
  * ACPI Timer interfaces
  */
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetTimerResolution (
     UINT32                  *Resolution))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetTimer (
     UINT32                  *Ticks))
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
 AcpiGetTimerDuration (
     UINT32                  StartTicks,
     UINT32                  EndTicks,
     UINT32                  *TimeElapsed))
 
 
 /*
  * Error/Warning output
  */
 void ACPI_INTERNAL_VAR_XFACE
 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);
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiBiosError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Format,
     ...) ACPI_PRINTF_LIKE(3);
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiBiosWarning (
     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__ */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpredef.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpredef.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acpredef.h	(revision 249699)
@@ -1,1064 +1,1064 @@
 /******************************************************************************
  *
  * Name: acpredef - Information table for ACPI predefined methods and objects
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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. Zero-length package is allowed:
  *      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. Zero-length
  *      parent package is allowed:
  *      object type
  *      count
  *      object type
  *      count
  *      (Used for _ALR,_MLS,_PSS,_TRT,_TSS)
  *
  * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element.
  *      Zero-length parent package is allowed:
  *      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. Zero-length
  *      parent package is allowed.
  *      (Used for _PRT)
  *
  * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length.
  *      Zero-length parent package is allowed:
  *      (Used for _HPX)
  *
  * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length
  *      (Used for _ART, _FPS)
  *
  * ACPI_PTYPE2_FIX_VAR: Each subpackage consists of some fixed-length elements
  *      followed by an optional element. Zero-length parent package is allowed.
  *      object type
  *      count
  *      object type
  *      count = 0 (optional)
  *      (Used for _DLM)
  *
  *****************************************************************************/
 
 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,
     ACPI_PTYPE2_FIX_VAR     = 10
 };
 
 
 /* Support macros for users of the predefined info table */
 
 #define METHOD_PREDEF_ARGS_MAX          4
 #define METHOD_ARG_BIT_WIDTH            3
 #define METHOD_ARG_MASK                 0x0007
 #define ARG_COUNT_IS_MINIMUM            0x8000
 #define METHOD_MAX_ARG_TYPE             ACPI_TYPE_PACKAGE
 
-#define METHOD_GET_COUNT(ArgList)       (ArgList & METHOD_ARG_MASK)
-#define METHOD_GET_NEXT_ARG(ArgList)    (ArgList >> METHOD_ARG_BIT_WIDTH)
+#define METHOD_GET_ARG_COUNT(ArgList)   ((ArgList) & METHOD_ARG_MASK)
+#define METHOD_GET_NEXT_TYPE(ArgList)   (((ArgList) >>= METHOD_ARG_BIT_WIDTH) & METHOD_ARG_MASK)
 
 /* Macros used to build the predefined info table */
 
 #define METHOD_0ARGS                    0
 #define METHOD_1ARGS(a1)                (1 | (a1 << 3))
 #define METHOD_2ARGS(a1,a2)             (2 | (a1 << 3) | (a2 << 6))
 #define METHOD_3ARGS(a1,a2,a3)          (3 | (a1 << 3) | (a2 << 6) | (a3 << 9))
 #define METHOD_4ARGS(a1,a2,a3,a4)       (4 | (a1 << 3) | (a2 << 6) | (a3 << 9) | (a4 << 12))
 
 #define METHOD_RETURNS(type)            (type)
 #define METHOD_NO_RETURN_VALUE          0
 
 #define PACKAGE_INFO(a,b,c,d,e,f)       {{{(a),(b),(c),(d)}, ((((UINT16)(f)) << 8) | (e)), 0}}
 
 
 /* Support macros for the resource descriptor info table */
 
 #define WIDTH_1                         0x0001
 #define WIDTH_2                         0x0002
 #define WIDTH_3                         0x0004
 #define WIDTH_8                         0x0008
 #define WIDTH_16                        0x0010
 #define WIDTH_32                        0x0020
 #define WIDTH_64                        0x0040
 #define VARIABLE_DATA                   0x0080
 #define NUM_RESOURCE_WIDTHS             8
 
 #define WIDTH_ADDRESS                   WIDTH_16 | WIDTH_32 | WIDTH_64
 
 
 #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
  *              _Wxx wake events
  *
  *      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
  *
  * The main entries in the table each contain the following items:
  *
  * Name                 - The ACPI reserved name
  * ArgumentList         - Contains (in 16 bits), the number of required
  *                        arguments to the method (3 bits), and a 3-bit type
  *                        field for each argument (up to 4 arguments). The
  *                        METHOD_?ARGS macros generate the correct packed data.
  * 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.
  *
  * Note2: Table is used by the kernel-resident subsystem, the iASL compiler,
  * and the AcpiHelp utility.
  *
  * TBD: _PRT - currently ignore reversed entries. Attempt to fix in nsrepair.
  * Possibly fixing package elements like _BIF, etc.
  *
  *****************************************************************************/
 
 const ACPI_PREDEFINED_INFO          AcpiGbl_PredefinedMethods[] =
 {
     {{"_AC0",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC1",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC2",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC3",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC4",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC5",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC6",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC7",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC8",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AC9",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ADR",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_AEI",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_AL0",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL1",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL2",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL3",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL4",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL5",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL6",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL7",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL8",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_AL9",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_ALC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ALI",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ALP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ALR",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 2 (Ints) */
                     PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0,0,0),
 
     {{"_ALT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ART",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */
                     PACKAGE_INFO (ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER, 11,0),
 
     {{"_BBN",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BCL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0,0,0),
 
     {{"_BCM",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_BCT",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BDN",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BFS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_BIF",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (9 Int),(4 Str) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING, 4,0),
 
     {{"_BIX",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int),(4 Str) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING, 4,0),
 
     {{"_BLT",   METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_BMA",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BMC",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_BMD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (5 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0,0,0),
 
     {{"_BMS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BQC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BST",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0,0,0),
 
     {{"_BTM",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_BTP",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_CBA",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */
 
     {{"_CDM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_CID",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Strs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0,0,0),
 
     {{"_CLS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0,0,0),
 
     {{"_CPC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Bufs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0,0,0,0),
 
     {{"_CRS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_CRT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_CSD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(n), n-1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0,0,0),
 
     {{"_CST",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */
                     PACKAGE_INFO (ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER, 3,0),
 
     {{"_CWS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_DCK",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_DCS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_DDC",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER)}},
 
     {{"_DDN",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_STRING)}},
 
     {{"_DEP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_DGS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_DIS",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_DLM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (1 Ref, 0/1 Optional Buf/Ref) */
                     PACKAGE_INFO (ACPI_PTYPE2_FIX_VAR, ACPI_RTYPE_REFERENCE, 1, ACPI_RTYPE_REFERENCE | ACPI_RTYPE_BUFFER, 0,0),
 
     {{"_DMA",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_DOD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0,0,0),
 
     {{"_DOS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_DSM",   METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_PACKAGE),
                 METHOD_RETURNS (ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */
 
     {{"_DSS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_DSW",   METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_DTI",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EC_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_EDL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs)*/
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_EJ0",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EJ1",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EJ2",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EJ3",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EJ4",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_EJD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_STRING)}},
 
     {{"_ERR",   METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_STRING, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* Internal use only, used by ACPICA test suites */
 
     {{"_EVT",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_FDE",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_FDI",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0,0,0),
 
     {{"_FDM",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_FIF",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0,0,0),
 
     {{"_FIX",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0,0,0),
 
     {{"_FPS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */
                     PACKAGE_INFO (ACPI_PTYPE2_REV_FIXED,ACPI_RTYPE_INTEGER, 5, 0,0,0),
 
     {{"_FSL",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_FST",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3,0,0,0),
 
     {{"_GAI",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GCP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GHL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GLK",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GPD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GPE",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* _GPE method, not _GPE scope */
 
     {{"_GRT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_GSB",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_GTF",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_GTM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_GTS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_GWS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_HID",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING)}},
 
     {{"_HOT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_HPP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */
                     PACKAGE_INFO (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",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (var Ints) */
                     PACKAGE_INFO (ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0,0,0),
 
     {{"_HRV",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_IFT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See IPMI spec */
 
     {{"_INI",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_IRC",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_LCK",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_LID",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_MAT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_MBM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (8 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8,0,0,0),
 
     {{"_MLS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (1 Str/1 Buf) */
                     PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_STRING, 1, ACPI_RTYPE_BUFFER, 1,0),
 
     {{"_MSG",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_MSM",   METHOD_4ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_NTT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_OFF",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_ON_",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_OS_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_STRING)}},
 
     {{"_OSC",   METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_BUFFER),
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_OST",   METHOD_3ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_BUFFER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PAI",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PCL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PCT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Buf) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0,0,0),
 
     {{"_PDC",   METHOD_1ARGS (ACPI_TYPE_BUFFER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PDL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PIC",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PIF",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int),(3 Str) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING, 3,0),
 
     {{"_PLD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Bufs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0,0,0),
 
     {{"_PMC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (11 Int),(3 Str) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING, 3,0),
 
     {{"_PMD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PMM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PPC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PPE",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See dig64 spec */
 
     {{"_PR0",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PR1",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PR2",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PR3",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PRE",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PRL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PRS",   METHOD_0ARGS,
                 METHOD_RETURNS (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",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */
                     PACKAGE_INFO (ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER, ACPI_RTYPE_INTEGER,
                                   ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, ACPI_RTYPE_INTEGER),
 
     {{"_PRW",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE,
                                   ACPI_RTYPE_INTEGER, ACPI_RTYPE_REFERENCE, 0),
 
     {{"_PS0",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PS1",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PS2",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PS3",   METHOD_0ARGS,
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PSC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PSD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (5 Int) with count */
                     PACKAGE_INFO (ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0,0,0),
 
     {{"_PSE",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PSL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_PSR",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PSS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (6 Int) */
                     PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0,0,0),
 
     {{"_PSV",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PSW",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PTC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Buf) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0,0,0),
 
     {{"_PTP",   METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_PTS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_PUR",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0,0,0),
 
     {{"_PXM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_REG",   METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_REV",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_RMV",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_ROM",   METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_RTV",   METHOD_0ARGS,
                 METHOD_RETURNS (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_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S1_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S2_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S3_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S4_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S5_",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0,0,0),
 
     {{"_S1D",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S2D",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S3D",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S4D",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S0W",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S1W",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S2W",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S3W",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_S4W",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SBS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SCP",   METHOD_1ARGS (ACPI_TYPE_INTEGER) | ARG_COUNT_IS_MINIMUM,
                 METHOD_NO_RETURN_VALUE}},   /* Acpi 1.0 allowed 1 integer arg. Acpi 3.0 expanded to 3 args. Allow both. */
 
     {{"_SDD",   METHOD_1ARGS (ACPI_TYPE_BUFFER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_SEG",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SHL",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SLI",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_SPD",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SRS",   METHOD_1ARGS (ACPI_TYPE_BUFFER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_SRT",   METHOD_1ARGS (ACPI_TYPE_BUFFER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SRV",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, /* See IPMI spec */
 
     {{"_SST",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_STA",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_STM",   METHOD_3ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_BUFFER, ACPI_TYPE_BUFFER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_STP",   METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_STR",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_STV",   METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SUB",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_STRING)}},
 
     {{"_SUN",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_SWS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TC1",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TC2",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TDL",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TIP",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TIV",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TMP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TPC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TPT",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_TRT",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 2 Ref/6 Int */
                     PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER, 6, 0),
 
     {{"_TSD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 5 Int with count */
                     PACKAGE_INFO (ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0,0,0),
 
     {{"_TSP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TSS",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 5 Int */
                     PACKAGE_INFO (ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0,0,0),
 
     {{"_TST",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_TTS",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_NO_RETURN_VALUE}},
 
     {{"_TZD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
                     PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
 
     {{"_TZM",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_REFERENCE)}},
 
     {{"_TZP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_UID",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING)}},
 
     {{"_UPC",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0,0,0),
 
     {{"_UPD",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_UPP",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     {{"_VPO",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
 
     /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */
 
     {{"_WAK",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE)}},
                     PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0,0,0), /* Fixed-length (2 Int), but is optional */
 
     /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */
 
     {{"_WDG",   METHOD_0ARGS,
                 METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
 
     {{"_WED",   METHOD_1ARGS (ACPI_TYPE_INTEGER),
                 METHOD_RETURNS (ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER)}},
 
     PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */
 };
 #else
 extern const ACPI_PREDEFINED_INFO       AcpiGbl_PredefinedMethods[];
 #endif
 
 
 #if (defined ACPI_CREATE_RESOURCE_TABLE && defined ACPI_APPLICATION)
 /******************************************************************************
  *
  * Predefined names for use in Resource Descriptors. These names do not
  * appear in the global Predefined Name table (since these names never
  * appear in actual AML byte code, only in the original ASL)
  *
  * Note: Used by iASL compiler and AcpiHelp utility only.
  *
  *****************************************************************************/
 
 const ACPI_PREDEFINED_INFO      AcpiGbl_ResourceNames[] =
 {
     {{"_ADR",   WIDTH_16 | WIDTH_64,            0}},
     {{"_ALN",   WIDTH_8 | WIDTH_16 | WIDTH_32,  0}},
     {{"_ASI",   WIDTH_8,                        0}},
     {{"_ASZ",   WIDTH_8,                        0}},
     {{"_ATT",   WIDTH_64,                       0}},
     {{"_BAS",   WIDTH_16 | WIDTH_32,            0}},
     {{"_BM_",   WIDTH_1,                        0}},
     {{"_DBT",   WIDTH_16,                       0}},  /* Acpi 5.0 */
     {{"_DEC",   WIDTH_1,                        0}},
     {{"_DMA",   WIDTH_8,                        0}},
     {{"_DPL",   WIDTH_1,                        0}},  /* Acpi 5.0 */
     {{"_DRS",   WIDTH_16,                       0}},  /* Acpi 5.0 */
     {{"_END",   WIDTH_1,                        0}},  /* Acpi 5.0 */
     {{"_FLC",   WIDTH_2,                        0}},  /* Acpi 5.0 */
     {{"_GRA",   WIDTH_ADDRESS,                  0}},
     {{"_HE_",   WIDTH_1,                        0}},
     {{"_INT",   WIDTH_16 | WIDTH_32,            0}},
     {{"_IOR",   WIDTH_2,                        0}},  /* Acpi 5.0 */
     {{"_LEN",   WIDTH_8 | WIDTH_ADDRESS,        0}},
     {{"_LIN",   WIDTH_8,                        0}},  /* Acpi 5.0 */
     {{"_LL_",   WIDTH_1,                        0}},
     {{"_MAF",   WIDTH_1,                        0}},
     {{"_MAX",   WIDTH_ADDRESS,                  0}},
     {{"_MEM",   WIDTH_2,                        0}},
     {{"_MIF",   WIDTH_1,                        0}},
     {{"_MIN",   WIDTH_ADDRESS,                  0}},
     {{"_MOD",   WIDTH_1,                        0}},  /* Acpi 5.0 */
     {{"_MTP",   WIDTH_2,                        0}},
     {{"_PAR",   WIDTH_8,                        0}},  /* Acpi 5.0 */
     {{"_PHA",   WIDTH_1,                        0}},  /* Acpi 5.0 */
     {{"_PIN",   WIDTH_16,                       0}},  /* Acpi 5.0 */
     {{"_PPI",   WIDTH_8,                        0}},  /* Acpi 5.0 */
     {{"_POL",   WIDTH_1 | WIDTH_2,              0}},  /* Acpi 5.0 */
     {{"_RBO",   WIDTH_8,                        0}},
     {{"_RBW",   WIDTH_8,                        0}},
     {{"_RNG",   WIDTH_1,                        0}},
     {{"_RT_",   WIDTH_8,                        0}},  /* Acpi 3.0 */
     {{"_RW_",   WIDTH_1,                        0}},
     {{"_RXL",   WIDTH_16,                       0}},  /* Acpi 5.0 */
     {{"_SHR",   WIDTH_2,                        0}},
     {{"_SIZ",   WIDTH_2,                        0}},
     {{"_SLV",   WIDTH_1,                        0}},  /* Acpi 5.0 */
     {{"_SPE",   WIDTH_32,                       0}},  /* Acpi 5.0 */
     {{"_STB",   WIDTH_2,                        0}},  /* Acpi 5.0 */
     {{"_TRA",   WIDTH_ADDRESS,                  0}},
     {{"_TRS",   WIDTH_1,                        0}},
     {{"_TSF",   WIDTH_8,                        0}},  /* Acpi 3.0 */
     {{"_TTP",   WIDTH_1,                        0}},
     {{"_TXL",   WIDTH_16,                       0}},  /* Acpi 5.0 */
     {{"_TYP",   WIDTH_2 | WIDTH_16,             0}},
     {{"_VEN",   VARIABLE_DATA,                  0}},  /* Acpi 5.0 */
     PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */
 };
 
 static const ACPI_PREDEFINED_INFO      AcpiGbl_ScopeNames[] = {
     {{"_GPE",     0,      0}},
     {{"_PR_",     0,      0}},
     {{"_SB_",     0,      0}},
     {{"_SI_",     0,      0}},
     {{"_TZ_",     0,      0}},
     PACKAGE_INFO (0,0,0,0,0,0) /* Table terminator */
 };
 #else
 extern const ACPI_PREDEFINED_INFO      AcpiGbl_ResourceNames[];
 #endif
 
 #endif
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acstruct.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acstruct.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acstruct.h	(revision 249699)
@@ -1,254 +1,270 @@
 /******************************************************************************
  *
  * Name: acstruct.h - Internal structs
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #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 AcpiNsInitializeObjects and AcpiDsInitializeObjects */
 
 typedef struct acpi_init_walk_info
 {
     UINT32                          TableIndex;
     UINT32                          ObjectCount;
     UINT32                          MethodCount;
     UINT32                          DeviceCount;
     UINT32                          OpRegionCount;
     UINT32                          FieldCount;
     UINT32                          BufferCount;
     UINT32                          PackageCount;
     UINT32                          OpRegionInit;
     UINT32                          FieldInit;
     UINT32                          BufferInit;
     UINT32                          PackageInit;
     ACPI_OWNER_ID                   OwnerId;
 
 } ACPI_INIT_WALK_INFO;
 
 
 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.
+ * Structure used to pass object evaluation information and 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;
+    /* The first 3 elements are passed by the caller to AcpiNsEvaluate */
 
+    ACPI_NAMESPACE_NODE             *PrefixNode;        /* Input: starting node */
+    char                            *RelativePathname;  /* Input: path relative to PrefixNode */
+    ACPI_OPERAND_OBJECT             **Parameters;       /* Input: argument list */
+
+    ACPI_NAMESPACE_NODE             *Node;              /* Resolved node (PrefixNode:RelativePathname) */
+    ACPI_OPERAND_OBJECT             *ObjDesc;           /* Object attached to the resolved node */
+    char                            *FullPathname;      /* Full pathname of the resolved node */
+
+    const ACPI_PREDEFINED_INFO      *Predefined;        /* Used if Node is a predefined name */
+    ACPI_OPERAND_OBJECT             *ReturnObject;      /* Object returned from the evaluation */
+    union acpi_operand_object       *ParentPackage;     /* Used if return object is a Package */
+
+    UINT32                          ReturnFlags;        /* Used for return value analysis */
+    UINT32                          ReturnBtype;        /* Bitmapped type of the returned object */
+    UINT16                          ParamCount;         /* Count of the input argument list */
+    UINT8                           PassNumber;         /* Parser pass number */
+    UINT8                           ReturnObjectType;   /* Object type of the returned object */
+    UINT8                           NodeFlags;          /* Same as Node->Flags */
+    UINT8                           Flags;              /* General flags */
+
 } ACPI_EVALUATE_INFO;
 
 /* Values for Flags above */
 
-#define ACPI_IGNORE_RETURN_VALUE        1
+#define ACPI_IGNORE_RETURN_VALUE    1
+
+/* Defines for ReturnFlags field above */
+
+#define ACPI_OBJECT_REPAIRED        1
+#define ACPI_OBJECT_WRAPPED         2
 
 
 /* Info used by AcpiNsInitializeDevices */
 
 typedef struct acpi_device_walk_info
 {
     ACPI_TABLE_DESC                 *TableDesc;
     ACPI_EVALUATE_INFO              *EvaluateInfo;
     UINT32                          DeviceCount;
     UINT32                          Num_STA;
     UINT32                          Num_INI;
 
 } 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
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include/acutils.h
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include/acutils.h	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include/acutils.h	(revision 249699)
@@ -1,1039 +1,1048 @@
 /******************************************************************************
  *
  * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
  *
  *****************************************************************************/
 
 /*
  * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions, and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    substantially similar to the "NO WARRANTY" disclaimer below
  *    ("Disclaimer") and any redistribution must be conditioned upon
  *    including a substantially similar Disclaimer requirement for further
  *    binary redistribution.
  * 3. Neither the names of the above-listed copyright holders nor the names
  *    of any contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
  * Alternatively, this software may be distributed under the terms of the
  * GNU General Public License ("GPL") version 2 as published by the Free
  * Software Foundation.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
 #ifndef _ACUTILS_H
 #define _ACUTILS_H
 
 
 extern const UINT8                      AcpiGbl_ResourceAmlSizes[];
 extern const UINT8                      AcpiGbl_ResourceAmlSerialBusSizes[];
 
 /* 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[];
 extern const char                       *AcpiGbl_PpcDecode[];
 extern const char                       *AcpiGbl_IorDecode[];
 extern const char                       *AcpiGbl_DtsDecode[];
 extern const char                       *AcpiGbl_CtDecode[];
 extern const char                       *AcpiGbl_SbtDecode[];
 extern const char                       *AcpiGbl_AmDecode[];
 extern const char                       *AcpiGbl_SmDecode[];
 extern const char                       *AcpiGbl_WmDecode[];
 extern const char                       *AcpiGbl_CphDecode[];
 extern const char                       *AcpiGbl_CpoDecode[];
 extern const char                       *AcpiGbl_DpDecode[];
 extern const char                       *AcpiGbl_EdDecode[];
 extern const char                       *AcpiGbl_BpbDecode[];
 extern const char                       *AcpiGbl_SbDecode[];
 extern const char                       *AcpiGbl_FcDecode[];
 extern const char                       *AcpiGbl_PtDecode[];
 #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;
 
 /* Object reference counts */
 
 #define REF_INCREMENT       (UINT16) 0
 #define REF_DECREMENT       (UINT16) 1
 
 /* 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 (
     UINT64                  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,
     UINT64                  Value);
 
 void
 AcpiUtPtrExit (
     UINT32                  LineNumber,
     const char              *FunctionName,
     const char              *ModuleName,
     UINT32                  ComponentId,
     UINT8                   *Ptr);
 
 void
 AcpiUtDebugDumpBuffer (
     UINT8                   *Buffer,
     UINT32                  Count,
     UINT32                  Display,
     UINT32                  ComponentId);
 
 void
 AcpiUtDumpBuffer (
     UINT8                   *Buffer,
     UINT32                  Count,
     UINT32                  Display,
     UINT32                  Offset);
 
 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
 AcpiUtEvaluateObject (
     ACPI_NAMESPACE_NODE     *PrefixNode,
     char                    *Path,
     UINT32                  ExpectedReturnBtypes,
     ACPI_OPERAND_OBJECT     **ReturnDesc);
 
 ACPI_STATUS
 AcpiUtEvaluateNumericObject (
     char                    *ObjectName,
     ACPI_NAMESPACE_NODE     *DeviceNode,
     UINT64                  *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_PNP_DEVICE_ID      **ReturnId);
 
 ACPI_STATUS
 AcpiUtExecute_UID (
     ACPI_NAMESPACE_NODE     *DeviceNode,
     ACPI_PNP_DEVICE_ID      **ReturnId);
 
 ACPI_STATUS
 AcpiUtExecute_SUB (
     ACPI_NAMESPACE_NODE     *DeviceNode,
     ACPI_PNP_DEVICE_ID      **ReturnId);
 
 ACPI_STATUS
 AcpiUtExecute_CID (
     ACPI_NAMESPACE_NODE     *DeviceNode,
     ACPI_PNP_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);
 
 
 /*
  * utosi - Support for the _OSI predefined control method
  */
 ACPI_STATUS
 AcpiUtInitializeInterfaces (
     void);
 
 ACPI_STATUS
 AcpiUtInterfaceTerminate (
     void);
 
 ACPI_STATUS
 AcpiUtInstallInterface (
     ACPI_STRING             InterfaceName);
 
 ACPI_STATUS
 AcpiUtRemoveInterface (
     ACPI_STRING             InterfaceName);
 
 ACPI_INTERFACE_INFO *
 AcpiUtGetInterface (
     ACPI_STRING             InterfaceName);
 
 ACPI_STATUS
 AcpiUtOsiImplementation (
     ACPI_WALK_STATE         *WalkState);
 
 
 /*
  * utpredef - support for predefined names
  */
 const ACPI_PREDEFINED_INFO *
 AcpiUtGetNextPredefinedMethod (
     const ACPI_PREDEFINED_INFO  *ThisName);
 
 const ACPI_PREDEFINED_INFO *
 AcpiUtMatchPredefinedMethod (
     char                        *Name);
 
 const ACPI_PREDEFINED_INFO *
 AcpiUtMatchResourceName (
     char                        *Name);
 
 void
 AcpiUtDisplayPredefinedMethod (
     char                        *Buffer,
     const ACPI_PREDEFINED_INFO  *ThisName,
     BOOLEAN                     MultiLine);
 
 void
 AcpiUtGetExpectedReturnTypes (
     char                    *Buffer,
     UINT32                  ExpectedBtypes);
 
 UINT32
 AcpiUtGetResourceBitWidth (
     char                    *Buffer,
     UINT16                  Types);
 
 
 /*
  * 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 (
     UINT64                  InDividend,
     UINT64                  InDivisor,
     UINT64                  *OutQuotient,
     UINT64                  *OutRemainder);
 
 ACPI_STATUS
 AcpiUtShortDivide (
     UINT64                  InDividend,
     UINT32                  Divisor,
     UINT64                  *OutQuotient,
     UINT32                  *OutRemainder);
 
 
 /*
  * utmisc
  */
 const ACPI_EXCEPTION_INFO *
 AcpiUtValidateException (
     ACPI_STATUS             Status);
 
 BOOLEAN
 AcpiUtIsPciRootBridge (
     char                    *Id);
 
 BOOLEAN
 AcpiUtIsAmlTable (
     ACPI_TABLE_HEADER       *Table);
 
 ACPI_STATUS
 AcpiUtWalkPackageTree (
     ACPI_OPERAND_OBJECT     *SourceObject,
     void                    *TargetObject,
     ACPI_PKG_CALLBACK       WalkCallback,
     void                    *Context);
 
 
 /* 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
 
 
 /*
  * utownerid - Support for Table/Method Owner IDs
  */
 ACPI_STATUS
 AcpiUtAllocateOwnerId (
     ACPI_OWNER_ID           *OwnerId);
 
 void
 AcpiUtReleaseOwnerId (
     ACPI_OWNER_ID           *OwnerId);
 
 
 /*
  * utresrc
  */
 ACPI_STATUS
 AcpiUtWalkAmlResources (
     ACPI_WALK_STATE         *WalkState,
     UINT8                   *Aml,
     ACPI_SIZE               AmlLength,
     ACPI_WALK_AML_CALLBACK  UserFunction,
     void                    **Context);
 
 ACPI_STATUS
 AcpiUtValidateResource (
     ACPI_WALK_STATE         *WalkState,
     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);
 
 
 /*
  * utstring - String and character utilities
  */
 void
 AcpiUtStrupr (
     char                    *SrcString);
 
 void
 AcpiUtStrlwr (
     char                    *SrcString);
 
 int
 AcpiUtStricmp (
     char                    *String1,
     char                    *String2);
 
 ACPI_STATUS
 AcpiUtStrtoul64 (
     char                    *String,
     UINT32                  Base,
     UINT64                  *RetInteger);
 
 void
 AcpiUtPrintString (
     char                    *String,
     UINT8                   MaxLength);
 
 void
 UtConvertBackslashes (
     char                    *Pathname);
 
 BOOLEAN
 AcpiUtValidAcpiName (
     UINT32                  Name);
 
 BOOLEAN
 AcpiUtValidAcpiChar (
     char                    Character,
     UINT32                  Position);
 
 void
 AcpiUtRepairName (
     char                    *Name);
 
 
 /*
  * 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 /* ACPI_DBG_TRACK_ALLOCATIONS */
 
 /*
  * utaddress - address range check
  */
 ACPI_STATUS
 AcpiUtAddAddressRange (
     ACPI_ADR_SPACE_TYPE     SpaceId,
     ACPI_PHYSICAL_ADDRESS   Address,
     UINT32                  Length,
     ACPI_NAMESPACE_NODE     *RegionNode);
 
 void
 AcpiUtRemoveAddressRange (
     ACPI_ADR_SPACE_TYPE     SpaceId,
     ACPI_NAMESPACE_NODE     *RegionNode);
 
 UINT32
 AcpiUtCheckAddressRange (
     ACPI_ADR_SPACE_TYPE     SpaceId,
     ACPI_PHYSICAL_ADDRESS   Address,
     UINT32                  Length,
     BOOLEAN                 Warn);
 
 void
 AcpiUtDeleteAddressLists (
     void);
 
 /*
  * utxferror - various error/warning output functions
  */
 void ACPI_INTERNAL_VAR_XFACE
 AcpiUtPredefinedWarning (
     const char              *ModuleName,
     UINT32                  LineNumber,
     char                    *Pathname,
     UINT8                   NodeFlags,
     const char              *Format,
     ...);
 
 void ACPI_INTERNAL_VAR_XFACE
 AcpiUtPredefinedInfo (
     const char              *ModuleName,
     UINT32                  LineNumber,
     char                    *Pathname,
     UINT8                   NodeFlags,
     const char              *Format,
     ...);
 
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtPredefinedBiosError (
+    const char              *ModuleName,
+    UINT32                  LineNumber,
+    char                    *Pathname,
+    UINT8                   NodeFlags,
+    const char              *Format,
+    ...);
+
 void
 AcpiUtNamespaceError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *InternalName,
     ACPI_STATUS             LookupStatus);
 
 void
 AcpiUtMethodError (
     const char              *ModuleName,
     UINT32                  LineNumber,
     const char              *Message,
     ACPI_NAMESPACE_NODE     *Node,
     const char              *Path,
     ACPI_STATUS             LookupStatus);
 
 #endif /* _ACUTILS_H */
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/include
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/include	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/include	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/include
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/include:r249111-249661
   Merged /head/sys/contrib/dev/acpica/include:r249197-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica/os_specific
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica/os_specific	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica/os_specific	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica/os_specific
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /vendor-sys/acpica/dist/source/os_specific:r245579-249661
   Merged /head/sys/contrib/dev/acpica/os_specific:r246295-249698
Index: user/attilio/vmcontention/sys/contrib/dev/acpica
===================================================================
--- user/attilio/vmcontention/sys/contrib/dev/acpica	(revision 249698)
+++ user/attilio/vmcontention/sys/contrib/dev/acpica	(revision 249699)

Property changes on: user/attilio/vmcontention/sys/contrib/dev/acpica
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,2 ##
   Merged /head/sys/contrib/dev/acpica:r249197-249698
   Merged /vendor-sys/acpica/dist/source:r249112-249661
Index: user/attilio/vmcontention/sys/dev/ath/if_ath.c
===================================================================
--- user/attilio/vmcontention/sys/dev/ath/if_ath.c	(revision 249698)
+++ user/attilio/vmcontention/sys/dev/ath/if_ath.c	(revision 249699)
@@ -1,5992 +1,5992 @@
 /*-
  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer,
  *    without modification.
  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
  *    redistribution must be conditioned upon including a substantially
  *    similar Disclaimer requirement for further binary redistribution.
  *
  * NO WARRANTY
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 /*
  * Driver for the Atheros Wireless LAN controller.
  *
  * This software is derived from work of Atsushi Onoe; his contribution
  * is greatly appreciated.
  */
 
 #include "opt_inet.h"
 #include "opt_ath.h"
 /*
  * This is needed for register operations which are performed
  * by the driver - eg, calls to ath_hal_gettsf32().
  *
  * It's also required for any AH_DEBUG checks in here, eg the
  * module dependencies.
  */
 #include "opt_ah.h"
 #include "opt_wlan.h"
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 	/* for mp_ncpus */
 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #ifdef IEEE80211_SUPPORT_SUPERG
 #include 
 #endif
 #ifdef IEEE80211_SUPPORT_TDMA
 #include 
 #endif
 
 #include 
 
 #ifdef INET
 #include 
 #include 
 #endif
 
 #include 
 #include 		/* XXX for softled */
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #ifdef ATH_TX99_DIAG
 #include 
 #endif
 
 #ifdef	ATH_DEBUG_ALQ
 #include 
 #endif
 
 /*
  * Only enable this if you're working on PS-POLL support.
  */
 #undef	ATH_SW_PSQ
 
 /*
  * ATH_BCBUF determines the number of vap's that can transmit
  * beacons and also (currently) the number of vap's that can
  * have unique mac addresses/bssid.  When staggering beacons
  * 4 is probably a good max as otherwise the beacons become
  * very closely spaced and there is limited time for cab q traffic
  * to go out.  You can burst beacons instead but that is not good
  * for stations in power save and at some point you really want
  * another radio (and channel).
  *
  * The limit on the number of mac addresses is tied to our use of
  * the U/L bit and tracking addresses in a byte; it would be
  * worthwhile to allow more for applications like proxy sta.
  */
 CTASSERT(ATH_BCBUF <= 8);
 
 static struct ieee80211vap *ath_vap_create(struct ieee80211com *,
 		    const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
 		    const uint8_t [IEEE80211_ADDR_LEN],
 		    const uint8_t [IEEE80211_ADDR_LEN]);
 static void	ath_vap_delete(struct ieee80211vap *);
 static void	ath_init(void *);
 static void	ath_stop_locked(struct ifnet *);
 static void	ath_stop(struct ifnet *);
 static int	ath_reset_vap(struct ieee80211vap *, u_long);
 static void	ath_start_queue(struct ifnet *ifp);
 static int	ath_media_change(struct ifnet *);
 static void	ath_watchdog(void *);
 static int	ath_ioctl(struct ifnet *, u_long, caddr_t);
 static void	ath_fatal_proc(void *, int);
 static void	ath_bmiss_vap(struct ieee80211vap *);
 static void	ath_bmiss_proc(void *, int);
 static void	ath_key_update_begin(struct ieee80211vap *);
 static void	ath_key_update_end(struct ieee80211vap *);
 static void	ath_update_mcast(struct ifnet *);
 static void	ath_update_promisc(struct ifnet *);
 static void	ath_updateslot(struct ifnet *);
 static void	ath_bstuck_proc(void *, int);
 static void	ath_reset_proc(void *, int);
 static int	ath_desc_alloc(struct ath_softc *);
 static void	ath_desc_free(struct ath_softc *);
 static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *,
 			const uint8_t [IEEE80211_ADDR_LEN]);
 static void	ath_node_cleanup(struct ieee80211_node *);
 static void	ath_node_free(struct ieee80211_node *);
 static void	ath_node_getsignal(const struct ieee80211_node *,
 			int8_t *, int8_t *);
 static void	ath_txq_init(struct ath_softc *sc, struct ath_txq *, int);
 static struct ath_txq *ath_txq_setup(struct ath_softc*, int qtype, int subtype);
 static int	ath_tx_setup(struct ath_softc *, int, int);
 static void	ath_tx_cleanupq(struct ath_softc *, struct ath_txq *);
 static void	ath_tx_cleanup(struct ath_softc *);
 static int	ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq,
 		    int dosched);
 static void	ath_tx_proc_q0(void *, int);
 static void	ath_tx_proc_q0123(void *, int);
 static void	ath_tx_proc(void *, int);
 static void	ath_txq_sched_tasklet(void *, int);
 static int	ath_chan_set(struct ath_softc *, struct ieee80211_channel *);
 static void	ath_chan_change(struct ath_softc *, struct ieee80211_channel *);
 static void	ath_scan_start(struct ieee80211com *);
 static void	ath_scan_end(struct ieee80211com *);
 static void	ath_set_channel(struct ieee80211com *);
 #ifdef	ATH_ENABLE_11N
 static void	ath_update_chw(struct ieee80211com *);
 #endif	/* ATH_ENABLE_11N */
 static void	ath_calibrate(void *);
 static int	ath_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static void	ath_setup_stationkey(struct ieee80211_node *);
 static void	ath_newassoc(struct ieee80211_node *, int);
 static int	ath_setregdomain(struct ieee80211com *,
 		    struct ieee80211_regdomain *, int,
 		    struct ieee80211_channel []);
 static void	ath_getradiocaps(struct ieee80211com *, int, int *,
 		    struct ieee80211_channel []);
 static int	ath_getchannels(struct ath_softc *);
 
 static int	ath_rate_setup(struct ath_softc *, u_int mode);
 static void	ath_setcurmode(struct ath_softc *, enum ieee80211_phymode);
 
 static void	ath_announce(struct ath_softc *);
 
 static void	ath_dfs_tasklet(void *, int);
 static void	ath_node_powersave(struct ieee80211_node *, int);
 static int	ath_node_set_tim(struct ieee80211_node *, int);
 
 #ifdef IEEE80211_SUPPORT_TDMA
 #include 
 #endif
 
 SYSCTL_DECL(_hw_ath);
 
 /* XXX validate sysctl values */
 static	int ath_longcalinterval = 30;		/* long cals every 30 secs */
 SYSCTL_INT(_hw_ath, OID_AUTO, longcal, CTLFLAG_RW, &ath_longcalinterval,
 	    0, "long chip calibration interval (secs)");
 static	int ath_shortcalinterval = 100;		/* short cals every 100 ms */
 SYSCTL_INT(_hw_ath, OID_AUTO, shortcal, CTLFLAG_RW, &ath_shortcalinterval,
 	    0, "short chip calibration interval (msecs)");
 static	int ath_resetcalinterval = 20*60;	/* reset cal state 20 mins */
 SYSCTL_INT(_hw_ath, OID_AUTO, resetcal, CTLFLAG_RW, &ath_resetcalinterval,
 	    0, "reset chip calibration results (secs)");
 static	int ath_anicalinterval = 100;		/* ANI calibration - 100 msec */
 SYSCTL_INT(_hw_ath, OID_AUTO, anical, CTLFLAG_RW, &ath_anicalinterval,
 	    0, "ANI calibration (msecs)");
 
 int ath_rxbuf = ATH_RXBUF;		/* # rx buffers to allocate */
 SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RW, &ath_rxbuf,
 	    0, "rx buffers allocated");
 TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf);
 int ath_txbuf = ATH_TXBUF;		/* # tx buffers to allocate */
 SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RW, &ath_txbuf,
 	    0, "tx buffers allocated");
 TUNABLE_INT("hw.ath.txbuf", &ath_txbuf);
 int ath_txbuf_mgmt = ATH_MGMT_TXBUF;	/* # mgmt tx buffers to allocate */
 SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RW, &ath_txbuf_mgmt,
 	    0, "tx (mgmt) buffers allocated");
 TUNABLE_INT("hw.ath.txbuf_mgmt", &ath_txbuf_mgmt);
 
 int ath_bstuck_threshold = 4;		/* max missed beacons */
 SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold,
 	    0, "max missed beacon xmits before chip reset");
 
 MALLOC_DEFINE(M_ATHDEV, "athdev", "ath driver dma buffers");
 
 void
 ath_legacy_attach_comp_func(struct ath_softc *sc)
 {
 
 	/*
 	 * Special case certain configurations.  Note the
 	 * CAB queue is handled by these specially so don't
 	 * include them when checking the txq setup mask.
 	 */
 	switch (sc->sc_txqsetup &~ (1<sc_cabq->axq_qnum)) {
 	case 0x01:
 		TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc);
 		break;
 	case 0x0f:
 		TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc);
 		break;
 	default:
 		TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc);
 		break;
 	}
 }
 
 #define	HAL_MODE_HT20 (HAL_MODE_11NG_HT20 | HAL_MODE_11NA_HT20)
 #define	HAL_MODE_HT40 \
 	(HAL_MODE_11NG_HT40PLUS | HAL_MODE_11NG_HT40MINUS | \
 	HAL_MODE_11NA_HT40PLUS | HAL_MODE_11NA_HT40MINUS)
 int
 ath_attach(u_int16_t devid, struct ath_softc *sc)
 {
 	struct ifnet *ifp;
 	struct ieee80211com *ic;
 	struct ath_hal *ah = NULL;
 	HAL_STATUS status;
 	int error = 0, i;
 	u_int wmodes;
 	uint8_t macaddr[IEEE80211_ADDR_LEN];
 	int rx_chainmask, tx_chainmask;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid);
 
 	CURVNET_SET(vnet0);
 	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
 	if (ifp == NULL) {
 		device_printf(sc->sc_dev, "can not if_alloc()\n");
 		error = ENOSPC;
 		CURVNET_RESTORE();
 		goto bad;
 	}
 	ic = ifp->if_l2com;
 
 	/* set these up early for if_printf use */
 	if_initname(ifp, device_get_name(sc->sc_dev),
 		device_get_unit(sc->sc_dev));
 	CURVNET_RESTORE();
 
 	ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh,
 	    sc->sc_eepromdata, &status);
 	if (ah == NULL) {
 		if_printf(ifp, "unable to attach hardware; HAL status %u\n",
 			status);
 		error = ENXIO;
 		goto bad;
 	}
 	sc->sc_ah = ah;
 	sc->sc_invalid = 0;	/* ready to go, enable interrupt handling */
 #ifdef	ATH_DEBUG
 	sc->sc_debug = ath_debug;
 #endif
 
 	/*
 	 * Setup the DMA/EDMA functions based on the current
 	 * hardware support.
 	 *
 	 * This is required before the descriptors are allocated.
 	 */
 	if (ath_hal_hasedma(sc->sc_ah)) {
 		sc->sc_isedma = 1;
 		ath_recv_setup_edma(sc);
 		ath_xmit_setup_edma(sc);
 	} else {
 		ath_recv_setup_legacy(sc);
 		ath_xmit_setup_legacy(sc);
 	}
 
 	/*
 	 * Check if the MAC has multi-rate retry support.
 	 * We do this by trying to setup a fake extended
 	 * descriptor.  MAC's that don't have support will
 	 * return false w/o doing anything.  MAC's that do
 	 * support it will return true w/o doing anything.
 	 */
 	sc->sc_mrretry = ath_hal_setupxtxdesc(ah, NULL, 0,0, 0,0, 0,0);
 
 	/*
 	 * Check if the device has hardware counters for PHY
 	 * errors.  If so we need to enable the MIB interrupt
 	 * so we can act on stat triggers.
 	 */
 	if (ath_hal_hwphycounters(ah))
 		sc->sc_needmib = 1;
 
 	/*
 	 * Get the hardware key cache size.
 	 */
 	sc->sc_keymax = ath_hal_keycachesize(ah);
 	if (sc->sc_keymax > ATH_KEYMAX) {
 		if_printf(ifp, "Warning, using only %u of %u key cache slots\n",
 			ATH_KEYMAX, sc->sc_keymax);
 		sc->sc_keymax = ATH_KEYMAX;
 	}
 	/*
 	 * Reset the key cache since some parts do not
 	 * reset the contents on initial power up.
 	 */
 	for (i = 0; i < sc->sc_keymax; i++)
 		ath_hal_keyreset(ah, i);
 
 	/*
 	 * Collect the default channel list.
 	 */
 	error = ath_getchannels(sc);
 	if (error != 0)
 		goto bad;
 
 	/*
 	 * Setup rate tables for all potential media types.
 	 */
 	ath_rate_setup(sc, IEEE80211_MODE_11A);
 	ath_rate_setup(sc, IEEE80211_MODE_11B);
 	ath_rate_setup(sc, IEEE80211_MODE_11G);
 	ath_rate_setup(sc, IEEE80211_MODE_TURBO_A);
 	ath_rate_setup(sc, IEEE80211_MODE_TURBO_G);
 	ath_rate_setup(sc, IEEE80211_MODE_STURBO_A);
 	ath_rate_setup(sc, IEEE80211_MODE_11NA);
 	ath_rate_setup(sc, IEEE80211_MODE_11NG);
 	ath_rate_setup(sc, IEEE80211_MODE_HALF);
 	ath_rate_setup(sc, IEEE80211_MODE_QUARTER);
 
 	/* NB: setup here so ath_rate_update is happy */
 	ath_setcurmode(sc, IEEE80211_MODE_11A);
 
 	/*
 	 * Allocate TX descriptors and populate the lists.
 	 */
 	error = ath_desc_alloc(sc);
 	if (error != 0) {
 		if_printf(ifp, "failed to allocate TX descriptors: %d\n",
 		    error);
 		goto bad;
 	}
 	error = ath_txdma_setup(sc);
 	if (error != 0) {
 		if_printf(ifp, "failed to allocate TX descriptors: %d\n",
 		    error);
 		goto bad;
 	}
 
 	/*
 	 * Allocate RX descriptors and populate the lists.
 	 */
 	error = ath_rxdma_setup(sc);
 	if (error != 0) {
 		if_printf(ifp, "failed to allocate RX descriptors: %d\n",
 		    error);
 		goto bad;
 	}
 
 	callout_init_mtx(&sc->sc_cal_ch, &sc->sc_mtx, 0);
 	callout_init_mtx(&sc->sc_wd_ch, &sc->sc_mtx, 0);
 
 	ATH_TXBUF_LOCK_INIT(sc);
 
 	sc->sc_tq = taskqueue_create("ath_taskq", M_NOWAIT,
 		taskqueue_thread_enqueue, &sc->sc_tq);
 	taskqueue_start_threads(&sc->sc_tq, 1, PI_NET,
 		"%s taskq", ifp->if_xname);
 
 	TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc);
 	TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc);
 	TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc);
 	TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc);
 	TASK_INIT(&sc->sc_txqtask, 0, ath_txq_sched_tasklet, sc);
 	TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc);
 
 	/* XXX make this a higher priority taskqueue? */
 	TASK_INIT(&sc->sc_txpkttask, 0, ath_start_task, sc);
 
 	/*
 	 * Allocate hardware transmit queues: one queue for
 	 * beacon frames and one data queue for each QoS
 	 * priority.  Note that the hal handles resetting
 	 * these queues at the needed time.
 	 *
 	 * XXX PS-Poll
 	 */
 	sc->sc_bhalq = ath_beaconq_setup(sc);
 	if (sc->sc_bhalq == (u_int) -1) {
 		if_printf(ifp, "unable to setup a beacon xmit queue!\n");
 		error = EIO;
 		goto bad2;
 	}
 	sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0);
 	if (sc->sc_cabq == NULL) {
 		if_printf(ifp, "unable to setup CAB xmit queue!\n");
 		error = EIO;
 		goto bad2;
 	}
 	/* NB: insure BK queue is the lowest priority h/w queue */
 	if (!ath_tx_setup(sc, WME_AC_BK, HAL_WME_AC_BK)) {
 		if_printf(ifp, "unable to setup xmit queue for %s traffic!\n",
 			ieee80211_wme_acnames[WME_AC_BK]);
 		error = EIO;
 		goto bad2;
 	}
 	if (!ath_tx_setup(sc, WME_AC_BE, HAL_WME_AC_BE) ||
 	    !ath_tx_setup(sc, WME_AC_VI, HAL_WME_AC_VI) ||
 	    !ath_tx_setup(sc, WME_AC_VO, HAL_WME_AC_VO)) {
 		/*
 		 * Not enough hardware tx queues to properly do WME;
 		 * just punt and assign them all to the same h/w queue.
 		 * We could do a better job of this if, for example,
 		 * we allocate queues when we switch from station to
 		 * AP mode.
 		 */
 		if (sc->sc_ac2q[WME_AC_VI] != NULL)
 			ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]);
 		if (sc->sc_ac2q[WME_AC_BE] != NULL)
 			ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]);
 		sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK];
 		sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK];
 		sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK];
 	}
 
 	/*
 	 * Attach the TX completion function.
 	 *
 	 * The non-EDMA chips may have some special case optimisations;
 	 * this method gives everyone a chance to attach cleanly.
 	 */
 	sc->sc_tx.xmit_attach_comp_func(sc);
 
 	/*
 	 * Setup rate control.  Some rate control modules
 	 * call back to change the anntena state so expose
 	 * the necessary entry points.
 	 * XXX maybe belongs in struct ath_ratectrl?
 	 */
 	sc->sc_setdefantenna = ath_setdefantenna;
 	sc->sc_rc = ath_rate_attach(sc);
 	if (sc->sc_rc == NULL) {
 		error = EIO;
 		goto bad2;
 	}
 
 	/* Attach DFS module */
 	if (! ath_dfs_attach(sc)) {
 		device_printf(sc->sc_dev,
 		    "%s: unable to attach DFS\n", __func__);
 		error = EIO;
 		goto bad2;
 	}
 
 	/* Attach spectral module */
 	if (ath_spectral_attach(sc) < 0) {
 		device_printf(sc->sc_dev,
 		    "%s: unable to attach spectral\n", __func__);
 		error = EIO;
 		goto bad2;
 	}
 
 	/* Start DFS processing tasklet */
 	TASK_INIT(&sc->sc_dfstask, 0, ath_dfs_tasklet, sc);
 
 	/* Configure LED state */
 	sc->sc_blinking = 0;
 	sc->sc_ledstate = 1;
 	sc->sc_ledon = 0;			/* low true */
 	sc->sc_ledidle = (2700*hz)/1000;	/* 2.7sec */
 	callout_init(&sc->sc_ledtimer, CALLOUT_MPSAFE);
 
 	/*
 	 * Don't setup hardware-based blinking.
 	 *
 	 * Although some NICs may have this configured in the
 	 * default reset register values, the user may wish
 	 * to alter which pins have which function.
 	 *
 	 * The reference driver attaches the MAC network LED to GPIO1 and
 	 * the MAC power LED to GPIO2.  However, the DWA-552 cardbus
 	 * NIC has these reversed.
 	 */
 	sc->sc_hardled = (1 == 0);
 	sc->sc_led_net_pin = -1;
 	sc->sc_led_pwr_pin = -1;
 	/*
 	 * Auto-enable soft led processing for IBM cards and for
 	 * 5211 minipci cards.  Users can also manually enable/disable
 	 * support with a sysctl.
 	 */
 	sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID);
 	ath_led_config(sc);
 	ath_hal_setledstate(ah, HAL_LED_INIT);
 
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
 	ifp->if_start = ath_start_queue;
 	ifp->if_ioctl = ath_ioctl;
 	ifp->if_init = ath_init;
 	IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
 	ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
 	IFQ_SET_READY(&ifp->if_snd);
 
 	ic->ic_ifp = ifp;
 	/* XXX not right but it's not used anywhere important */
 	ic->ic_phytype = IEEE80211_T_OFDM;
 	ic->ic_opmode = IEEE80211_M_STA;
 	ic->ic_caps =
 		  IEEE80211_C_STA		/* station mode */
 		| IEEE80211_C_IBSS		/* ibss, nee adhoc, mode */
 		| IEEE80211_C_HOSTAP		/* hostap mode */
 		| IEEE80211_C_MONITOR		/* monitor mode */
 		| IEEE80211_C_AHDEMO		/* adhoc demo mode */
 		| IEEE80211_C_WDS		/* 4-address traffic works */
 		| IEEE80211_C_MBSS		/* mesh point link mode */
 		| IEEE80211_C_SHPREAMBLE	/* short preamble supported */
 		| IEEE80211_C_SHSLOT		/* short slot time supported */
 		| IEEE80211_C_WPA		/* capable of WPA1+WPA2 */
 #ifndef	ATH_ENABLE_11N
 		| IEEE80211_C_BGSCAN		/* capable of bg scanning */
 #endif
 		| IEEE80211_C_TXFRAG		/* handle tx frags */
 #ifdef	ATH_ENABLE_DFS
 		| IEEE80211_C_DFS		/* Enable radar detection */
 #endif
 		;
 	/*
 	 * Query the hal to figure out h/w crypto support.
 	 */
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_WEP))
 		ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_OCB))
 		ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_OCB;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_AES_CCM))
 		ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_CCM;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_CKIP))
 		ic->ic_cryptocaps |= IEEE80211_CRYPTO_CKIP;
 	if (ath_hal_ciphersupported(ah, HAL_CIPHER_TKIP)) {
 		ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIP;
 		/*
 		 * Check if h/w does the MIC and/or whether the
 		 * separate key cache entries are required to
 		 * handle both tx+rx MIC keys.
 		 */
 		if (ath_hal_ciphersupported(ah, HAL_CIPHER_MIC))
 			ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC;
 		/*
 		 * If the h/w supports storing tx+rx MIC keys
 		 * in one cache slot automatically enable use.
 		 */
 		if (ath_hal_hastkipsplit(ah) ||
 		    !ath_hal_settkipsplit(ah, AH_FALSE))
 			sc->sc_splitmic = 1;
 		/*
 		 * If the h/w can do TKIP MIC together with WME then
 		 * we use it; otherwise we force the MIC to be done
 		 * in software by the net80211 layer.
 		 */
 		if (ath_hal_haswmetkipmic(ah))
 			sc->sc_wmetkipmic = 1;
 	}
 	sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR);
 	/*
 	 * Check for multicast key search support.
 	 */
 	if (ath_hal_hasmcastkeysearch(sc->sc_ah) &&
 	    !ath_hal_getmcastkeysearch(sc->sc_ah)) {
 		ath_hal_setmcastkeysearch(sc->sc_ah, 1);
 	}
 	sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah);
 	/*
 	 * Mark key cache slots associated with global keys
 	 * as in use.  If we knew TKIP was not to be used we
 	 * could leave the +32, +64, and +32+64 slots free.
 	 */
 	for (i = 0; i < IEEE80211_WEP_NKID; i++) {
 		setbit(sc->sc_keymap, i);
 		setbit(sc->sc_keymap, i+64);
 		if (sc->sc_splitmic) {
 			setbit(sc->sc_keymap, i+32);
 			setbit(sc->sc_keymap, i+32+64);
 		}
 	}
 	/*
 	 * TPC support can be done either with a global cap or
 	 * per-packet support.  The latter is not available on
 	 * all parts.  We're a bit pedantic here as all parts
 	 * support a global cap.
 	 */
 	if (ath_hal_hastpc(ah) || ath_hal_hastxpowlimit(ah))
 		ic->ic_caps |= IEEE80211_C_TXPMGT;
 
 	/*
 	 * Mark WME capability only if we have sufficient
 	 * hardware queues to do proper priority scheduling.
 	 */
 	if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK])
 		ic->ic_caps |= IEEE80211_C_WME;
 	/*
 	 * Check for misc other capabilities.
 	 */
 	if (ath_hal_hasbursting(ah))
 		ic->ic_caps |= IEEE80211_C_BURST;
 	sc->sc_hasbmask = ath_hal_hasbssidmask(ah);
 	sc->sc_hasbmatch = ath_hal_hasbssidmatch(ah);
 	sc->sc_hastsfadd = ath_hal_hastsfadjust(ah);
 	sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah);
 	sc->sc_rxtsf32 = ath_hal_has_long_rxdesc_tsf(ah);
 	if (ath_hal_hasfastframes(ah))
 		ic->ic_caps |= IEEE80211_C_FF;
 	wmodes = ath_hal_getwirelessmodes(ah);
 	if (wmodes & (HAL_MODE_108G|HAL_MODE_TURBO))
 		ic->ic_caps |= IEEE80211_C_TURBOP;
 #ifdef IEEE80211_SUPPORT_TDMA
 	if (ath_hal_macversion(ah) > 0x78) {
 		ic->ic_caps |= IEEE80211_C_TDMA; /* capable of TDMA */
 		ic->ic_tdma_update = ath_tdma_update;
 	}
 #endif
 
 	/*
 	 * TODO: enforce that at least this many frames are available
 	 * in the txbuf list before allowing data frames (raw or
 	 * otherwise) to be transmitted.
 	 */
 	sc->sc_txq_data_minfree = 10;
 	/*
 	 * Leave this as default to maintain legacy behaviour.
 	 * Shortening the cabq/mcastq may end up causing some
 	 * undesirable behaviour.
 	 */
 	sc->sc_txq_mcastq_maxdepth = ath_txbuf;
 
 	/* Enable CABQ by default */
 	sc->sc_cabq_enable = 1;
 
 	/*
 	 * Allow the TX and RX chainmasks to be overridden by
 	 * environment variables and/or device.hints.
 	 *
 	 * This must be done early - before the hardware is
 	 * calibrated or before the 802.11n stream calculation
 	 * is done.
 	 */
 	if (resource_int_value(device_get_name(sc->sc_dev),
 	    device_get_unit(sc->sc_dev), "rx_chainmask",
 	    &rx_chainmask) == 0) {
 		device_printf(sc->sc_dev, "Setting RX chainmask to 0x%x\n",
 		    rx_chainmask);
 		(void) ath_hal_setrxchainmask(sc->sc_ah, rx_chainmask);
 	}
 	if (resource_int_value(device_get_name(sc->sc_dev),
 	    device_get_unit(sc->sc_dev), "tx_chainmask",
 	    &tx_chainmask) == 0) {
 		device_printf(sc->sc_dev, "Setting TX chainmask to 0x%x\n",
 		    tx_chainmask);
 		(void) ath_hal_settxchainmask(sc->sc_ah, tx_chainmask);
 	}
 
 	/*
+	 * Query the TX/RX chainmask configuration.
+	 *
+	 * This is only relevant for 11n devices.
+	 */
+	ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask);
+	ath_hal_gettxchainmask(ah, &sc->sc_txchainmask);
+
+	/*
 	 * Disable MRR with protected frames by default.
 	 * Only 802.11n series NICs can handle this.
 	 */
 	sc->sc_mrrprot = 0;	/* XXX should be a capability */
 
 	/*
 	 * Query the enterprise mode information the HAL.
 	 */
 	if (ath_hal_getcapability(ah, HAL_CAP_ENTERPRISE_MODE, 0,
 	    &sc->sc_ent_cfg) == HAL_OK)
 		sc->sc_use_ent = 1;
 
 #ifdef	ATH_ENABLE_11N
 	/*
 	 * Query HT capabilities
 	 */
 	if (ath_hal_getcapability(ah, HAL_CAP_HT, 0, NULL) == HAL_OK &&
 	    (wmodes & (HAL_MODE_HT20 | HAL_MODE_HT40))) {
 		uint32_t rxs, txs;
 
 		device_printf(sc->sc_dev, "[HT] enabling HT modes\n");
 
 		sc->sc_mrrprot = 1;	/* XXX should be a capability */
 
 		ic->ic_htcaps = IEEE80211_HTC_HT	/* HT operation */
 			    | IEEE80211_HTC_AMPDU	/* A-MPDU tx/rx */
 			    | IEEE80211_HTC_AMSDU	/* A-MSDU tx/rx */
 			    | IEEE80211_HTCAP_MAXAMSDU_3839
 			    				/* max A-MSDU length */
 			    | IEEE80211_HTCAP_SMPS_OFF;	/* SM power save off */
 			;
 
 		/*
 		 * Enable short-GI for HT20 only if the hardware
 		 * advertises support.
 		 * Notably, anything earlier than the AR9287 doesn't.
 		 */
 		if ((ath_hal_getcapability(ah,
 		    HAL_CAP_HT20_SGI, 0, NULL) == HAL_OK) &&
 		    (wmodes & HAL_MODE_HT20)) {
 			device_printf(sc->sc_dev,
 			    "[HT] enabling short-GI in 20MHz mode\n");
 			ic->ic_htcaps |= IEEE80211_HTCAP_SHORTGI20;
 		}
 
 		if (wmodes & HAL_MODE_HT40)
 			ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40
 			    |  IEEE80211_HTCAP_SHORTGI40;
 
 		/*
 		 * TX/RX streams need to be taken into account when
 		 * negotiating which MCS rates it'll receive and
 		 * what MCS rates are available for TX.
 		 */
 		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 0, &txs);
 		(void) ath_hal_getcapability(ah, HAL_CAP_STREAMS, 1, &rxs);
-
-		ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask);
-		ath_hal_gettxchainmask(ah, &sc->sc_txchainmask);
-
-		device_printf(sc->sc_dev, "Chainmasks: TX=0x%x; RX=0x%x\n",
-		    sc->sc_txchainmask,
-		    sc->sc_rxchainmask);
-
 		ic->ic_txstream = txs;
 		ic->ic_rxstream = rxs;
 
 		/*
 		 * Setup TX and RX STBC based on what the HAL allows and
 		 * the currently configured chainmask set.
 		 * Ie - don't enable STBC TX if only one chain is enabled.
 		 * STBC RX is fine on a single RX chain; it just won't
 		 * provide any real benefit.
 		 */
 		if (ath_hal_getcapability(ah, HAL_CAP_RX_STBC, 0,
 		    NULL) == HAL_OK) {
 			sc->sc_rx_stbc = 1;
 			device_printf(sc->sc_dev,
 			    "[HT] 1 stream STBC receive enabled\n");
 			ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_1STREAM;
 		}
 		if (txs > 1 && ath_hal_getcapability(ah, HAL_CAP_TX_STBC, 0,
 		    NULL) == HAL_OK) {
 			sc->sc_tx_stbc = 1;
 			device_printf(sc->sc_dev,
 			    "[HT] 1 stream STBC transmit enabled\n");
 			ic->ic_htcaps |= IEEE80211_HTCAP_TXSTBC;
 		}
 
 		(void) ath_hal_getcapability(ah, HAL_CAP_RTS_AGGR_LIMIT, 1,
 		    &sc->sc_rts_aggr_limit);
 		if (sc->sc_rts_aggr_limit != (64 * 1024))
 			device_printf(sc->sc_dev,
 			    "[HT] RTS aggregates limited to %d KiB\n",
 			    sc->sc_rts_aggr_limit / 1024);
 
 		device_printf(sc->sc_dev,
 		    "[HT] %d RX streams; %d TX streams\n", rxs, txs);
 	}
 #endif
 
 	/*
 	 * Initial aggregation settings.
 	 */
 	sc->sc_hwq_limit = ATH_AGGR_MIN_QDEPTH;
 	sc->sc_tid_hwq_lo = ATH_AGGR_SCHED_LOW;
 	sc->sc_tid_hwq_hi = ATH_AGGR_SCHED_HIGH;
 	sc->sc_aggr_limit = ATH_AGGR_MAXSIZE;
 	sc->sc_delim_min_pad = 0;
 
 	/*
 	 * Check if the hardware requires PCI register serialisation.
 	 * Some of the Owl based MACs require this.
 	 */
 	if (mp_ncpus > 1 &&
 	    ath_hal_getcapability(ah, HAL_CAP_SERIALISE_WAR,
 	     0, NULL) == HAL_OK) {
 		sc->sc_ah->ah_config.ah_serialise_reg_war = 1;
 		device_printf(sc->sc_dev,
 		    "Enabling register serialisation\n");
 	}
 
 	/*
 	 * Initialise the deferred completed RX buffer list.
 	 */
 	TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_HP]);
 	TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_LP]);
 
 	/*
 	 * Indicate we need the 802.11 header padded to a
 	 * 32-bit boundary for 4-address and QoS frames.
 	 */
 	ic->ic_flags |= IEEE80211_F_DATAPAD;
 
 	/*
 	 * Query the hal about antenna support.
 	 */
 	sc->sc_defant = ath_hal_getdefantenna(ah);
 
 	/*
 	 * Not all chips have the VEOL support we want to
 	 * use with IBSS beacons; check here for it.
 	 */
 	sc->sc_hasveol = ath_hal_hasveol(ah);
 
 	/* get mac address from hardware */
 	ath_hal_getmac(ah, macaddr);
 	if (sc->sc_hasbmask)
 		ath_hal_getbssidmask(ah, sc->sc_hwbssidmask);
 
 	/* NB: used to size node table key mapping array */
 	ic->ic_max_keyix = sc->sc_keymax;
 	/* call MI attach routine. */
 	ieee80211_ifattach(ic, macaddr);
 	ic->ic_setregdomain = ath_setregdomain;
 	ic->ic_getradiocaps = ath_getradiocaps;
 	sc->sc_opmode = HAL_M_STA;
 
 	/* override default methods */
 	ic->ic_newassoc = ath_newassoc;
 	ic->ic_updateslot = ath_updateslot;
 	ic->ic_wme.wme_update = ath_wme_update;
 	ic->ic_vap_create = ath_vap_create;
 	ic->ic_vap_delete = ath_vap_delete;
 	ic->ic_raw_xmit = ath_raw_xmit;
 	ic->ic_update_mcast = ath_update_mcast;
 	ic->ic_update_promisc = ath_update_promisc;
 	ic->ic_node_alloc = ath_node_alloc;
 	sc->sc_node_free = ic->ic_node_free;
 	ic->ic_node_free = ath_node_free;
 	sc->sc_node_cleanup = ic->ic_node_cleanup;
 	ic->ic_node_cleanup = ath_node_cleanup;
 	ic->ic_node_getsignal = ath_node_getsignal;
 	ic->ic_scan_start = ath_scan_start;
 	ic->ic_scan_end = ath_scan_end;
 	ic->ic_set_channel = ath_set_channel;
 #ifdef	ATH_ENABLE_11N
 	/* 802.11n specific - but just override anyway */
 	sc->sc_addba_request = ic->ic_addba_request;
 	sc->sc_addba_response = ic->ic_addba_response;
 	sc->sc_addba_stop = ic->ic_addba_stop;
 	sc->sc_bar_response = ic->ic_bar_response;
 	sc->sc_addba_response_timeout = ic->ic_addba_response_timeout;
 
 	ic->ic_addba_request = ath_addba_request;
 	ic->ic_addba_response = ath_addba_response;
 	ic->ic_addba_response_timeout = ath_addba_response_timeout;
 	ic->ic_addba_stop = ath_addba_stop;
 	ic->ic_bar_response = ath_bar_response;
 
 	ic->ic_update_chw = ath_update_chw;
 #endif	/* ATH_ENABLE_11N */
 
 #ifdef	ATH_ENABLE_RADIOTAP_VENDOR_EXT
 	/*
 	 * There's one vendor bitmap entry in the RX radiotap
 	 * header; make sure that's taken into account.
 	 */
 	ieee80211_radiotap_attachv(ic,
 	    &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 0,
 		ATH_TX_RADIOTAP_PRESENT,
 	    &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 1,
 		ATH_RX_RADIOTAP_PRESENT);
 #else
 	/*
 	 * No vendor bitmap/extensions are present.
 	 */
 	ieee80211_radiotap_attach(ic,
 	    &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th),
 		ATH_TX_RADIOTAP_PRESENT,
 	    &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th),
 		ATH_RX_RADIOTAP_PRESENT);
 #endif	/* ATH_ENABLE_RADIOTAP_VENDOR_EXT */
 
 	/*
 	 * Setup the ALQ logging if required
 	 */
 #ifdef	ATH_DEBUG_ALQ
 	if_ath_alq_init(&sc->sc_alq, device_get_nameunit(sc->sc_dev));
 	if_ath_alq_setcfg(&sc->sc_alq,
 	    sc->sc_ah->ah_macVersion,
 	    sc->sc_ah->ah_macRev,
 	    sc->sc_ah->ah_phyRev,
 	    sc->sc_ah->ah_magic);
 #endif
 
 	/*
 	 * Setup dynamic sysctl's now that country code and
 	 * regdomain are available from the hal.
 	 */
 	ath_sysctlattach(sc);
 	ath_sysctl_stats_attach(sc);
 	ath_sysctl_hal_attach(sc);
 
 	if (bootverbose)
 		ieee80211_announce(ic);
 	ath_announce(sc);
 	return 0;
 bad2:
 	ath_tx_cleanup(sc);
 	ath_desc_free(sc);
 	ath_txdma_teardown(sc);
 	ath_rxdma_teardown(sc);
 bad:
 	if (ah)
 		ath_hal_detach(ah);
 
 	/*
 	 * To work around scoping issues with CURVNET_SET/CURVNET_RESTORE..
 	 */
 	if (ifp != NULL && ifp->if_vnet) {
 		CURVNET_SET(ifp->if_vnet);
 		if_free(ifp);
 		CURVNET_RESTORE();
 	} else if (ifp != NULL)
 		if_free(ifp);
 	sc->sc_invalid = 1;
 	return error;
 }
 
 int
 ath_detach(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
 	/*
 	 * NB: the order of these is important:
 	 * o stop the chip so no more interrupts will fire
 	 * o call the 802.11 layer before detaching the hal to
 	 *   insure callbacks into the driver to delete global
 	 *   key cache entries can be handled
 	 * o free the taskqueue which drains any pending tasks
 	 * o reclaim the tx queue data structures after calling
 	 *   the 802.11 layer as we'll get called back to reclaim
 	 *   node state and potentially want to use them
 	 * o to cleanup the tx queues the hal is called, so detach
 	 *   it last
 	 * Other than that, it's straightforward...
 	 */
 	ath_stop(ifp);
 	ieee80211_ifdetach(ifp->if_l2com);
 	taskqueue_free(sc->sc_tq);
 #ifdef ATH_TX99_DIAG
 	if (sc->sc_tx99 != NULL)
 		sc->sc_tx99->detach(sc->sc_tx99);
 #endif
 	ath_rate_detach(sc->sc_rc);
 #ifdef	ATH_DEBUG_ALQ
 	if_ath_alq_tidyup(&sc->sc_alq);
 #endif
 	ath_spectral_detach(sc);
 	ath_dfs_detach(sc);
 	ath_desc_free(sc);
 	ath_txdma_teardown(sc);
 	ath_rxdma_teardown(sc);
 	ath_tx_cleanup(sc);
 	ath_hal_detach(sc->sc_ah);	/* NB: sets chip in full sleep */
 
 	CURVNET_SET(ifp->if_vnet);
 	if_free(ifp);
 	CURVNET_RESTORE();
 
 	return 0;
 }
 
 /*
  * MAC address handling for multiple BSS on the same radio.
  * The first vap uses the MAC address from the EEPROM.  For
  * subsequent vap's we set the U/L bit (bit 1) in the MAC
  * address and use the next six bits as an index.
  */
 static void
 assign_address(struct ath_softc *sc, uint8_t mac[IEEE80211_ADDR_LEN], int clone)
 {
 	int i;
 
 	if (clone && sc->sc_hasbmask) {
 		/* NB: we only do this if h/w supports multiple bssid */
 		for (i = 0; i < 8; i++)
 			if ((sc->sc_bssidmask & (1<sc_bssidmask |= 1<sc_hwbssidmask[0] &= ~mac[0];
 	if (i == 0)
 		sc->sc_nbssid0++;
 }
 
 static void
 reclaim_address(struct ath_softc *sc, const uint8_t mac[IEEE80211_ADDR_LEN])
 {
 	int i = mac[0] >> 2;
 	uint8_t mask;
 
 	if (i != 0 || --sc->sc_nbssid0 == 0) {
 		sc->sc_bssidmask &= ~(1<sc_bssidmask & (1<sc_hwbssidmask[0] |= mask;
 	}
 }
 
 /*
  * Assign a beacon xmit slot.  We try to space out
  * assignments so when beacons are staggered the
  * traffic coming out of the cab q has maximal time
  * to go out before the next beacon is scheduled.
  */
 static int
 assign_bslot(struct ath_softc *sc)
 {
 	u_int slot, free;
 
 	free = 0;
 	for (slot = 0; slot < ATH_BCBUF; slot++)
 		if (sc->sc_bslot[slot] == NULL) {
 			if (sc->sc_bslot[(slot+1)%ATH_BCBUF] == NULL &&
 			    sc->sc_bslot[(slot-1)%ATH_BCBUF] == NULL)
 				return slot;
 			free = slot;
 			/* NB: keep looking for a double slot */
 		}
 	return free;
 }
 
 static struct ieee80211vap *
 ath_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
     enum ieee80211_opmode opmode, int flags,
     const uint8_t bssid[IEEE80211_ADDR_LEN],
     const uint8_t mac0[IEEE80211_ADDR_LEN])
 {
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_vap *avp;
 	struct ieee80211vap *vap;
 	uint8_t mac[IEEE80211_ADDR_LEN];
 	int needbeacon, error;
 	enum ieee80211_opmode ic_opmode;
 
 	avp = (struct ath_vap *) malloc(sizeof(struct ath_vap),
 	    M_80211_VAP, M_WAITOK | M_ZERO);
 	needbeacon = 0;
 	IEEE80211_ADDR_COPY(mac, mac0);
 
 	ATH_LOCK(sc);
 	ic_opmode = opmode;		/* default to opmode of new vap */
 	switch (opmode) {
 	case IEEE80211_M_STA:
 		if (sc->sc_nstavaps != 0) {	/* XXX only 1 for now */
 			device_printf(sc->sc_dev, "only 1 sta vap supported\n");
 			goto bad;
 		}
 		if (sc->sc_nvaps) {
 			/*
 			 * With multiple vaps we must fall back
 			 * to s/w beacon miss handling.
 			 */
 			flags |= IEEE80211_CLONE_NOBEACONS;
 		}
 		if (flags & IEEE80211_CLONE_NOBEACONS) {
 			/*
 			 * Station mode w/o beacons are implemented w/ AP mode.
 			 */
 			ic_opmode = IEEE80211_M_HOSTAP;
 		}
 		break;
 	case IEEE80211_M_IBSS:
 		if (sc->sc_nvaps != 0) {	/* XXX only 1 for now */
 			device_printf(sc->sc_dev,
 			    "only 1 ibss vap supported\n");
 			goto bad;
 		}
 		needbeacon = 1;
 		break;
 	case IEEE80211_M_AHDEMO:
 #ifdef IEEE80211_SUPPORT_TDMA
 		if (flags & IEEE80211_CLONE_TDMA) {
 			if (sc->sc_nvaps != 0) {
 				device_printf(sc->sc_dev,
 				    "only 1 tdma vap supported\n");
 				goto bad;
 			}
 			needbeacon = 1;
 			flags |= IEEE80211_CLONE_NOBEACONS;
 		}
 		/* fall thru... */
 #endif
 	case IEEE80211_M_MONITOR:
 		if (sc->sc_nvaps != 0 && ic->ic_opmode != opmode) {
 			/*
 			 * Adopt existing mode.  Adding a monitor or ahdemo
 			 * vap to an existing configuration is of dubious
 			 * value but should be ok.
 			 */
 			/* XXX not right for monitor mode */
 			ic_opmode = ic->ic_opmode;
 		}
 		break;
 	case IEEE80211_M_HOSTAP:
 	case IEEE80211_M_MBSS:
 		needbeacon = 1;
 		break;
 	case IEEE80211_M_WDS:
 		if (sc->sc_nvaps != 0 && ic->ic_opmode == IEEE80211_M_STA) {
 			device_printf(sc->sc_dev,
 			    "wds not supported in sta mode\n");
 			goto bad;
 		}
 		/*
 		 * Silently remove any request for a unique
 		 * bssid; WDS vap's always share the local
 		 * mac address.
 		 */
 		flags &= ~IEEE80211_CLONE_BSSID;
 		if (sc->sc_nvaps == 0)
 			ic_opmode = IEEE80211_M_HOSTAP;
 		else
 			ic_opmode = ic->ic_opmode;
 		break;
 	default:
 		device_printf(sc->sc_dev, "unknown opmode %d\n", opmode);
 		goto bad;
 	}
 	/*
 	 * Check that a beacon buffer is available; the code below assumes it.
 	 */
 	if (needbeacon & TAILQ_EMPTY(&sc->sc_bbuf)) {
 		device_printf(sc->sc_dev, "no beacon buffer available\n");
 		goto bad;
 	}
 
 	/* STA, AHDEMO? */
 	if (opmode == IEEE80211_M_HOSTAP || opmode == IEEE80211_M_MBSS) {
 		assign_address(sc, mac, flags & IEEE80211_CLONE_BSSID);
 		ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask);
 	}
 
 	vap = &avp->av_vap;
 	/* XXX can't hold mutex across if_alloc */
 	ATH_UNLOCK(sc);
 	error = ieee80211_vap_setup(ic, vap, name, unit, opmode, flags,
 	    bssid, mac);
 	ATH_LOCK(sc);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "%s: error %d creating vap\n",
 		    __func__, error);
 		goto bad2;
 	}
 
 	/* h/w crypto support */
 	vap->iv_key_alloc = ath_key_alloc;
 	vap->iv_key_delete = ath_key_delete;
 	vap->iv_key_set = ath_key_set;
 	vap->iv_key_update_begin = ath_key_update_begin;
 	vap->iv_key_update_end = ath_key_update_end;
 
 	/* override various methods */
 	avp->av_recv_mgmt = vap->iv_recv_mgmt;
 	vap->iv_recv_mgmt = ath_recv_mgmt;
 	vap->iv_reset = ath_reset_vap;
 	vap->iv_update_beacon = ath_beacon_update;
 	avp->av_newstate = vap->iv_newstate;
 	vap->iv_newstate = ath_newstate;
 	avp->av_bmiss = vap->iv_bmiss;
 	vap->iv_bmiss = ath_bmiss_vap;
 
 	avp->av_node_ps = vap->iv_node_ps;
 	vap->iv_node_ps = ath_node_powersave;
 
 	avp->av_set_tim = vap->iv_set_tim;
 	vap->iv_set_tim = ath_node_set_tim;
 
 	/* Set default parameters */
 
 	/*
 	 * Anything earlier than some AR9300 series MACs don't
 	 * support a smaller MPDU density.
 	 */
 	vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_8;
 	/*
 	 * All NICs can handle the maximum size, however
 	 * AR5416 based MACs can only TX aggregates w/ RTS
 	 * protection when the total aggregate size is <= 8k.
 	 * However, for now that's enforced by the TX path.
 	 */
 	vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K;
 
 	avp->av_bslot = -1;
 	if (needbeacon) {
 		/*
 		 * Allocate beacon state and setup the q for buffered
 		 * multicast frames.  We know a beacon buffer is
 		 * available because we checked above.
 		 */
 		avp->av_bcbuf = TAILQ_FIRST(&sc->sc_bbuf);
 		TAILQ_REMOVE(&sc->sc_bbuf, avp->av_bcbuf, bf_list);
 		if (opmode != IEEE80211_M_IBSS || !sc->sc_hasveol) {
 			/*
 			 * Assign the vap to a beacon xmit slot.  As above
 			 * this cannot fail to find a free one.
 			 */
 			avp->av_bslot = assign_bslot(sc);
 			KASSERT(sc->sc_bslot[avp->av_bslot] == NULL,
 			    ("beacon slot %u not empty", avp->av_bslot));
 			sc->sc_bslot[avp->av_bslot] = vap;
 			sc->sc_nbcnvaps++;
 		}
 		if (sc->sc_hastsfadd && sc->sc_nbcnvaps > 0) {
 			/*
 			 * Multple vaps are to transmit beacons and we
 			 * have h/w support for TSF adjusting; enable
 			 * use of staggered beacons.
 			 */
 			sc->sc_stagbeacons = 1;
 		}
 		ath_txq_init(sc, &avp->av_mcastq, ATH_TXQ_SWQ);
 	}
 
 	ic->ic_opmode = ic_opmode;
 	if (opmode != IEEE80211_M_WDS) {
 		sc->sc_nvaps++;
 		if (opmode == IEEE80211_M_STA)
 			sc->sc_nstavaps++;
 		if (opmode == IEEE80211_M_MBSS)
 			sc->sc_nmeshvaps++;
 	}
 	switch (ic_opmode) {
 	case IEEE80211_M_IBSS:
 		sc->sc_opmode = HAL_M_IBSS;
 		break;
 	case IEEE80211_M_STA:
 		sc->sc_opmode = HAL_M_STA;
 		break;
 	case IEEE80211_M_AHDEMO:
 #ifdef IEEE80211_SUPPORT_TDMA
 		if (vap->iv_caps & IEEE80211_C_TDMA) {
 			sc->sc_tdma = 1;
 			/* NB: disable tsf adjust */
 			sc->sc_stagbeacons = 0;
 		}
 		/*
 		 * NB: adhoc demo mode is a pseudo mode; to the hal it's
 		 * just ap mode.
 		 */
 		/* fall thru... */
 #endif
 	case IEEE80211_M_HOSTAP:
 	case IEEE80211_M_MBSS:
 		sc->sc_opmode = HAL_M_HOSTAP;
 		break;
 	case IEEE80211_M_MONITOR:
 		sc->sc_opmode = HAL_M_MONITOR;
 		break;
 	default:
 		/* XXX should not happen */
 		break;
 	}
 	if (sc->sc_hastsfadd) {
 		/*
 		 * Configure whether or not TSF adjust should be done.
 		 */
 		ath_hal_settsfadjust(sc->sc_ah, sc->sc_stagbeacons);
 	}
 	if (flags & IEEE80211_CLONE_NOBEACONS) {
 		/*
 		 * Enable s/w beacon miss handling.
 		 */
 		sc->sc_swbmiss = 1;
 	}
 	ATH_UNLOCK(sc);
 
 	/* complete setup */
 	ieee80211_vap_attach(vap, ath_media_change, ieee80211_media_status);
 	return vap;
 bad2:
 	reclaim_address(sc, mac);
 	ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask);
 bad:
 	free(avp, M_80211_VAP);
 	ATH_UNLOCK(sc);
 	return NULL;
 }
 
 static void
 ath_vap_delete(struct ieee80211vap *vap)
 {
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 	struct ath_vap *avp = ATH_VAP(vap);
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__);
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 		/*
 		 * Quiesce the hardware while we remove the vap.  In
 		 * particular we need to reclaim all references to
 		 * the vap state by any frames pending on the tx queues.
 		 */
 		ath_hal_intrset(ah, 0);		/* disable interrupts */
 		ath_draintxq(sc, ATH_RESET_DEFAULT);		/* stop hw xmit side */
 		/* XXX Do all frames from all vaps/nodes need draining here? */
 		ath_stoprecv(sc, 1);		/* stop recv side */
 	}
 
 	ieee80211_vap_detach(vap);
 
 	/*
 	 * XXX Danger Will Robinson! Danger!
 	 *
 	 * Because ieee80211_vap_detach() can queue a frame (the station
 	 * diassociate message?) after we've drained the TXQ and
 	 * flushed the software TXQ, we will end up with a frame queued
 	 * to a node whose vap is about to be freed.
 	 *
 	 * To work around this, flush the hardware/software again.
 	 * This may be racy - the ath task may be running and the packet
 	 * may be being scheduled between sw->hw txq. Tsk.
 	 *
 	 * TODO: figure out why a new node gets allocated somewhere around
 	 * here (after the ath_tx_swq() call; and after an ath_stop_locked()
 	 * call!)
 	 */
 
 	ath_draintxq(sc, ATH_RESET_DEFAULT);
 
 	ATH_LOCK(sc);
 	/*
 	 * Reclaim beacon state.  Note this must be done before
 	 * the vap instance is reclaimed as we may have a reference
 	 * to it in the buffer for the beacon frame.
 	 */
 	if (avp->av_bcbuf != NULL) {
 		if (avp->av_bslot != -1) {
 			sc->sc_bslot[avp->av_bslot] = NULL;
 			sc->sc_nbcnvaps--;
 		}
 		ath_beacon_return(sc, avp->av_bcbuf);
 		avp->av_bcbuf = NULL;
 		if (sc->sc_nbcnvaps == 0) {
 			sc->sc_stagbeacons = 0;
 			if (sc->sc_hastsfadd)
 				ath_hal_settsfadjust(sc->sc_ah, 0);
 		}
 		/*
 		 * Reclaim any pending mcast frames for the vap.
 		 */
 		ath_tx_draintxq(sc, &avp->av_mcastq);
 	}
 	/*
 	 * Update bookkeeping.
 	 */
 	if (vap->iv_opmode == IEEE80211_M_STA) {
 		sc->sc_nstavaps--;
 		if (sc->sc_nstavaps == 0 && sc->sc_swbmiss)
 			sc->sc_swbmiss = 0;
 	} else if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
 	    vap->iv_opmode == IEEE80211_M_MBSS) {
 		reclaim_address(sc, vap->iv_myaddr);
 		ath_hal_setbssidmask(ah, sc->sc_hwbssidmask);
 		if (vap->iv_opmode == IEEE80211_M_MBSS)
 			sc->sc_nmeshvaps--;
 	}
 	if (vap->iv_opmode != IEEE80211_M_WDS)
 		sc->sc_nvaps--;
 #ifdef IEEE80211_SUPPORT_TDMA
 	/* TDMA operation ceases when the last vap is destroyed */
 	if (sc->sc_tdma && sc->sc_nvaps == 0) {
 		sc->sc_tdma = 0;
 		sc->sc_swbmiss = 0;
 	}
 #endif
 	free(avp, M_80211_VAP);
 
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 		/*
 		 * Restart rx+tx machines if still running (RUNNING will
 		 * be reset if we just destroyed the last vap).
 		 */
 		if (ath_startrecv(sc) != 0)
 			if_printf(ifp, "%s: unable to restart recv logic\n",
 			    __func__);
 		if (sc->sc_beacons) {		/* restart beacons */
 #ifdef IEEE80211_SUPPORT_TDMA
 			if (sc->sc_tdma)
 				ath_tdma_config(sc, NULL);
 			else
 #endif
 				ath_beacon_config(sc, NULL);
 		}
 		ath_hal_intrset(ah, sc->sc_imask);
 	}
 	ATH_UNLOCK(sc);
 }
 
 void
 ath_suspend(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
 	sc->sc_resume_up = (ifp->if_flags & IFF_UP) != 0;
 
 	ieee80211_suspend_all(ic);
 	/*
 	 * NB: don't worry about putting the chip in low power
 	 * mode; pci will power off our socket on suspend and
 	 * CardBus detaches the device.
 	 */
 
 	/*
 	 * XXX ensure none of the taskqueues are running
 	 * XXX ensure sc_invalid is 1
 	 * XXX ensure the calibration callout is disabled
 	 */
 
 	/* Disable the PCIe PHY, complete with workarounds */
 	ath_hal_enablepcie(sc->sc_ah, 1, 1);
 }
 
 /*
  * Reset the key cache since some parts do not reset the
  * contents on resume.  First we clear all entries, then
  * re-load keys that the 802.11 layer assumes are setup
  * in h/w.
  */
 static void
 ath_reset_keycache(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	int i;
 
 	for (i = 0; i < sc->sc_keymax; i++)
 		ath_hal_keyreset(ah, i);
 	ieee80211_crypto_reload_keys(ic);
 }
 
 /*
  * Fetch the current chainmask configuration based on the current
  * operating channel and options.
  */
 static void
 ath_update_chainmasks(struct ath_softc *sc, struct ieee80211_channel *chan)
 {
 
 	/*
 	 * Set TX chainmask to the currently configured chainmask;
 	 * the TX chainmask depends upon the current operating mode.
 	 */
 	sc->sc_cur_rxchainmask = sc->sc_rxchainmask;
 	if (IEEE80211_IS_CHAN_HT(chan)) {
 		sc->sc_cur_txchainmask = sc->sc_txchainmask;
 	} else {
 		sc->sc_cur_txchainmask = 1;
 	}
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: TX chainmask is now 0x%x, RX is now 0x%x\n",
 	    __func__,
 	    sc->sc_cur_txchainmask,
 	    sc->sc_cur_rxchainmask);
 }
 
 void
 ath_resume(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_STATUS status;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
 	/* Re-enable PCIe, re-enable the PCIe bus */
 	ath_hal_enablepcie(ah, 0, 0);
 
 	/*
 	 * Must reset the chip before we reload the
 	 * keycache as we were powered down on suspend.
 	 */
 	ath_update_chainmasks(sc,
 	    sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan);
 	ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
 	    sc->sc_cur_rxchainmask);
 	ath_hal_reset(ah, sc->sc_opmode,
 	    sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan,
 	    AH_FALSE, &status);
 	ath_reset_keycache(sc);
 
 	/* Let DFS at it in case it's a DFS channel */
 	ath_dfs_radar_enable(sc, ic->ic_curchan);
 
 	/* Let spectral at in case spectral is enabled */
 	ath_spectral_enable(sc, ic->ic_curchan);
 
 	/* Restore the LED configuration */
 	ath_led_config(sc);
 	ath_hal_setledstate(ah, HAL_LED_INIT);
 
 	if (sc->sc_resume_up)
 		ieee80211_resume_all(ic);
 
 	/* XXX beacons ? */
 }
 
 void
 ath_shutdown(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
 		__func__, ifp->if_flags);
 
 	ath_stop(ifp);
 	/* NB: no point powering down chip as we're about to reboot */
 }
 
 /*
  * Interrupt handler.  Most of the actual processing is deferred.
  */
 void
 ath_intr(void *arg)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_INT status = 0;
 	uint32_t txqs;
 
 	/*
 	 * If we're inside a reset path, just print a warning and
 	 * clear the ISR. The reset routine will finish it for us.
 	 */
 	ATH_PCU_LOCK(sc);
 	if (sc->sc_inreset_cnt) {
 		HAL_INT status;
 		ath_hal_getisr(ah, &status);	/* clear ISR */
 		ath_hal_intrset(ah, 0);		/* disable further intr's */
 		DPRINTF(sc, ATH_DEBUG_ANY,
 		    "%s: in reset, ignoring: status=0x%x\n",
 		    __func__, status);
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 
 	if (sc->sc_invalid) {
 		/*
 		 * The hardware is not ready/present, don't touch anything.
 		 * Note this can happen early on if the IRQ is shared.
 		 */
 		DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid; ignored\n", __func__);
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 	if (!ath_hal_intrpend(ah)) {		/* shared irq, not for us */
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 
 	if ((ifp->if_flags & IFF_UP) == 0 ||
 	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
 		HAL_INT status;
 
 		DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
 			__func__, ifp->if_flags);
 		ath_hal_getisr(ah, &status);	/* clear ISR */
 		ath_hal_intrset(ah, 0);		/* disable further intr's */
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 
 	/*
 	 * Figure out the reason(s) for the interrupt.  Note
 	 * that the hal returns a pseudo-ISR that may include
 	 * bits we haven't explicitly enabled so we mask the
 	 * value to insure we only process bits we requested.
 	 */
 	ath_hal_getisr(ah, &status);		/* NB: clears ISR too */
 	DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status);
 	ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1, "ath_intr: mask=0x%.8x", status);
 #ifdef	ATH_DEBUG_ALQ
 	if_ath_alq_post_intr(&sc->sc_alq, status, ah->ah_intrstate,
 	    ah->ah_syncstate);
 #endif	/* ATH_DEBUG_ALQ */
 #ifdef	ATH_KTR_INTR_DEBUG
 	ATH_KTR(sc, ATH_KTR_INTERRUPTS, 5,
 	    "ath_intr: ISR=0x%.8x, ISR_S0=0x%.8x, ISR_S1=0x%.8x, ISR_S2=0x%.8x, ISR_S5=0x%.8x",
 	    ah->ah_intrstate[0],
 	    ah->ah_intrstate[1],
 	    ah->ah_intrstate[2],
 	    ah->ah_intrstate[3],
 	    ah->ah_intrstate[6]);
 #endif
 
 	/* Squirrel away SYNC interrupt debugging */
 	if (ah->ah_syncstate != 0) {
 		int i;
 		for (i = 0; i < 32; i++)
 			if (ah->ah_syncstate & (i << i))
 				sc->sc_intr_stats.sync_intr[i]++;
 	}
 
 	status &= sc->sc_imask;			/* discard unasked for bits */
 
 	/* Short-circuit un-handled interrupts */
 	if (status == 0x0) {
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 
 	/*
 	 * Take a note that we're inside the interrupt handler, so
 	 * the reset routines know to wait.
 	 */
 	sc->sc_intr_cnt++;
 	ATH_PCU_UNLOCK(sc);
 
 	/*
 	 * Handle the interrupt. We won't run concurrent with the reset
 	 * or channel change routines as they'll wait for sc_intr_cnt
 	 * to be 0 before continuing.
 	 */
 	if (status & HAL_INT_FATAL) {
 		sc->sc_stats.ast_hardware++;
 		ath_hal_intrset(ah, 0);		/* disable intr's until reset */
 		taskqueue_enqueue(sc->sc_tq, &sc->sc_fataltask);
 	} else {
 		if (status & HAL_INT_SWBA) {
 			/*
 			 * Software beacon alert--time to send a beacon.
 			 * Handle beacon transmission directly; deferring
 			 * this is too slow to meet timing constraints
 			 * under load.
 			 */
 #ifdef IEEE80211_SUPPORT_TDMA
 			if (sc->sc_tdma) {
 				if (sc->sc_tdmaswba == 0) {
 					struct ieee80211com *ic = ifp->if_l2com;
 					struct ieee80211vap *vap =
 					    TAILQ_FIRST(&ic->ic_vaps);
 					ath_tdma_beacon_send(sc, vap);
 					sc->sc_tdmaswba =
 					    vap->iv_tdma->tdma_bintval;
 				} else
 					sc->sc_tdmaswba--;
 			} else
 #endif
 			{
 				ath_beacon_proc(sc, 0);
 #ifdef IEEE80211_SUPPORT_SUPERG
 				/*
 				 * Schedule the rx taskq in case there's no
 				 * traffic so any frames held on the staging
 				 * queue are aged and potentially flushed.
 				 */
 				sc->sc_rx.recv_sched(sc, 1);
 #endif
 			}
 		}
 		if (status & HAL_INT_RXEOL) {
 			int imask;
 			ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL");
 			ATH_PCU_LOCK(sc);
 			/*
 			 * NB: the hardware should re-read the link when
 			 *     RXE bit is written, but it doesn't work at
 			 *     least on older hardware revs.
 			 */
 			sc->sc_stats.ast_rxeol++;
 			/*
 			 * Disable RXEOL/RXORN - prevent an interrupt
 			 * storm until the PCU logic can be reset.
 			 * In case the interface is reset some other
 			 * way before "sc_kickpcu" is called, don't
 			 * modify sc_imask - that way if it is reset
 			 * by a call to ath_reset() somehow, the
 			 * interrupt mask will be correctly reprogrammed.
 			 */
 			imask = sc->sc_imask;
 			imask &= ~(HAL_INT_RXEOL | HAL_INT_RXORN);
 			ath_hal_intrset(ah, imask);
 			/*
 			 * Only blank sc_rxlink if we've not yet kicked
 			 * the PCU.
 			 *
 			 * This isn't entirely correct - the correct solution
 			 * would be to have a PCU lock and engage that for
 			 * the duration of the PCU fiddling; which would include
 			 * running the RX process. Otherwise we could end up
 			 * messing up the RX descriptor chain and making the
 			 * RX desc list much shorter.
 			 */
 			if (! sc->sc_kickpcu)
 				sc->sc_rxlink = NULL;
 			sc->sc_kickpcu = 1;
 			ATH_PCU_UNLOCK(sc);
 			/*
 			 * Enqueue an RX proc, to handled whatever
 			 * is in the RX queue.
 			 * This will then kick the PCU.
 			 */
 			sc->sc_rx.recv_sched(sc, 1);
 		}
 		if (status & HAL_INT_TXURN) {
 			sc->sc_stats.ast_txurn++;
 			/* bump tx trigger level */
 			ath_hal_updatetxtriglevel(ah, AH_TRUE);
 		}
 		/*
 		 * Handle both the legacy and RX EDMA interrupt bits.
 		 * Note that HAL_INT_RXLP is also HAL_INT_RXDESC.
 		 */
 		if (status & (HAL_INT_RX | HAL_INT_RXHP | HAL_INT_RXLP)) {
 			sc->sc_stats.ast_rx_intr++;
 			sc->sc_rx.recv_sched(sc, 1);
 		}
 		if (status & HAL_INT_TX) {
 			sc->sc_stats.ast_tx_intr++;
 			/*
 			 * Grab all the currently set bits in the HAL txq bitmap
 			 * and blank them. This is the only place we should be
 			 * doing this.
 			 */
 			if (! sc->sc_isedma) {
 				ATH_PCU_LOCK(sc);
 				txqs = 0xffffffff;
 				ath_hal_gettxintrtxqs(sc->sc_ah, &txqs);
 				ATH_KTR(sc, ATH_KTR_INTERRUPTS, 3,
 				    "ath_intr: TX; txqs=0x%08x, txq_active was 0x%08x, now 0x%08x",
 				    txqs,
 				    sc->sc_txq_active,
 				    sc->sc_txq_active | txqs);
 				sc->sc_txq_active |= txqs;
 				ATH_PCU_UNLOCK(sc);
 			}
 			taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask);
 		}
 		if (status & HAL_INT_BMISS) {
 			sc->sc_stats.ast_bmiss++;
 			taskqueue_enqueue(sc->sc_tq, &sc->sc_bmisstask);
 		}
 		if (status & HAL_INT_GTT)
 			sc->sc_stats.ast_tx_timeout++;
 		if (status & HAL_INT_CST)
 			sc->sc_stats.ast_tx_cst++;
 		if (status & HAL_INT_MIB) {
 			sc->sc_stats.ast_mib++;
 			ATH_PCU_LOCK(sc);
 			/*
 			 * Disable interrupts until we service the MIB
 			 * interrupt; otherwise it will continue to fire.
 			 */
 			ath_hal_intrset(ah, 0);
 			/*
 			 * Let the hal handle the event.  We assume it will
 			 * clear whatever condition caused the interrupt.
 			 */
 			ath_hal_mibevent(ah, &sc->sc_halstats);
 			/*
 			 * Don't reset the interrupt if we've just
 			 * kicked the PCU, or we may get a nested
 			 * RXEOL before the rxproc has had a chance
 			 * to run.
 			 */
 			if (sc->sc_kickpcu == 0)
 				ath_hal_intrset(ah, sc->sc_imask);
 			ATH_PCU_UNLOCK(sc);
 		}
 		if (status & HAL_INT_RXORN) {
 			/* NB: hal marks HAL_INT_FATAL when RXORN is fatal */
 			ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXORN");
 			sc->sc_stats.ast_rxorn++;
 		}
 	}
 	ATH_PCU_LOCK(sc);
 	sc->sc_intr_cnt--;
 	ATH_PCU_UNLOCK(sc);
 }
 
 static void
 ath_fatal_proc(void *arg, int pending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	u_int32_t *state;
 	u_int32_t len;
 	void *sp;
 
 	if_printf(ifp, "hardware error; resetting\n");
 	/*
 	 * Fatal errors are unrecoverable.  Typically these
 	 * are caused by DMA errors.  Collect h/w state from
 	 * the hal so we can diagnose what's going on.
 	 */
 	if (ath_hal_getfatalstate(sc->sc_ah, &sp, &len)) {
 		KASSERT(len >= 6*sizeof(u_int32_t), ("len %u bytes", len));
 		state = sp;
 		if_printf(ifp, "0x%08x 0x%08x 0x%08x, 0x%08x 0x%08x 0x%08x\n",
 		    state[0], state[1] , state[2], state[3],
 		    state[4], state[5]);
 	}
 	ath_reset(ifp, ATH_RESET_NOLOSS);
 }
 
 static void
 ath_bmiss_vap(struct ieee80211vap *vap)
 {
 	/*
 	 * Workaround phantom bmiss interrupts by sanity-checking
 	 * the time of our last rx'd frame.  If it is within the
 	 * beacon miss interval then ignore the interrupt.  If it's
 	 * truly a bmiss we'll get another interrupt soon and that'll
 	 * be dispatched up for processing.  Note this applies only
 	 * for h/w beacon miss events.
 	 */
 	if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) {
 		struct ifnet *ifp = vap->iv_ic->ic_ifp;
 		struct ath_softc *sc = ifp->if_softc;
 		u_int64_t lastrx = sc->sc_lastrx;
 		u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah);
 		/* XXX should take a locked ref to iv_bss */
 		u_int bmisstimeout =
 			vap->iv_bmissthreshold * vap->iv_bss->ni_intval * 1024;
 
 		DPRINTF(sc, ATH_DEBUG_BEACON,
 		    "%s: tsf %llu lastrx %lld (%llu) bmiss %u\n",
 		    __func__, (unsigned long long) tsf,
 		    (unsigned long long)(tsf - lastrx),
 		    (unsigned long long) lastrx, bmisstimeout);
 
 		if (tsf - lastrx <= bmisstimeout) {
 			sc->sc_stats.ast_bmiss_phantom++;
 			return;
 		}
 	}
 	ATH_VAP(vap)->av_bmiss(vap);
 }
 
 int
 ath_hal_gethangstate(struct ath_hal *ah, uint32_t mask, uint32_t *hangs)
 {
 	uint32_t rsize;
 	void *sp;
 
 	if (!ath_hal_getdiagstate(ah, HAL_DIAG_CHECK_HANGS, &mask, sizeof(mask), &sp, &rsize))
 		return 0;
 	KASSERT(rsize == sizeof(uint32_t), ("resultsize %u", rsize));
 	*hangs = *(uint32_t *)sp;
 	return 1;
 }
 
 static void
 ath_bmiss_proc(void *arg, int pending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	uint32_t hangs;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending);
 
 	/*
 	 * Do a reset upon any becaon miss event.
 	 *
 	 * It may be a non-recognised RX clear hang which needs a reset
 	 * to clear.
 	 */
 	if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) {
 		ath_reset(ifp, ATH_RESET_NOLOSS);
 		if_printf(ifp, "bb hang detected (0x%x), resetting\n", hangs);
 	} else {
 		ath_reset(ifp, ATH_RESET_NOLOSS);
 		ieee80211_beacon_miss(ifp->if_l2com);
 	}
 }
 
 /*
  * Handle TKIP MIC setup to deal hardware that doesn't do MIC
  * calcs together with WME.  If necessary disable the crypto
  * hardware and mark the 802.11 state so keys will be setup
  * with the MIC work done in software.
  */
 static void
 ath_settkipmic(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 
 	if ((ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP) && !sc->sc_wmetkipmic) {
 		if (ic->ic_flags & IEEE80211_F_WME) {
 			ath_hal_settkipmic(sc->sc_ah, AH_FALSE);
 			ic->ic_cryptocaps &= ~IEEE80211_CRYPTO_TKIPMIC;
 		} else {
 			ath_hal_settkipmic(sc->sc_ah, AH_TRUE);
 			ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC;
 		}
 	}
 }
 
 static void
 ath_init(void *arg)
 {
 	struct ath_softc *sc = (struct ath_softc *) arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_STATUS status;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
 		__func__, ifp->if_flags);
 
 	ATH_LOCK(sc);
 	/*
 	 * Stop anything previously setup.  This is safe
 	 * whether this is the first time through or not.
 	 */
 	ath_stop_locked(ifp);
 
 	/*
 	 * The basic interface to setting the hardware in a good
 	 * state is ``reset''.  On return the hardware is known to
 	 * be powered up and with interrupts disabled.  This must
 	 * be followed by initialization of the appropriate bits
 	 * and then setup of the interrupt mask.
 	 */
 	ath_settkipmic(sc);
 	ath_update_chainmasks(sc, ic->ic_curchan);
 	ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
 	    sc->sc_cur_rxchainmask);
 	if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, &status)) {
 		if_printf(ifp, "unable to reset hardware; hal status %u\n",
 			status);
 		ATH_UNLOCK(sc);
 		return;
 	}
 	ath_chan_change(sc, ic->ic_curchan);
 
 	/* Let DFS at it in case it's a DFS channel */
 	ath_dfs_radar_enable(sc, ic->ic_curchan);
 
 	/* Let spectral at in case spectral is enabled */
 	ath_spectral_enable(sc, ic->ic_curchan);
 
 	/*
 	 * Likewise this is set during reset so update
 	 * state cached in the driver.
 	 */
 	sc->sc_diversity = ath_hal_getdiversity(ah);
 	sc->sc_lastlongcal = 0;
 	sc->sc_resetcal = 1;
 	sc->sc_lastcalreset = 0;
 	sc->sc_lastani = 0;
 	sc->sc_lastshortcal = 0;
 	sc->sc_doresetcal = AH_FALSE;
 	/*
 	 * Beacon timers were cleared here; give ath_newstate()
 	 * a hint that the beacon timers should be poked when
 	 * things transition to the RUN state.
 	 */
 	sc->sc_beacons = 0;
 
 	/*
 	 * Setup the hardware after reset: the key cache
 	 * is filled as needed and the receive engine is
 	 * set going.  Frame transmit is handled entirely
 	 * in the frame output path; there's nothing to do
 	 * here except setup the interrupt mask.
 	 */
 	if (ath_startrecv(sc) != 0) {
 		if_printf(ifp, "unable to start recv logic\n");
 		ATH_UNLOCK(sc);
 		return;
 	}
 
 	/*
 	 * Enable interrupts.
 	 */
 	sc->sc_imask = HAL_INT_RX | HAL_INT_TX
 		  | HAL_INT_RXEOL | HAL_INT_RXORN
 		  | HAL_INT_TXURN
 		  | HAL_INT_FATAL | HAL_INT_GLOBAL;
 
 	/*
 	 * Enable RX EDMA bits.  Note these overlap with
 	 * HAL_INT_RX and HAL_INT_RXDESC respectively.
 	 */
 	if (sc->sc_isedma)
 		sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP);
 
 	/*
 	 * Enable MIB interrupts when there are hardware phy counters.
 	 * Note we only do this (at the moment) for station mode.
 	 */
 	if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA)
 		sc->sc_imask |= HAL_INT_MIB;
 
 	/* Enable global TX timeout and carrier sense timeout if available */
 	if (ath_hal_gtxto_supported(ah))
 		sc->sc_imask |= HAL_INT_GTT;
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: imask=0x%x\n",
 		__func__, sc->sc_imask);
 
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 	callout_reset(&sc->sc_wd_ch, hz, ath_watchdog, sc);
 	ath_hal_intrset(ah, sc->sc_imask);
 
 	ATH_UNLOCK(sc);
 
 #ifdef ATH_TX99_DIAG
 	if (sc->sc_tx99 != NULL)
 		sc->sc_tx99->start(sc->sc_tx99);
 	else
 #endif
 	ieee80211_start_all(ic);		/* start all vap's */
 }
 
 static void
 ath_stop_locked(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 
 	DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid %u if_flags 0x%x\n",
 		__func__, sc->sc_invalid, ifp->if_flags);
 
 	ATH_LOCK_ASSERT(sc);
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
 		/*
 		 * Shutdown the hardware and driver:
 		 *    reset 802.11 state machine
 		 *    turn off timers
 		 *    disable interrupts
 		 *    turn off the radio
 		 *    clear transmit machinery
 		 *    clear receive machinery
 		 *    drain and release tx queues
 		 *    reclaim beacon resources
 		 *    power down hardware
 		 *
 		 * Note that some of this work is not possible if the
 		 * hardware is gone (invalid).
 		 */
 #ifdef ATH_TX99_DIAG
 		if (sc->sc_tx99 != NULL)
 			sc->sc_tx99->stop(sc->sc_tx99);
 #endif
 		callout_stop(&sc->sc_wd_ch);
 		sc->sc_wd_timer = 0;
 		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 		if (!sc->sc_invalid) {
 			if (sc->sc_softled) {
 				callout_stop(&sc->sc_ledtimer);
 				ath_hal_gpioset(ah, sc->sc_ledpin,
 					!sc->sc_ledon);
 				sc->sc_blinking = 0;
 			}
 			ath_hal_intrset(ah, 0);
 		}
 		ath_draintxq(sc, ATH_RESET_DEFAULT);
 		if (!sc->sc_invalid) {
 			ath_stoprecv(sc, 1);
 			ath_hal_phydisable(ah);
 		} else
 			sc->sc_rxlink = NULL;
 		ath_beacon_free(sc);	/* XXX not needed */
 	}
 }
 
 #define	MAX_TXRX_ITERATIONS	1000
 static void
 ath_txrx_stop_locked(struct ath_softc *sc)
 {
 	int i = MAX_TXRX_ITERATIONS;
 
 	ATH_UNLOCK_ASSERT(sc);
 	ATH_PCU_LOCK_ASSERT(sc);
 
 	/*
 	 * Sleep until all the pending operations have completed.
 	 *
 	 * The caller must ensure that reset has been incremented
 	 * or the pending operations may continue being queued.
 	 */
 	while (sc->sc_rxproc_cnt || sc->sc_txproc_cnt ||
 	    sc->sc_txstart_cnt || sc->sc_intr_cnt) {
 		if (i <= 0)
 			break;
 		msleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", 1);
 		i--;
 	}
 
 	if (i <= 0)
 		device_printf(sc->sc_dev,
 		    "%s: didn't finish after %d iterations\n",
 		    __func__, MAX_TXRX_ITERATIONS);
 }
 #undef	MAX_TXRX_ITERATIONS
 
 #if 0
 static void
 ath_txrx_stop(struct ath_softc *sc)
 {
 	ATH_UNLOCK_ASSERT(sc);
 	ATH_PCU_UNLOCK_ASSERT(sc);
 
 	ATH_PCU_LOCK(sc);
 	ath_txrx_stop_locked(sc);
 	ATH_PCU_UNLOCK(sc);
 }
 #endif
 
 static void
 ath_txrx_start(struct ath_softc *sc)
 {
 
 	taskqueue_unblock(sc->sc_tq);
 }
 
 /*
  * Grab the reset lock, and wait around until noone else
  * is trying to do anything with it.
  *
  * This is totally horrible but we can't hold this lock for
  * long enough to do TX/RX or we end up with net80211/ip stack
  * LORs and eventual deadlock.
  *
  * "dowait" signals whether to spin, waiting for the reset
  * lock count to reach 0. This should (for now) only be used
  * during the reset path, as the rest of the code may not
  * be locking-reentrant enough to behave correctly.
  *
  * Another, cleaner way should be found to serialise all of
  * these operations.
  */
 #define	MAX_RESET_ITERATIONS	10
 static int
 ath_reset_grablock(struct ath_softc *sc, int dowait)
 {
 	int w = 0;
 	int i = MAX_RESET_ITERATIONS;
 
 	ATH_PCU_LOCK_ASSERT(sc);
 	do {
 		if (sc->sc_inreset_cnt == 0) {
 			w = 1;
 			break;
 		}
 		if (dowait == 0) {
 			w = 0;
 			break;
 		}
 		ATH_PCU_UNLOCK(sc);
 		pause("ath_reset_grablock", 1);
 		i--;
 		ATH_PCU_LOCK(sc);
 	} while (i > 0);
 
 	/*
 	 * We always increment the refcounter, regardless
 	 * of whether we succeeded to get it in an exclusive
 	 * way.
 	 */
 	sc->sc_inreset_cnt++;
 
 	if (i <= 0)
 		device_printf(sc->sc_dev,
 		    "%s: didn't finish after %d iterations\n",
 		    __func__, MAX_RESET_ITERATIONS);
 
 	if (w == 0)
 		device_printf(sc->sc_dev,
 		    "%s: warning, recursive reset path!\n",
 		    __func__);
 
 	return w;
 }
 #undef MAX_RESET_ITERATIONS
 
 /*
  * XXX TODO: write ath_reset_releaselock
  */
 
 static void
 ath_stop(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 
 	ATH_LOCK(sc);
 	ath_stop_locked(ifp);
 	ATH_UNLOCK(sc);
 }
 
 /*
  * Reset the hardware w/o losing operational state.  This is
  * basically a more efficient way of doing ath_stop, ath_init,
  * followed by state transitions to the current 802.11
  * operational state.  Used to recover from various errors and
  * to reset or reload hardware state.
  */
 int
 ath_reset(struct ifnet *ifp, ATH_RESET_TYPE reset_type)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_STATUS status;
 	int i;
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__);
 
 	/* Ensure ATH_LOCK isn't held; ath_rx_proc can't be locked */
 	ATH_PCU_UNLOCK_ASSERT(sc);
 	ATH_UNLOCK_ASSERT(sc);
 
 	/* Try to (stop any further TX/RX from occuring */
 	taskqueue_block(sc->sc_tq);
 
 	ATH_PCU_LOCK(sc);
 	ath_hal_intrset(ah, 0);		/* disable interrupts */
 	ath_txrx_stop_locked(sc);	/* Ensure TX/RX is stopped */
 	if (ath_reset_grablock(sc, 1) == 0) {
 		device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n",
 		    __func__);
 	}
 	ATH_PCU_UNLOCK(sc);
 
 	/*
 	 * Should now wait for pending TX/RX to complete
 	 * and block future ones from occuring. This needs to be
 	 * done before the TX queue is drained.
 	 */
 	ath_draintxq(sc, reset_type);	/* stop xmit side */
 
 	/*
 	 * Regardless of whether we're doing a no-loss flush or
 	 * not, stop the PCU and handle what's in the RX queue.
 	 * That way frames aren't dropped which shouldn't be.
 	 */
 	ath_stoprecv(sc, (reset_type != ATH_RESET_NOLOSS));
 	ath_rx_flush(sc);
 
 	ath_settkipmic(sc);		/* configure TKIP MIC handling */
 	/* NB: indicate channel change so we do a full reset */
 	ath_update_chainmasks(sc, ic->ic_curchan);
 	ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
 	    sc->sc_cur_rxchainmask);
 	if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, &status))
 		if_printf(ifp, "%s: unable to reset hardware; hal status %u\n",
 			__func__, status);
 	sc->sc_diversity = ath_hal_getdiversity(ah);
 
 	/* Let DFS at it in case it's a DFS channel */
 	ath_dfs_radar_enable(sc, ic->ic_curchan);
 
 	/* Let spectral at in case spectral is enabled */
 	ath_spectral_enable(sc, ic->ic_curchan);
 
 	if (ath_startrecv(sc) != 0)	/* restart recv */
 		if_printf(ifp, "%s: unable to start recv logic\n", __func__);
 	/*
 	 * We may be doing a reset in response to an ioctl
 	 * that changes the channel so update any state that
 	 * might change as a result.
 	 */
 	ath_chan_change(sc, ic->ic_curchan);
 	if (sc->sc_beacons) {		/* restart beacons */
 #ifdef IEEE80211_SUPPORT_TDMA
 		if (sc->sc_tdma)
 			ath_tdma_config(sc, NULL);
 		else
 #endif
 			ath_beacon_config(sc, NULL);
 	}
 
 	/*
 	 * Release the reset lock and re-enable interrupts here.
 	 * If an interrupt was being processed in ath_intr(),
 	 * it would disable interrupts at this point. So we have
 	 * to atomically enable interrupts and decrement the
 	 * reset counter - this way ath_intr() doesn't end up
 	 * disabling interrupts without a corresponding enable
 	 * in the rest or channel change path.
 	 */
 	ATH_PCU_LOCK(sc);
 	sc->sc_inreset_cnt--;
 	/* XXX only do this if sc_inreset_cnt == 0? */
 	ath_hal_intrset(ah, sc->sc_imask);
 	ATH_PCU_UNLOCK(sc);
 
 	/*
 	 * TX and RX can be started here. If it were started with
 	 * sc_inreset_cnt > 0, the TX and RX path would abort.
 	 * Thus if this is a nested call through the reset or
 	 * channel change code, TX completion will occur but
 	 * RX completion and ath_start / ath_tx_start will not
 	 * run.
 	 */
 
 	/* Restart TX/RX as needed */
 	ath_txrx_start(sc);
 
 	/* Restart TX completion and pending TX */
 	if (reset_type == ATH_RESET_NOLOSS) {
 		for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
 			if (ATH_TXQ_SETUP(sc, i)) {
 				ATH_TXQ_LOCK(&sc->sc_txq[i]);
 				ath_txq_restart_dma(sc, &sc->sc_txq[i]);
 				ATH_TXQ_UNLOCK(&sc->sc_txq[i]);
 
 				ATH_TX_LOCK(sc);
 				ath_txq_sched(sc, &sc->sc_txq[i]);
 				ATH_TX_UNLOCK(sc);
 			}
 		}
 	}
 
 	/*
 	 * This may have been set during an ath_start() call which
 	 * set this once it detected a concurrent TX was going on.
 	 * So, clear it.
 	 */
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 
 	/* Handle any frames in the TX queue */
 	/*
 	 * XXX should this be done by the caller, rather than
 	 * ath_reset() ?
 	 */
 	ath_tx_kick(sc);		/* restart xmit */
 	return 0;
 }
 
 static int
 ath_reset_vap(struct ieee80211vap *vap, u_long cmd)
 {
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 
 	switch (cmd) {
 	case IEEE80211_IOC_TXPOWER:
 		/*
 		 * If per-packet TPC is enabled, then we have nothing
 		 * to do; otherwise we need to force the global limit.
 		 * All this can happen directly; no need to reset.
 		 */
 		if (!ath_hal_gettpc(ah))
 			ath_hal_settxpowlimit(ah, ic->ic_txpowlimit);
 		return 0;
 	}
 	/* XXX? Full or NOLOSS? */
 	return ath_reset(ifp, ATH_RESET_FULL);
 }
 
 struct ath_buf *
 _ath_getbuf_locked(struct ath_softc *sc, ath_buf_type_t btype)
 {
 	struct ath_buf *bf;
 
 	ATH_TXBUF_LOCK_ASSERT(sc);
 
 	if (btype == ATH_BUFTYPE_MGMT)
 		bf = TAILQ_FIRST(&sc->sc_txbuf_mgmt);
 	else
 		bf = TAILQ_FIRST(&sc->sc_txbuf);
 
 	if (bf == NULL) {
 		sc->sc_stats.ast_tx_getnobuf++;
 	} else {
 		if (bf->bf_flags & ATH_BUF_BUSY) {
 			sc->sc_stats.ast_tx_getbusybuf++;
 			bf = NULL;
 		}
 	}
 
 	if (bf != NULL && (bf->bf_flags & ATH_BUF_BUSY) == 0) {
 		if (btype == ATH_BUFTYPE_MGMT)
 			TAILQ_REMOVE(&sc->sc_txbuf_mgmt, bf, bf_list);
 		else {
 			TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list);
 			sc->sc_txbuf_cnt--;
 
 			/*
 			 * This shuldn't happen; however just to be
 			 * safe print a warning and fudge the txbuf
 			 * count.
 			 */
 			if (sc->sc_txbuf_cnt < 0) {
 				device_printf(sc->sc_dev,
 				    "%s: sc_txbuf_cnt < 0?\n",
 				    __func__);
 				sc->sc_txbuf_cnt = 0;
 			}
 		}
 	} else
 		bf = NULL;
 
 	if (bf == NULL) {
 		/* XXX should check which list, mgmt or otherwise */
 		DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__,
 		    TAILQ_FIRST(&sc->sc_txbuf) == NULL ?
 			"out of xmit buffers" : "xmit buffer busy");
 		return NULL;
 	}
 
 	/* XXX TODO: should do this at buffer list initialisation */
 	/* XXX (then, ensure the buffer has the right flag set) */
 	bf->bf_flags = 0;
 	if (btype == ATH_BUFTYPE_MGMT)
 		bf->bf_flags |= ATH_BUF_MGMT;
 	else
 		bf->bf_flags &= (~ATH_BUF_MGMT);
 
 	/* Valid bf here; clear some basic fields */
 	bf->bf_next = NULL;	/* XXX just to be sure */
 	bf->bf_last = NULL;	/* XXX again, just to be sure */
 	bf->bf_comp = NULL;	/* XXX again, just to be sure */
 	bzero(&bf->bf_state, sizeof(bf->bf_state));
 
 	/*
 	 * Track the descriptor ID only if doing EDMA
 	 */
 	if (sc->sc_isedma) {
 		bf->bf_descid = sc->sc_txbuf_descid;
 		sc->sc_txbuf_descid++;
 	}
 
 	return bf;
 }
 
 /*
  * When retrying a software frame, buffers marked ATH_BUF_BUSY
  * can't be thrown back on the queue as they could still be
  * in use by the hardware.
  *
  * This duplicates the buffer, or returns NULL.
  *
  * The descriptor is also copied but the link pointers and
  * the DMA segments aren't copied; this frame should thus
  * be again passed through the descriptor setup/chain routines
  * so the link is correct.
  *
  * The caller must free the buffer using ath_freebuf().
  */
 struct ath_buf *
 ath_buf_clone(struct ath_softc *sc, struct ath_buf *bf)
 {
 	struct ath_buf *tbf;
 
 	tbf = ath_getbuf(sc,
 	    (bf->bf_flags & ATH_BUF_MGMT) ?
 	     ATH_BUFTYPE_MGMT : ATH_BUFTYPE_NORMAL);
 	if (tbf == NULL)
 		return NULL;	/* XXX failure? Why? */
 
 	/* Copy basics */
 	tbf->bf_next = NULL;
 	tbf->bf_nseg = bf->bf_nseg;
 	tbf->bf_flags = bf->bf_flags & ATH_BUF_FLAGS_CLONE;
 	tbf->bf_status = bf->bf_status;
 	tbf->bf_m = bf->bf_m;
 	tbf->bf_node = bf->bf_node;
 	/* will be setup by the chain/setup function */
 	tbf->bf_lastds = NULL;
 	/* for now, last == self */
 	tbf->bf_last = tbf;
 	tbf->bf_comp = bf->bf_comp;
 
 	/* NOTE: DMA segments will be setup by the setup/chain functions */
 
 	/* The caller has to re-init the descriptor + links */
 
 	/*
 	 * Free the DMA mapping here, before we NULL the mbuf.
 	 * We must only call bus_dmamap_unload() once per mbuf chain
 	 * or behaviour is undefined.
 	 */
 	if (bf->bf_m != NULL) {
 		/*
 		 * XXX is this POSTWRITE call required?
 		 */
 		bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
 		    BUS_DMASYNC_POSTWRITE);
 		bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 	}
 
 	bf->bf_m = NULL;
 	bf->bf_node = NULL;
 
 	/* Copy state */
 	memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state));
 
 	return tbf;
 }
 
 struct ath_buf *
 ath_getbuf(struct ath_softc *sc, ath_buf_type_t btype)
 {
 	struct ath_buf *bf;
 
 	ATH_TXBUF_LOCK(sc);
 	bf = _ath_getbuf_locked(sc, btype);
 	/*
 	 * If a mgmt buffer was requested but we're out of those,
 	 * try requesting a normal one.
 	 */
 	if (bf == NULL && btype == ATH_BUFTYPE_MGMT)
 		bf = _ath_getbuf_locked(sc, ATH_BUFTYPE_NORMAL);
 	ATH_TXBUF_UNLOCK(sc);
 	if (bf == NULL) {
 		struct ifnet *ifp = sc->sc_ifp;
 
 		DPRINTF(sc, ATH_DEBUG_XMIT, "%s: stop queue\n", __func__);
 		sc->sc_stats.ast_tx_qstop++;
 		IF_LOCK(&ifp->if_snd);
 		ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 		IF_UNLOCK(&ifp->if_snd);
 	}
 	return bf;
 }
 
 static void
 ath_start_queue(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 
 	ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_queue: start");
 	ath_tx_kick(sc);
 	ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_queue: finished");
 }
 
 void
 ath_start_task(void *arg, int npending)
 {
 	struct ath_softc *sc = (struct ath_softc *) arg;
 	struct ifnet *ifp = sc->sc_ifp;
 
 	ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: start");
 
 	/* XXX is it ok to hold the ATH_LOCK here? */
 	ATH_PCU_LOCK(sc);
 	if (sc->sc_inreset_cnt > 0) {
 		device_printf(sc->sc_dev,
 		    "%s: sc_inreset_cnt > 0; bailing\n", __func__);
 		ATH_PCU_UNLOCK(sc);
 		IF_LOCK(&ifp->if_snd);
 		sc->sc_stats.ast_tx_qstop++;
 		ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 		IF_UNLOCK(&ifp->if_snd);
 		ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: OACTIVE, finish");
 		return;
 	}
 	sc->sc_txstart_cnt++;
 	ATH_PCU_UNLOCK(sc);
 
 	ATH_TX_LOCK(sc);
 	ath_start(sc->sc_ifp);
 	ATH_TX_UNLOCK(sc);
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txstart_cnt--;
 	ATH_PCU_UNLOCK(sc);
 	ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: finished");
 }
 
 void
 ath_start(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	struct ieee80211_node *ni;
 	struct ath_buf *bf;
 	struct mbuf *m, *next;
 	ath_bufhead frags;
 	int npkts = 0;
 
 	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->sc_invalid)
 		return;
 
 	ATH_TX_LOCK_ASSERT(sc);
 
 	ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start: called");
 
 	for (;;) {
 		ATH_TXBUF_LOCK(sc);
 		if (sc->sc_txbuf_cnt <= sc->sc_txq_data_minfree) {
 			/* XXX increment counter? */
 			ATH_TXBUF_UNLOCK(sc);
 			IF_LOCK(&ifp->if_snd);
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 			IF_UNLOCK(&ifp->if_snd);
 			break;
 		}
 		ATH_TXBUF_UNLOCK(sc);
 		
 		/*
 		 * Grab a TX buffer and associated resources.
 		 */
 		bf = ath_getbuf(sc, ATH_BUFTYPE_NORMAL);
 		if (bf == NULL)
 			break;
 
 		IFQ_DEQUEUE(&ifp->if_snd, m);
 		if (m == NULL) {
 			ATH_TXBUF_LOCK(sc);
 			ath_returnbuf_head(sc, bf);
 			ATH_TXBUF_UNLOCK(sc);
 			break;
 		}
 		ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
 		npkts ++;
 		/*
 		 * Check for fragmentation.  If this frame
 		 * has been broken up verify we have enough
 		 * buffers to send all the fragments so all
 		 * go out or none...
 		 */
 		TAILQ_INIT(&frags);
 		if ((m->m_flags & M_FRAG) &&
 		    !ath_txfrag_setup(sc, &frags, m, ni)) {
 			DPRINTF(sc, ATH_DEBUG_XMIT,
 			    "%s: out of txfrag buffers\n", __func__);
 			sc->sc_stats.ast_tx_nofrag++;
 			ifp->if_oerrors++;
 			ath_freetx(m);
 			goto bad;
 		}
 		ifp->if_opackets++;
 	nextfrag:
 		/*
 		 * Pass the frame to the h/w for transmission.
 		 * Fragmented frames have each frag chained together
 		 * with m_nextpkt.  We know there are sufficient ath_buf's
 		 * to send all the frags because of work done by
 		 * ath_txfrag_setup.  We leave m_nextpkt set while
 		 * calling ath_tx_start so it can use it to extend the
 		 * the tx duration to cover the subsequent frag and
 		 * so it can reclaim all the mbufs in case of an error;
 		 * ath_tx_start clears m_nextpkt once it commits to
 		 * handing the frame to the hardware.
 		 */
 		next = m->m_nextpkt;
 		if (ath_tx_start(sc, ni, bf, m)) {
 	bad:
 			ifp->if_oerrors++;
 	reclaim:
 			bf->bf_m = NULL;
 			bf->bf_node = NULL;
 			ATH_TXBUF_LOCK(sc);
 			ath_returnbuf_head(sc, bf);
 			ath_txfrag_cleanup(sc, &frags, ni);
 			ATH_TXBUF_UNLOCK(sc);
 			/*
 			 * XXX todo, free the node outside of
 			 * the TX lock context!
 			 */
 			if (ni != NULL)
 				ieee80211_free_node(ni);
 			continue;
 		}
 
 		/*
 		 * Check here if the node is in power save state.
 		 */
 		ath_tx_update_tim(sc, ni, 1);
 
 		if (next != NULL) {
 			/*
 			 * Beware of state changing between frags.
 			 * XXX check sta power-save state?
 			 */
 			if (ni->ni_vap->iv_state != IEEE80211_S_RUN) {
 				DPRINTF(sc, ATH_DEBUG_XMIT,
 				    "%s: flush fragmented packet, state %s\n",
 				    __func__,
 				    ieee80211_state_name[ni->ni_vap->iv_state]);
 				/* XXX dmamap */
 				ath_freetx(next);
 				goto reclaim;
 			}
 			m = next;
 			bf = TAILQ_FIRST(&frags);
 			KASSERT(bf != NULL, ("no buf for txfrag"));
 			TAILQ_REMOVE(&frags, bf, bf_list);
 			goto nextfrag;
 		}
 
 		sc->sc_wd_timer = 5;
 	}
 	ATH_KTR(sc, ATH_KTR_TX, 1, "ath_start: finished; npkts=%d", npkts);
 }
 static int
 ath_media_change(struct ifnet *ifp)
 {
 	int error = ieee80211_media_change(ifp);
 	/* NB: only the fixed rate can change and that doesn't need a reset */
 	return (error == ENETRESET ? 0 : error);
 }
 
 /*
  * Block/unblock tx+rx processing while a key change is done.
  * We assume the caller serializes key management operations
  * so we only need to worry about synchronization with other
  * uses that originate in the driver.
  */
 static void
 ath_key_update_begin(struct ieee80211vap *vap)
 {
 	struct ifnet *ifp = vap->iv_ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 
 	DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__);
 	taskqueue_block(sc->sc_tq);
 	IF_LOCK(&ifp->if_snd);		/* NB: doesn't block mgmt frames */
 }
 
 static void
 ath_key_update_end(struct ieee80211vap *vap)
 {
 	struct ifnet *ifp = vap->iv_ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 
 	DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__);
 	IF_UNLOCK(&ifp->if_snd);
 	taskqueue_unblock(sc->sc_tq);
 }
 
 static void
 ath_update_promisc(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	u_int32_t rfilt;
 
 	/* configure rx filter */
 	rfilt = ath_calcrxfilter(sc);
 	ath_hal_setrxfilter(sc->sc_ah, rfilt);
 
 	DPRINTF(sc, ATH_DEBUG_MODE, "%s: RX filter 0x%x\n", __func__, rfilt);
 }
 
 static void
 ath_update_mcast(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	u_int32_t mfilt[2];
 
 	/* calculate and install multicast filter */
 	if ((ifp->if_flags & IFF_ALLMULTI) == 0) {
 		struct ifmultiaddr *ifma;
 		/*
 		 * Merge multicast addresses to form the hardware filter.
 		 */
 		mfilt[0] = mfilt[1] = 0;
 		if_maddr_rlock(ifp);	/* XXX need some fiddling to remove? */
 		TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
 			caddr_t dl;
 			u_int32_t val;
 			u_int8_t pos;
 
 			/* calculate XOR of eight 6bit values */
 			dl = LLADDR((struct sockaddr_dl *) ifma->ifma_addr);
 			val = LE_READ_4(dl + 0);
 			pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
 			val = LE_READ_4(dl + 3);
 			pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
 			pos &= 0x3f;
 			mfilt[pos / 32] |= (1 << (pos % 32));
 		}
 		if_maddr_runlock(ifp);
 	} else
 		mfilt[0] = mfilt[1] = ~0;
 	ath_hal_setmcastfilter(sc->sc_ah, mfilt[0], mfilt[1]);
 	DPRINTF(sc, ATH_DEBUG_MODE, "%s: MC filter %08x:%08x\n",
 		__func__, mfilt[0], mfilt[1]);
 }
 
 void
 ath_mode_init(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ath_hal *ah = sc->sc_ah;
 	u_int32_t rfilt;
 
 	/* configure rx filter */
 	rfilt = ath_calcrxfilter(sc);
 	ath_hal_setrxfilter(ah, rfilt);
 
 	/* configure operational mode */
 	ath_hal_setopmode(ah);
 
 	DPRINTF(sc, ATH_DEBUG_STATE | ATH_DEBUG_MODE,
 	    "%s: ah=%p, ifp=%p, if_addr=%p\n",
 	    __func__,
 	    ah,
 	    ifp,
 	    (ifp == NULL) ? NULL : ifp->if_addr);
 
 	/* handle any link-level address change */
 	ath_hal_setmac(ah, IF_LLADDR(ifp));
 
 	/* calculate and install multicast filter */
 	ath_update_mcast(ifp);
 }
 
 /*
  * Set the slot time based on the current setting.
  */
 void
 ath_setslottime(struct ath_softc *sc)
 {
 	struct ieee80211com *ic = sc->sc_ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	u_int usec;
 
 	if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan))
 		usec = 13;
 	else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan))
 		usec = 21;
 	else if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) {
 		/* honor short/long slot time only in 11g */
 		/* XXX shouldn't honor on pure g or turbo g channel */
 		if (ic->ic_flags & IEEE80211_F_SHSLOT)
 			usec = HAL_SLOT_TIME_9;
 		else
 			usec = HAL_SLOT_TIME_20;
 	} else
 		usec = HAL_SLOT_TIME_9;
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: chan %u MHz flags 0x%x %s slot, %u usec\n",
 	    __func__, ic->ic_curchan->ic_freq, ic->ic_curchan->ic_flags,
 	    ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long", usec);
 
 	ath_hal_setslottime(ah, usec);
 	sc->sc_updateslot = OK;
 }
 
 /*
  * Callback from the 802.11 layer to update the
  * slot time based on the current setting.
  */
 static void
 ath_updateslot(struct ifnet *ifp)
 {
 	struct ath_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 
 	/*
 	 * When not coordinating the BSS, change the hardware
 	 * immediately.  For other operation we defer the change
 	 * until beacon updates have propagated to the stations.
 	 */
 	if (ic->ic_opmode == IEEE80211_M_HOSTAP ||
 	    ic->ic_opmode == IEEE80211_M_MBSS)
 		sc->sc_updateslot = UPDATE;
 	else
 		ath_setslottime(sc);
 }
 
 /*
  * Append the contents of src to dst; both queues
  * are assumed to be locked.
  */
 void
 ath_txqmove(struct ath_txq *dst, struct ath_txq *src)
 {
 
 	ATH_TXQ_LOCK_ASSERT(src);
 	ATH_TXQ_LOCK_ASSERT(dst);
 
 	TAILQ_CONCAT(&dst->axq_q, &src->axq_q, bf_list);
 	dst->axq_link = src->axq_link;
 	src->axq_link = NULL;
 	dst->axq_depth += src->axq_depth;
 	dst->axq_aggr_depth += src->axq_aggr_depth;
 	src->axq_depth = 0;
 	src->axq_aggr_depth = 0;
 }
 
 /*
  * Reset the hardware, with no loss.
  *
  * This can't be used for a general case reset.
  */
 static void
 ath_reset_proc(void *arg, int pending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 
 #if 0
 	if_printf(ifp, "%s: resetting\n", __func__);
 #endif
 	ath_reset(ifp, ATH_RESET_NOLOSS);
 }
 
 /*
  * Reset the hardware after detecting beacons have stopped.
  */
 static void
 ath_bstuck_proc(void *arg, int pending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	uint32_t hangs = 0;
 
 	if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0)
 		if_printf(ifp, "bb hang detected (0x%x)\n", hangs);
 
 	if_printf(ifp, "stuck beacon; resetting (bmiss count %u)\n",
 		sc->sc_bmisscount);
 	sc->sc_stats.ast_bstuck++;
 	/*
 	 * This assumes that there's no simultaneous channel mode change
 	 * occuring.
 	 */
 	ath_reset(ifp, ATH_RESET_NOLOSS);
 }
 
 static void
 ath_load_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
 {
 	bus_addr_t *paddr = (bus_addr_t*) arg;
 	KASSERT(error == 0, ("error %u on bus_dma callback", error));
 	*paddr = segs->ds_addr;
 }
 
 /*
  * Allocate the descriptors and appropriate DMA tag/setup.
  *
  * For some situations (eg EDMA TX completion), there isn't a requirement
  * for the ath_buf entries to be allocated.
  */
 int
 ath_descdma_alloc_desc(struct ath_softc *sc,
 	struct ath_descdma *dd, ath_bufhead *head,
 	const char *name, int ds_size, int ndesc)
 {
 #define	DS2PHYS(_dd, _ds) \
 	((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
 #define	ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \
 	((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0)
 	struct ifnet *ifp = sc->sc_ifp;
 	int error;
 
 	dd->dd_descsize = ds_size;
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: %s DMA: %u desc, %d bytes per descriptor\n",
 	    __func__, name, ndesc, dd->dd_descsize);
 
 	dd->dd_name = name;
 	dd->dd_desc_len = dd->dd_descsize * ndesc;
 
 	/*
 	 * Merlin work-around:
 	 * Descriptors that cross the 4KB boundary can't be used.
 	 * Assume one skipped descriptor per 4KB page.
 	 */
 	if (! ath_hal_split4ktrans(sc->sc_ah)) {
 		int numpages = dd->dd_desc_len / 4096;
 		dd->dd_desc_len += ds_size * numpages;
 	}
 
 	/*
 	 * Setup DMA descriptor area.
 	 *
 	 * BUS_DMA_ALLOCNOW is not used; we never use bounce
 	 * buffers for the descriptors themselves.
 	 */
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev),	/* parent */
 		       PAGE_SIZE, 0,		/* alignment, bounds */
 		       BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
 		       BUS_SPACE_MAXADDR,	/* highaddr */
 		       NULL, NULL,		/* filter, filterarg */
 		       dd->dd_desc_len,		/* maxsize */
 		       1,			/* nsegments */
 		       dd->dd_desc_len,		/* maxsegsize */
 		       0,			/* flags */
 		       NULL,			/* lockfunc */
 		       NULL,			/* lockarg */
 		       &dd->dd_dmat);
 	if (error != 0) {
 		if_printf(ifp, "cannot allocate %s DMA tag\n", dd->dd_name);
 		return error;
 	}
 
 	/* allocate descriptors */
 	error = bus_dmamem_alloc(dd->dd_dmat, (void**) &dd->dd_desc,
 				 BUS_DMA_NOWAIT | BUS_DMA_COHERENT,
 				 &dd->dd_dmamap);
 	if (error != 0) {
 		if_printf(ifp, "unable to alloc memory for %u %s descriptors, "
 			"error %u\n", ndesc, dd->dd_name, error);
 		goto fail1;
 	}
 
 	error = bus_dmamap_load(dd->dd_dmat, dd->dd_dmamap,
 				dd->dd_desc, dd->dd_desc_len,
 				ath_load_cb, &dd->dd_desc_paddr,
 				BUS_DMA_NOWAIT);
 	if (error != 0) {
 		if_printf(ifp, "unable to map %s descriptors, error %u\n",
 			dd->dd_name, error);
 		goto fail2;
 	}
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n",
 	    __func__, dd->dd_name, (uint8_t *) dd->dd_desc,
 	    (u_long) dd->dd_desc_len, (caddr_t) dd->dd_desc_paddr,
 	    /*XXX*/ (u_long) dd->dd_desc_len);
 
 	return (0);
 
 fail2:
 	bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap);
 fail1:
 	bus_dma_tag_destroy(dd->dd_dmat);
 	memset(dd, 0, sizeof(*dd));
 	return error;
 #undef DS2PHYS
 #undef ATH_DESC_4KB_BOUND_CHECK
 }
 
 int
 ath_descdma_setup(struct ath_softc *sc,
 	struct ath_descdma *dd, ath_bufhead *head,
 	const char *name, int ds_size, int nbuf, int ndesc)
 {
 #define	DS2PHYS(_dd, _ds) \
 	((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
 #define	ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \
 	((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0)
 	struct ifnet *ifp = sc->sc_ifp;
 	uint8_t *ds;
 	struct ath_buf *bf;
 	int i, bsize, error;
 
 	/* Allocate descriptors */
 	error = ath_descdma_alloc_desc(sc, dd, head, name, ds_size,
 	    nbuf * ndesc);
 
 	/* Assume any errors during allocation were dealt with */
 	if (error != 0) {
 		return (error);
 	}
 
 	ds = (uint8_t *) dd->dd_desc;
 
 	/* allocate rx buffers */
 	bsize = sizeof(struct ath_buf) * nbuf;
 	bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO);
 	if (bf == NULL) {
 		if_printf(ifp, "malloc of %s buffers failed, size %u\n",
 			dd->dd_name, bsize);
 		goto fail3;
 	}
 	dd->dd_bufptr = bf;
 
 	TAILQ_INIT(head);
 	for (i = 0; i < nbuf; i++, bf++, ds += (ndesc * dd->dd_descsize)) {
 		bf->bf_desc = (struct ath_desc *) ds;
 		bf->bf_daddr = DS2PHYS(dd, ds);
 		if (! ath_hal_split4ktrans(sc->sc_ah)) {
 			/*
 			 * Merlin WAR: Skip descriptor addresses which
 			 * cause 4KB boundary crossing along any point
 			 * in the descriptor.
 			 */
 			 if (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr,
 			     dd->dd_descsize)) {
 				/* Start at the next page */
 				ds += 0x1000 - (bf->bf_daddr & 0xFFF);
 				bf->bf_desc = (struct ath_desc *) ds;
 				bf->bf_daddr = DS2PHYS(dd, ds);
 			}
 		}
 		error = bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT,
 				&bf->bf_dmamap);
 		if (error != 0) {
 			if_printf(ifp, "unable to create dmamap for %s "
 				"buffer %u, error %u\n", dd->dd_name, i, error);
 			ath_descdma_cleanup(sc, dd, head);
 			return error;
 		}
 		bf->bf_lastds = bf->bf_desc;	/* Just an initial value */
 		TAILQ_INSERT_TAIL(head, bf, bf_list);
 	}
 
 	/*
 	 * XXX TODO: ensure that ds doesn't overflow the descriptor
 	 * allocation otherwise weird stuff will occur and crash your
 	 * machine.
 	 */
 	return 0;
 	/* XXX this should likely just call ath_descdma_cleanup() */
 fail3:
 	bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap);
 	bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap);
 	bus_dma_tag_destroy(dd->dd_dmat);
 	memset(dd, 0, sizeof(*dd));
 	return error;
 #undef DS2PHYS
 #undef ATH_DESC_4KB_BOUND_CHECK
 }
 
 /*
  * Allocate ath_buf entries but no descriptor contents.
  *
  * This is for RX EDMA where the descriptors are the header part of
  * the RX buffer.
  */
 int
 ath_descdma_setup_rx_edma(struct ath_softc *sc,
 	struct ath_descdma *dd, ath_bufhead *head,
 	const char *name, int nbuf, int rx_status_len)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ath_buf *bf;
 	int i, bsize, error;
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: %s DMA: %u buffers\n",
 	    __func__, name, nbuf);
 
 	dd->dd_name = name;
 	/*
 	 * This is (mostly) purely for show.  We're not allocating any actual
 	 * descriptors here as EDMA RX has the descriptor be part
 	 * of the RX buffer.
 	 *
 	 * However, dd_desc_len is used by ath_descdma_free() to determine
 	 * whether we have already freed this DMA mapping.
 	 */
 	dd->dd_desc_len = rx_status_len * nbuf;
 	dd->dd_descsize = rx_status_len;
 
 	/* allocate rx buffers */
 	bsize = sizeof(struct ath_buf) * nbuf;
 	bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO);
 	if (bf == NULL) {
 		if_printf(ifp, "malloc of %s buffers failed, size %u\n",
 			dd->dd_name, bsize);
 		error = ENOMEM;
 		goto fail3;
 	}
 	dd->dd_bufptr = bf;
 
 	TAILQ_INIT(head);
 	for (i = 0; i < nbuf; i++, bf++) {
 		bf->bf_desc = NULL;
 		bf->bf_daddr = 0;
 		bf->bf_lastds = NULL;	/* Just an initial value */
 
 		error = bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT,
 				&bf->bf_dmamap);
 		if (error != 0) {
 			if_printf(ifp, "unable to create dmamap for %s "
 				"buffer %u, error %u\n", dd->dd_name, i, error);
 			ath_descdma_cleanup(sc, dd, head);
 			return error;
 		}
 		TAILQ_INSERT_TAIL(head, bf, bf_list);
 	}
 	return 0;
 fail3:
 	memset(dd, 0, sizeof(*dd));
 	return error;
 }
 
 void
 ath_descdma_cleanup(struct ath_softc *sc,
 	struct ath_descdma *dd, ath_bufhead *head)
 {
 	struct ath_buf *bf;
 	struct ieee80211_node *ni;
 	int do_warning = 0;
 
 	if (dd->dd_dmamap != 0) {
 		bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap);
 		bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap);
 		bus_dma_tag_destroy(dd->dd_dmat);
 	}
 
 	if (head != NULL) {
 		TAILQ_FOREACH(bf, head, bf_list) {
 			if (bf->bf_m) {
 				/*
 				 * XXX warn if there's buffers here.
 				 * XXX it should have been freed by the
 				 * owner!
 				 */
 				
 				if (do_warning == 0) {
 					do_warning = 1;
 					device_printf(sc->sc_dev,
 					    "%s: %s: mbuf should've been"
 					    " unmapped/freed!\n",
 					    __func__,
 					    dd->dd_name);
 				}
 				bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
 				    BUS_DMASYNC_POSTREAD);
 				bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 				m_freem(bf->bf_m);
 				bf->bf_m = NULL;
 			}
 			if (bf->bf_dmamap != NULL) {
 				bus_dmamap_destroy(sc->sc_dmat, bf->bf_dmamap);
 				bf->bf_dmamap = NULL;
 			}
 			ni = bf->bf_node;
 			bf->bf_node = NULL;
 			if (ni != NULL) {
 				/*
 				 * Reclaim node reference.
 				 */
 				ieee80211_free_node(ni);
 			}
 		}
 	}
 
 	if (head != NULL)
 		TAILQ_INIT(head);
 
 	if (dd->dd_bufptr != NULL)
 		free(dd->dd_bufptr, M_ATHDEV);
 	memset(dd, 0, sizeof(*dd));
 }
 
 static int
 ath_desc_alloc(struct ath_softc *sc)
 {
 	int error;
 
 	error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf,
 		    "tx", sc->sc_tx_desclen, ath_txbuf, ATH_MAX_SCATTER);
 	if (error != 0) {
 		return error;
 	}
 	sc->sc_txbuf_cnt = ath_txbuf;
 
 	error = ath_descdma_setup(sc, &sc->sc_txdma_mgmt, &sc->sc_txbuf_mgmt,
 		    "tx_mgmt", sc->sc_tx_desclen, ath_txbuf_mgmt,
 		    ATH_TXDESC);
 	if (error != 0) {
 		ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf);
 		return error;
 	}
 
 	/*
 	 * XXX mark txbuf_mgmt frames with ATH_BUF_MGMT, so the
 	 * flag doesn't have to be set in ath_getbuf_locked().
 	 */
 
 	error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf,
 			"beacon", sc->sc_tx_desclen, ATH_BCBUF, 1);
 	if (error != 0) {
 		ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf);
 		ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt,
 		    &sc->sc_txbuf_mgmt);
 		return error;
 	}
 	return 0;
 }
 
 static void
 ath_desc_free(struct ath_softc *sc)
 {
 
 	if (sc->sc_bdma.dd_desc_len != 0)
 		ath_descdma_cleanup(sc, &sc->sc_bdma, &sc->sc_bbuf);
 	if (sc->sc_txdma.dd_desc_len != 0)
 		ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf);
 	if (sc->sc_txdma_mgmt.dd_desc_len != 0)
 		ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt,
 		    &sc->sc_txbuf_mgmt);
 }
 
 static struct ieee80211_node *
 ath_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN])
 {
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space;
 	struct ath_node *an;
 
 	an = malloc(space, M_80211_NODE, M_NOWAIT|M_ZERO);
 	if (an == NULL) {
 		/* XXX stat+msg */
 		return NULL;
 	}
 	ath_rate_node_init(sc, an);
 
 	/* Setup the mutex - there's no associd yet so set the name to NULL */
 	snprintf(an->an_name, sizeof(an->an_name), "%s: node %p",
 	    device_get_nameunit(sc->sc_dev), an);
 	mtx_init(&an->an_mtx, an->an_name, NULL, MTX_DEF);
 
 	/* XXX setup ath_tid */
 	ath_tx_tid_init(sc, an);
 
 	DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an);
 	return &an->an_node;
 }
 
 static void
 ath_node_cleanup(struct ieee80211_node *ni)
 {
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 
 	/* Cleanup ath_tid, free unused bufs, unlink bufs in TXQ */
 	ath_tx_node_flush(sc, ATH_NODE(ni));
 	ath_rate_node_cleanup(sc, ATH_NODE(ni));
 	sc->sc_node_cleanup(ni);
 }
 
 static void
 ath_node_free(struct ieee80211_node *ni)
 {
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 
 	DPRINTF(sc, ATH_DEBUG_NODE, "%s: ni %p\n", __func__, ni);
 	mtx_destroy(&ATH_NODE(ni)->an_mtx);
 	sc->sc_node_free(ni);
 }
 
 static void
 ath_node_getsignal(const struct ieee80211_node *ni, int8_t *rssi, int8_t *noise)
 {
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 
 	*rssi = ic->ic_node_getrssi(ni);
 	if (ni->ni_chan != IEEE80211_CHAN_ANYC)
 		*noise = ath_hal_getchannoise(ah, ni->ni_chan);
 	else
 		*noise = -95;		/* nominally correct */
 }
 
 /*
  * Set the default antenna.
  */
 void
 ath_setdefantenna(struct ath_softc *sc, u_int antenna)
 {
 	struct ath_hal *ah = sc->sc_ah;
 
 	/* XXX block beacon interrupts */
 	ath_hal_setdefantenna(ah, antenna);
 	if (sc->sc_defant != antenna)
 		sc->sc_stats.ast_ant_defswitch++;
 	sc->sc_defant = antenna;
 	sc->sc_rxotherant = 0;
 }
 
 static void
 ath_txq_init(struct ath_softc *sc, struct ath_txq *txq, int qnum)
 {
 	txq->axq_qnum = qnum;
 	txq->axq_ac = 0;
 	txq->axq_depth = 0;
 	txq->axq_aggr_depth = 0;
 	txq->axq_intrcnt = 0;
 	txq->axq_link = NULL;
 	txq->axq_softc = sc;
 	TAILQ_INIT(&txq->axq_q);
 	TAILQ_INIT(&txq->axq_tidq);
 	TAILQ_INIT(&txq->fifo.axq_q);
 	ATH_TXQ_LOCK_INIT(sc, txq);
 }
 
 /*
  * Setup a h/w transmit queue.
  */
 static struct ath_txq *
 ath_txq_setup(struct ath_softc *sc, int qtype, int subtype)
 {
 #define	N(a)	(sizeof(a)/sizeof(a[0]))
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_TXQ_INFO qi;
 	int qnum;
 
 	memset(&qi, 0, sizeof(qi));
 	qi.tqi_subtype = subtype;
 	qi.tqi_aifs = HAL_TXQ_USEDEFAULT;
 	qi.tqi_cwmin = HAL_TXQ_USEDEFAULT;
 	qi.tqi_cwmax = HAL_TXQ_USEDEFAULT;
 	/*
 	 * Enable interrupts only for EOL and DESC conditions.
 	 * We mark tx descriptors to receive a DESC interrupt
 	 * when a tx queue gets deep; otherwise waiting for the
 	 * EOL to reap descriptors.  Note that this is done to
 	 * reduce interrupt load and this only defers reaping
 	 * descriptors, never transmitting frames.  Aside from
 	 * reducing interrupts this also permits more concurrency.
 	 * The only potential downside is if the tx queue backs
 	 * up in which case the top half of the kernel may backup
 	 * due to a lack of tx descriptors.
 	 */
 	if (sc->sc_isedma)
 		qi.tqi_qflags = HAL_TXQ_TXEOLINT_ENABLE |
 		    HAL_TXQ_TXOKINT_ENABLE;
 	else
 		qi.tqi_qflags = HAL_TXQ_TXEOLINT_ENABLE |
 		    HAL_TXQ_TXDESCINT_ENABLE;
 
 	qnum = ath_hal_setuptxqueue(ah, qtype, &qi);
 	if (qnum == -1) {
 		/*
 		 * NB: don't print a message, this happens
 		 * normally on parts with too few tx queues
 		 */
 		return NULL;
 	}
 	if (qnum >= N(sc->sc_txq)) {
 		device_printf(sc->sc_dev,
 			"hal qnum %u out of range, max %zu!\n",
 			qnum, N(sc->sc_txq));
 		ath_hal_releasetxqueue(ah, qnum);
 		return NULL;
 	}
 	if (!ATH_TXQ_SETUP(sc, qnum)) {
 		ath_txq_init(sc, &sc->sc_txq[qnum], qnum);
 		sc->sc_txqsetup |= 1<sc_txq[qnum];
 #undef N
 }
 
 /*
  * Setup a hardware data transmit queue for the specified
  * access control.  The hal may not support all requested
  * queues in which case it will return a reference to a
  * previously setup queue.  We record the mapping from ac's
  * to h/w queues for use by ath_tx_start and also track
  * the set of h/w queues being used to optimize work in the
  * transmit interrupt handler and related routines.
  */
 static int
 ath_tx_setup(struct ath_softc *sc, int ac, int haltype)
 {
 #define	N(a)	(sizeof(a)/sizeof(a[0]))
 	struct ath_txq *txq;
 
 	if (ac >= N(sc->sc_ac2q)) {
 		device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n",
 			ac, N(sc->sc_ac2q));
 		return 0;
 	}
 	txq = ath_txq_setup(sc, HAL_TX_QUEUE_DATA, haltype);
 	if (txq != NULL) {
 		txq->axq_ac = ac;
 		sc->sc_ac2q[ac] = txq;
 		return 1;
 	} else
 		return 0;
 #undef N
 }
 
 /*
  * Update WME parameters for a transmit queue.
  */
 static int
 ath_txq_update(struct ath_softc *sc, int ac)
 {
 #define	ATH_EXPONENT_TO_VALUE(v)	((1<sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_txq *txq = sc->sc_ac2q[ac];
 	struct wmeParams *wmep = &ic->ic_wme.wme_chanParams.cap_wmeParams[ac];
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_TXQ_INFO qi;
 
 	ath_hal_gettxqueueprops(ah, txq->axq_qnum, &qi);
 #ifdef IEEE80211_SUPPORT_TDMA
 	if (sc->sc_tdma) {
 		/*
 		 * AIFS is zero so there's no pre-transmit wait.  The
 		 * burst time defines the slot duration and is configured
 		 * through net80211.  The QCU is setup to not do post-xmit
 		 * back off, lockout all lower-priority QCU's, and fire
 		 * off the DMA beacon alert timer which is setup based
 		 * on the slot configuration.
 		 */
 		qi.tqi_qflags = HAL_TXQ_TXOKINT_ENABLE
 			      | HAL_TXQ_TXERRINT_ENABLE
 			      | HAL_TXQ_TXURNINT_ENABLE
 			      | HAL_TXQ_TXEOLINT_ENABLE
 			      | HAL_TXQ_DBA_GATED
 			      | HAL_TXQ_BACKOFF_DISABLE
 			      | HAL_TXQ_ARB_LOCKOUT_GLOBAL
 			      ;
 		qi.tqi_aifs = 0;
 		/* XXX +dbaprep? */
 		qi.tqi_readyTime = sc->sc_tdmaslotlen;
 		qi.tqi_burstTime = qi.tqi_readyTime;
 	} else {
 #endif
 		/*
 		 * XXX shouldn't this just use the default flags
 		 * used in the previous queue setup?
 		 */
 		qi.tqi_qflags = HAL_TXQ_TXOKINT_ENABLE
 			      | HAL_TXQ_TXERRINT_ENABLE
 			      | HAL_TXQ_TXDESCINT_ENABLE
 			      | HAL_TXQ_TXURNINT_ENABLE
 			      | HAL_TXQ_TXEOLINT_ENABLE
 			      ;
 		qi.tqi_aifs = wmep->wmep_aifsn;
 		qi.tqi_cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
 		qi.tqi_cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
 		qi.tqi_readyTime = 0;
 		qi.tqi_burstTime = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
 #ifdef IEEE80211_SUPPORT_TDMA
 	}
 #endif
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: Q%u qflags 0x%x aifs %u cwmin %u cwmax %u burstTime %u\n",
 	    __func__, txq->axq_qnum, qi.tqi_qflags,
 	    qi.tqi_aifs, qi.tqi_cwmin, qi.tqi_cwmax, qi.tqi_burstTime);
 
 	if (!ath_hal_settxqueueprops(ah, txq->axq_qnum, &qi)) {
 		if_printf(ifp, "unable to update hardware queue "
 			"parameters for %s traffic!\n",
 			ieee80211_wme_acnames[ac]);
 		return 0;
 	} else {
 		ath_hal_resettxqueue(ah, txq->axq_qnum); /* push to h/w */
 		return 1;
 	}
 #undef ATH_TXOP_TO_US
 #undef ATH_EXPONENT_TO_VALUE
 }
 
 /*
  * Callback from the 802.11 layer to update WME parameters.
  */
 int
 ath_wme_update(struct ieee80211com *ic)
 {
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 
 	return !ath_txq_update(sc, WME_AC_BE) ||
 	    !ath_txq_update(sc, WME_AC_BK) ||
 	    !ath_txq_update(sc, WME_AC_VI) ||
 	    !ath_txq_update(sc, WME_AC_VO) ? EIO : 0;
 }
 
 /*
  * Reclaim resources for a setup queue.
  */
 static void
 ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq)
 {
 
 	ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum);
 	sc->sc_txqsetup &= ~(1<axq_qnum);
 	ATH_TXQ_LOCK_DESTROY(txq);
 }
 
 /*
  * Reclaim all tx queue resources.
  */
 static void
 ath_tx_cleanup(struct ath_softc *sc)
 {
 	int i;
 
 	ATH_TXBUF_LOCK_DESTROY(sc);
 	for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
 		if (ATH_TXQ_SETUP(sc, i))
 			ath_tx_cleanupq(sc, &sc->sc_txq[i]);
 }
 
 /*
  * Return h/w rate index for an IEEE rate (w/o basic rate bit)
  * using the current rates in sc_rixmap.
  */
 int
 ath_tx_findrix(const struct ath_softc *sc, uint8_t rate)
 {
 	int rix = sc->sc_rixmap[rate];
 	/* NB: return lowest rix for invalid rate */
 	return (rix == 0xff ? 0 : rix);
 }
 
 static void
 ath_tx_update_stats(struct ath_softc *sc, struct ath_tx_status *ts,
     struct ath_buf *bf)
 {
 	struct ieee80211_node *ni = bf->bf_node;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	int sr, lr, pri;
 
 	if (ts->ts_status == 0) {
 		u_int8_t txant = ts->ts_antenna;
 		sc->sc_stats.ast_ant_tx[txant]++;
 		sc->sc_ant_tx[txant]++;
 		if (ts->ts_finaltsi != 0)
 			sc->sc_stats.ast_tx_altrate++;
 		pri = M_WME_GETAC(bf->bf_m);
 		if (pri >= WME_AC_VO)
 			ic->ic_wme.wme_hipri_traffic++;
 		if ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)
 			ni->ni_inact = ni->ni_inact_reload;
 	} else {
 		if (ts->ts_status & HAL_TXERR_XRETRY)
 			sc->sc_stats.ast_tx_xretries++;
 		if (ts->ts_status & HAL_TXERR_FIFO)
 			sc->sc_stats.ast_tx_fifoerr++;
 		if (ts->ts_status & HAL_TXERR_FILT)
 			sc->sc_stats.ast_tx_filtered++;
 		if (ts->ts_status & HAL_TXERR_XTXOP)
 			sc->sc_stats.ast_tx_xtxop++;
 		if (ts->ts_status & HAL_TXERR_TIMER_EXPIRED)
 			sc->sc_stats.ast_tx_timerexpired++;
 
 		if (bf->bf_m->m_flags & M_FF)
 			sc->sc_stats.ast_ff_txerr++;
 	}
 	/* XXX when is this valid? */
 	if (ts->ts_flags & HAL_TX_DESC_CFG_ERR)
 		sc->sc_stats.ast_tx_desccfgerr++;
 	/*
 	 * This can be valid for successful frame transmission!
 	 * If there's a TX FIFO underrun during aggregate transmission,
 	 * the MAC will pad the rest of the aggregate with delimiters.
 	 * If a BA is returned, the frame is marked as "OK" and it's up
 	 * to the TX completion code to notice which frames weren't
 	 * successfully transmitted.
 	 */
 	if (ts->ts_flags & HAL_TX_DATA_UNDERRUN)
 		sc->sc_stats.ast_tx_data_underrun++;
 	if (ts->ts_flags & HAL_TX_DELIM_UNDERRUN)
 		sc->sc_stats.ast_tx_delim_underrun++;
 
 	sr = ts->ts_shortretry;
 	lr = ts->ts_longretry;
 	sc->sc_stats.ast_tx_shortretry += sr;
 	sc->sc_stats.ast_tx_longretry += lr;
 
 }
 
 /*
  * The default completion. If fail is 1, this means
  * "please don't retry the frame, and just return -1 status
  * to the net80211 stack.
  */
 void
 ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, int fail)
 {
 	struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
 	int st;
 
 	if (fail == 1)
 		st = -1;
 	else
 		st = ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0) ?
 		    ts->ts_status : HAL_TXERR_XRETRY;
 
 #if 0
 	if (bf->bf_state.bfs_dobaw)
 		device_printf(sc->sc_dev,
 		    "%s: bf %p: seqno %d: dobaw should've been cleared!\n",
 		    __func__,
 		    bf,
 		    SEQNO(bf->bf_state.bfs_seqno));
 #endif
 	if (bf->bf_next != NULL)
 		device_printf(sc->sc_dev,
 		    "%s: bf %p: seqno %d: bf_next not NULL!\n",
 		    __func__,
 		    bf,
 		    SEQNO(bf->bf_state.bfs_seqno));
 
 	/*
 	 * Check if the node software queue is empty; if so
 	 * then clear the TIM.
 	 *
 	 * This needs to be done before the buffer is freed as
 	 * otherwise the node reference will have been released
 	 * and the node may not actually exist any longer.
 	 *
 	 * XXX I don't like this belonging here, but it's cleaner
 	 * to do it here right now then all the other places
 	 * where ath_tx_default_comp() is called.
 	 *
 	 * XXX TODO: during drain, ensure that the callback is
 	 * being called so we get a chance to update the TIM.
 	 */
 	if (bf->bf_node)
 		ath_tx_update_tim(sc, bf->bf_node, 0);
 
 	/*
 	 * Do any tx complete callback.  Note this must
 	 * be done before releasing the node reference.
 	 * This will free the mbuf, release the net80211
 	 * node and recycle the ath_buf.
 	 */
 	ath_tx_freebuf(sc, bf, st);
 }
 
 /*
  * Update rate control with the given completion status.
  */
 void
 ath_tx_update_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni,
     struct ath_rc_series *rc, struct ath_tx_status *ts, int frmlen,
     int nframes, int nbad)
 {
 	struct ath_node *an;
 
 	/* Only for unicast frames */
 	if (ni == NULL)
 		return;
 
 	an = ATH_NODE(ni);
 	ATH_NODE_UNLOCK_ASSERT(an);
 
 	if ((ts->ts_status & HAL_TXERR_FILT) == 0) {
 		ATH_NODE_LOCK(an);
 		ath_rate_tx_complete(sc, an, rc, ts, frmlen, nframes, nbad);
 		ATH_NODE_UNLOCK(an);
 	}
 }
 
 /*
  * Process the completion of the given buffer.
  *
  * This calls the rate control update and then the buffer completion.
  * This will either free the buffer or requeue it.  In any case, the
  * bf pointer should be treated as invalid after this function is called.
  */
 void
 ath_tx_process_buf_completion(struct ath_softc *sc, struct ath_txq *txq,
     struct ath_tx_status *ts, struct ath_buf *bf)
 {
 	struct ieee80211_node *ni = bf->bf_node;
 	struct ath_node *an = NULL;
 
 	ATH_TX_UNLOCK_ASSERT(sc);
 
 	/* If unicast frame, update general statistics */
 	if (ni != NULL) {
 		an = ATH_NODE(ni);
 		/* update statistics */
 		ath_tx_update_stats(sc, ts, bf);
 	}
 
 	/*
 	 * Call the completion handler.
 	 * The completion handler is responsible for
 	 * calling the rate control code.
 	 *
 	 * Frames with no completion handler get the
 	 * rate control code called here.
 	 */
 	if (bf->bf_comp == NULL) {
 		if ((ts->ts_status & HAL_TXERR_FILT) == 0 &&
 		    (bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0) {
 			/*
 			 * XXX assume this isn't an aggregate
 			 * frame.
 			 */
 			ath_tx_update_ratectrl(sc, ni,
 			     bf->bf_state.bfs_rc, ts,
 			    bf->bf_state.bfs_pktlen, 1,
 			    (ts->ts_status == 0 ? 0 : 1));
 		}
 		ath_tx_default_comp(sc, bf, 0);
 	} else
 		bf->bf_comp(sc, bf, 0);
 }
 
 
 
 /*
  * Process completed xmit descriptors from the specified queue.
  * Kick the packet scheduler if needed. This can occur from this
  * particular task.
  */
 static int
 ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq, int dosched)
 {
 	struct ath_hal *ah = sc->sc_ah;
 	struct ath_buf *bf;
 	struct ath_desc *ds;
 	struct ath_tx_status *ts;
 	struct ieee80211_node *ni;
 #ifdef	IEEE80211_SUPPORT_SUPERG
 	struct ieee80211com *ic = sc->sc_ifp->if_l2com;
 #endif	/* IEEE80211_SUPPORT_SUPERG */
 	int nacked;
 	HAL_STATUS status;
 
 	DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %u head %p link %p\n",
 		__func__, txq->axq_qnum,
 		(caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum),
 		txq->axq_link);
 
 	ATH_KTR(sc, ATH_KTR_TXCOMP, 4,
 	    "ath_tx_processq: txq=%u head %p link %p depth %p",
 	    txq->axq_qnum,
 	    (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum),
 	    txq->axq_link,
 	    txq->axq_depth);
 
 	nacked = 0;
 	for (;;) {
 		ATH_TXQ_LOCK(txq);
 		txq->axq_intrcnt = 0;	/* reset periodic desc intr count */
 		bf = TAILQ_FIRST(&txq->axq_q);
 		if (bf == NULL) {
 			ATH_TXQ_UNLOCK(txq);
 			break;
 		}
 		ds = bf->bf_lastds;	/* XXX must be setup correctly! */
 		ts = &bf->bf_status.ds_txstat;
 
 		status = ath_hal_txprocdesc(ah, ds, ts);
 #ifdef ATH_DEBUG
 		if (sc->sc_debug & ATH_DEBUG_XMIT_DESC)
 			ath_printtxbuf(sc, bf, txq->axq_qnum, 0,
 			    status == HAL_OK);
 		else if ((sc->sc_debug & ATH_DEBUG_RESET) && (dosched == 0))
 			ath_printtxbuf(sc, bf, txq->axq_qnum, 0,
 			    status == HAL_OK);
 #endif
 #ifdef	ATH_DEBUG_ALQ
 		if (if_ath_alq_checkdebug(&sc->sc_alq,
 		    ATH_ALQ_EDMA_TXSTATUS)) {
 			if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS,
 			sc->sc_tx_statuslen,
 			(char *) ds);
 		}
 #endif
 
 		if (status == HAL_EINPROGRESS) {
 			ATH_KTR(sc, ATH_KTR_TXCOMP, 3,
 			    "ath_tx_processq: txq=%u, bf=%p ds=%p, HAL_EINPROGRESS",
 			    txq->axq_qnum, bf, ds);
 			ATH_TXQ_UNLOCK(txq);
 			break;
 		}
 		ATH_TXQ_REMOVE(txq, bf, bf_list);
 		if (txq->axq_depth > 0) {
 			/*
 			 * More frames follow.  Mark the buffer busy
 			 * so it's not re-used while the hardware may
 			 * still re-read the link field in the descriptor.
 			 *
 			 * Use the last buffer in an aggregate as that
 			 * is where the hardware may be - intermediate
 			 * descriptors won't be "busy".
 			 */
 			bf->bf_last->bf_flags |= ATH_BUF_BUSY;
 		} else
 			txq->axq_link = NULL;
 		if (bf->bf_state.bfs_aggr)
 			txq->axq_aggr_depth--;
 
 		ni = bf->bf_node;
 
 		ATH_KTR(sc, ATH_KTR_TXCOMP, 5,
 		    "ath_tx_processq: txq=%u, bf=%p, ds=%p, ni=%p, ts_status=0x%08x",
 		    txq->axq_qnum, bf, ds, ni, ts->ts_status);
 		/*
 		 * If unicast frame was ack'd update RSSI,
 		 * including the last rx time used to
 		 * workaround phantom bmiss interrupts.
 		 */
 		if (ni != NULL && ts->ts_status == 0 &&
 		    ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) {
 			nacked++;
 			sc->sc_stats.ast_tx_rssi = ts->ts_rssi;
 			ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi,
 				ts->ts_rssi);
 		}
 		ATH_TXQ_UNLOCK(txq);
 
 		/*
 		 * Update statistics and call completion
 		 */
 		ath_tx_process_buf_completion(sc, txq, ts, bf);
 
 		/* XXX at this point, bf and ni may be totally invalid */
 	}
 #ifdef IEEE80211_SUPPORT_SUPERG
 	/*
 	 * Flush fast-frame staging queue when traffic slows.
 	 */
 	if (txq->axq_depth <= 1)
 		ieee80211_ff_flush(ic, txq->axq_ac);
 #endif
 
 	/* Kick the software TXQ scheduler */
 	if (dosched) {
 		ATH_TX_LOCK(sc);
 		ath_txq_sched(sc, txq);
 		ATH_TX_UNLOCK(sc);
 	}
 
 	ATH_KTR(sc, ATH_KTR_TXCOMP, 1,
 	    "ath_tx_processq: txq=%u: done",
 	    txq->axq_qnum);
 
 	return nacked;
 }
 
 #define	TXQACTIVE(t, q)		( (t) & (1 << (q)))
 
 /*
  * Deferred processing of transmit interrupt; special-cased
  * for a single hardware transmit queue (e.g. 5210 and 5211).
  */
 static void
 ath_tx_proc_q0(void *arg, int npending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	uint32_t txqs;
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt++;
 	txqs = sc->sc_txq_active;
 	sc->sc_txq_active &= ~txqs;
 	ATH_PCU_UNLOCK(sc);
 
 	ATH_KTR(sc, ATH_KTR_TXCOMP, 1,
 	    "ath_tx_proc_q0: txqs=0x%08x", txqs);
 
 	if (TXQACTIVE(txqs, 0) && ath_tx_processq(sc, &sc->sc_txq[0], 1))
 		/* XXX why is lastrx updated in tx code? */
 		sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah);
 	if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum))
 		ath_tx_processq(sc, sc->sc_cabq, 1);
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 	sc->sc_wd_timer = 0;
 
 	if (sc->sc_softled)
 		ath_led_event(sc, sc->sc_txrix);
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt--;
 	ATH_PCU_UNLOCK(sc);
 
 	ath_tx_kick(sc);
 }
 
 /*
  * Deferred processing of transmit interrupt; special-cased
  * for four hardware queues, 0-3 (e.g. 5212 w/ WME support).
  */
 static void
 ath_tx_proc_q0123(void *arg, int npending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	int nacked;
 	uint32_t txqs;
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt++;
 	txqs = sc->sc_txq_active;
 	sc->sc_txq_active &= ~txqs;
 	ATH_PCU_UNLOCK(sc);
 
 	ATH_KTR(sc, ATH_KTR_TXCOMP, 1,
 	    "ath_tx_proc_q0123: txqs=0x%08x", txqs);
 
 	/*
 	 * Process each active queue.
 	 */
 	nacked = 0;
 	if (TXQACTIVE(txqs, 0))
 		nacked += ath_tx_processq(sc, &sc->sc_txq[0], 1);
 	if (TXQACTIVE(txqs, 1))
 		nacked += ath_tx_processq(sc, &sc->sc_txq[1], 1);
 	if (TXQACTIVE(txqs, 2))
 		nacked += ath_tx_processq(sc, &sc->sc_txq[2], 1);
 	if (TXQACTIVE(txqs, 3))
 		nacked += ath_tx_processq(sc, &sc->sc_txq[3], 1);
 	if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum))
 		ath_tx_processq(sc, sc->sc_cabq, 1);
 	if (nacked)
 		sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah);
 
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 	sc->sc_wd_timer = 0;
 
 	if (sc->sc_softled)
 		ath_led_event(sc, sc->sc_txrix);
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt--;
 	ATH_PCU_UNLOCK(sc);
 
 	ath_tx_kick(sc);
 }
 
 /*
  * Deferred processing of transmit interrupt.
  */
 static void
 ath_tx_proc(void *arg, int npending)
 {
 	struct ath_softc *sc = arg;
 	struct ifnet *ifp = sc->sc_ifp;
 	int i, nacked;
 	uint32_t txqs;
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt++;
 	txqs = sc->sc_txq_active;
 	sc->sc_txq_active &= ~txqs;
 	ATH_PCU_UNLOCK(sc);
 
 	ATH_KTR(sc, ATH_KTR_TXCOMP, 1, "ath_tx_proc: txqs=0x%08x", txqs);
 
 	/*
 	 * Process each active queue.
 	 */
 	nacked = 0;
 	for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
 		if (ATH_TXQ_SETUP(sc, i) && TXQACTIVE(txqs, i))
 			nacked += ath_tx_processq(sc, &sc->sc_txq[i], 1);
 	if (nacked)
 		sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah);
 
 	/* XXX check this inside of IF_LOCK? */
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 	sc->sc_wd_timer = 0;
 
 	if (sc->sc_softled)
 		ath_led_event(sc, sc->sc_txrix);
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt--;
 	ATH_PCU_UNLOCK(sc);
 
 	ath_tx_kick(sc);
 }
 #undef	TXQACTIVE
 
 /*
  * Deferred processing of TXQ rescheduling.
  */
 static void
 ath_txq_sched_tasklet(void *arg, int npending)
 {
 	struct ath_softc *sc = arg;
 	int i;
 
 	/* XXX is skipping ok? */
 	ATH_PCU_LOCK(sc);
 #if 0
 	if (sc->sc_inreset_cnt > 0) {
 		device_printf(sc->sc_dev,
 		    "%s: sc_inreset_cnt > 0; skipping\n", __func__);
 		ATH_PCU_UNLOCK(sc);
 		return;
 	}
 #endif
 	sc->sc_txproc_cnt++;
 	ATH_PCU_UNLOCK(sc);
 
 	ATH_TX_LOCK(sc);
 	for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
 		if (ATH_TXQ_SETUP(sc, i)) {
 			ath_txq_sched(sc, &sc->sc_txq[i]);
 		}
 	}
 	ATH_TX_UNLOCK(sc);
 
 	ATH_PCU_LOCK(sc);
 	sc->sc_txproc_cnt--;
 	ATH_PCU_UNLOCK(sc);
 }
 
 void
 ath_returnbuf_tail(struct ath_softc *sc, struct ath_buf *bf)
 {
 
 	ATH_TXBUF_LOCK_ASSERT(sc);
 
 	if (bf->bf_flags & ATH_BUF_MGMT)
 		TAILQ_INSERT_TAIL(&sc->sc_txbuf_mgmt, bf, bf_list);
 	else {
 		TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
 		sc->sc_txbuf_cnt++;
 		if (sc->sc_txbuf_cnt > ath_txbuf) {
 			device_printf(sc->sc_dev,
 			    "%s: sc_txbuf_cnt > %d?\n",
 			    __func__,
 			    ath_txbuf);
 			sc->sc_txbuf_cnt = ath_txbuf;
 		}
 	}
 }
 
 void
 ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf)
 {
 
 	ATH_TXBUF_LOCK_ASSERT(sc);
 
 	if (bf->bf_flags & ATH_BUF_MGMT)
 		TAILQ_INSERT_HEAD(&sc->sc_txbuf_mgmt, bf, bf_list);
 	else {
 		TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list);
 		sc->sc_txbuf_cnt++;
 		if (sc->sc_txbuf_cnt > ATH_TXBUF) {
 			device_printf(sc->sc_dev,
 			    "%s: sc_txbuf_cnt > %d?\n",
 			    __func__,
 			    ATH_TXBUF);
 			sc->sc_txbuf_cnt = ATH_TXBUF;
 		}
 	}
 }
 
 /*
  * Free the holding buffer if it exists
  */
 void
 ath_txq_freeholdingbuf(struct ath_softc *sc, struct ath_txq *txq)
 {
 	ATH_TXBUF_LOCK_ASSERT(sc);
 
 	if (txq->axq_holdingbf == NULL)
 		return;
 
 	txq->axq_holdingbf->bf_flags &= ~ATH_BUF_BUSY;
 	ath_returnbuf_tail(sc, txq->axq_holdingbf);
 	txq->axq_holdingbf = NULL;
 }
 
 /*
  * Add this buffer to the holding queue, freeing the previous
  * one if it exists.
  */
 static void
 ath_txq_addholdingbuf(struct ath_softc *sc, struct ath_buf *bf)
 {
 	struct ath_txq *txq;
 
 	ATH_TXBUF_LOCK_ASSERT(sc);
 
 	/* XXX assert ATH_BUF_BUSY is set */
 
 	/* XXX assert the tx queue is under the max number */
 	if (bf->bf_state.bfs_tx_queue > HAL_NUM_TX_QUEUES) {
 		device_printf(sc->sc_dev, "%s: bf=%p: invalid tx queue (%d)\n",
 		    __func__,
 		    bf,
 		    bf->bf_state.bfs_tx_queue);
 		bf->bf_flags &= ~ATH_BUF_BUSY;
 		ath_returnbuf_tail(sc, bf);
 		return;
 	}
 	txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue];
 	ath_txq_freeholdingbuf(sc, txq);
 	txq->axq_holdingbf = bf;
 }
 
 /*
  * Return a buffer to the pool and update the 'busy' flag on the
  * previous 'tail' entry.
  *
  * This _must_ only be called when the buffer is involved in a completed
  * TX. The logic is that if it was part of an active TX, the previous
  * buffer on the list is now not involved in a halted TX DMA queue, waiting
  * for restart (eg for TDMA.)
  *
  * The caller must free the mbuf and recycle the node reference.
  */
 void
 ath_freebuf(struct ath_softc *sc, struct ath_buf *bf)
 {
 	KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__));
 	KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__));
 
 	/*
 	 * If this buffer is busy, push it onto the holding queue
 	 */
 	if (bf->bf_flags & ATH_BUF_BUSY) {
 		ATH_TXBUF_LOCK(sc);
 		ath_txq_addholdingbuf(sc, bf);
 		ATH_TXBUF_UNLOCK(sc);
 		return;
 	}
 
 	/*
 	 * Not a busy buffer, so free normally
 	 */
 	ATH_TXBUF_LOCK(sc);
 	ath_returnbuf_tail(sc, bf);
 	ATH_TXBUF_UNLOCK(sc);
 }
 
 /*
  * This is currently used by ath_tx_draintxq() and
  * ath_tx_tid_free_pkts().
  *
  * It recycles a single ath_buf.
  */
 void
 ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status)
 {
 	struct ieee80211_node *ni = bf->bf_node;
 	struct mbuf *m0 = bf->bf_m;
 
 	/*
 	 * Make sure that we only sync/unload if there's an mbuf.
 	 * If not (eg we cloned a buffer), the unload will have already
 	 * occured.
 	 */
 	if (bf->bf_m != NULL) {
 		bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
 		    BUS_DMASYNC_POSTWRITE);
 		bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
 	}
 
 	bf->bf_node = NULL;
 	bf->bf_m = NULL;
 
 	/* Free the buffer, it's not needed any longer */
 	ath_freebuf(sc, bf);
 
 	if (ni != NULL) {
 		/*
 		 * Do any callback and reclaim the node reference.
 		 */
 		if (m0->m_flags & M_TXCB)
 			ieee80211_process_callback(ni, m0, status);
 		ieee80211_free_node(ni);
 	}
 
 	/* Finally, we don't need this mbuf any longer */
 	m_freem(m0);
 }
 
 static struct ath_buf *
 ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq)
 {
 	struct ath_buf *bf;
 
 	ATH_TXQ_LOCK_ASSERT(txq);
 
 	/*
 	 * Drain the FIFO queue first, then if it's
 	 * empty, move to the normal frame queue.
 	 */
 	bf = TAILQ_FIRST(&txq->fifo.axq_q);
 	if (bf != NULL) {
 		/*
 		 * Is it the last buffer in this set?
 		 * Decrement the FIFO counter.
 		 */
 		if (bf->bf_flags & ATH_BUF_FIFOEND) {
 			if (txq->axq_fifo_depth == 0) {
 				device_printf(sc->sc_dev,
 				    "%s: Q%d: fifo_depth=0, fifo.axq_depth=%d?\n",
 				    __func__,
 				    txq->axq_qnum,
 				    txq->fifo.axq_depth);
 			} else
 				txq->axq_fifo_depth--;
 		}
 		ATH_TXQ_REMOVE(&txq->fifo, bf, bf_list);
 		return (bf);
 	}
 
 	/*
 	 * Debugging!
 	 */
 	if (txq->axq_fifo_depth != 0 || txq->fifo.axq_depth != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: Q%d: fifo_depth=%d, fifo.axq_depth=%d\n",
 		    __func__,
 		    txq->axq_qnum,
 		    txq->axq_fifo_depth,
 		    txq->fifo.axq_depth);
 	}
 
 	/*
 	 * Now drain the pending queue.
 	 */
 	bf = TAILQ_FIRST(&txq->axq_q);
 	if (bf == NULL) {
 		txq->axq_link = NULL;
 		return (NULL);
 	}
 	ATH_TXQ_REMOVE(txq, bf, bf_list);
 	return (bf);
 }
 
 void
 ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq)
 {
 #ifdef ATH_DEBUG
 	struct ath_hal *ah = sc->sc_ah;
 #endif
 	struct ath_buf *bf;
 	u_int ix;
 
 	/*
 	 * NB: this assumes output has been stopped and
 	 *     we do not need to block ath_tx_proc
 	 */
 	for (ix = 0;; ix++) {
 		ATH_TXQ_LOCK(txq);
 		bf = ath_tx_draintxq_get_one(sc, txq);
 		if (bf == NULL) {
 			ATH_TXQ_UNLOCK(txq);
 			break;
 		}
 		if (bf->bf_state.bfs_aggr)
 			txq->axq_aggr_depth--;
 #ifdef ATH_DEBUG
 		if (sc->sc_debug & ATH_DEBUG_RESET) {
 			struct ieee80211com *ic = sc->sc_ifp->if_l2com;
 			int status = 0;
 
 			/*
 			 * EDMA operation has a TX completion FIFO
 			 * separate from the TX descriptor, so this
 			 * method of checking the "completion" status
 			 * is wrong.
 			 */
 			if (! sc->sc_isedma) {
 				status = (ath_hal_txprocdesc(ah,
 				    bf->bf_lastds,
 				    &bf->bf_status.ds_txstat) == HAL_OK);
 			}
 			ath_printtxbuf(sc, bf, txq->axq_qnum, ix, status);
 			ieee80211_dump_pkt(ic, mtod(bf->bf_m, const uint8_t *),
 			    bf->bf_m->m_len, 0, -1);
 		}
 #endif /* ATH_DEBUG */
 		/*
 		 * Since we're now doing magic in the completion
 		 * functions, we -must- call it for aggregation
 		 * destinations or BAW tracking will get upset.
 		 */
 		/*
 		 * Clear ATH_BUF_BUSY; the completion handler
 		 * will free the buffer.
 		 */
 		ATH_TXQ_UNLOCK(txq);
 		bf->bf_flags &= ~ATH_BUF_BUSY;
 		if (bf->bf_comp)
 			bf->bf_comp(sc, bf, 1);
 		else
 			ath_tx_default_comp(sc, bf, 1);
 	}
 
 	/*
 	 * Free the holding buffer if it exists
 	 */
 	ATH_TXBUF_LOCK(sc);
 	ath_txq_freeholdingbuf(sc, txq);
 	ATH_TXBUF_UNLOCK(sc);
 
 	/*
 	 * Drain software queued frames which are on
 	 * active TIDs.
 	 */
 	ath_tx_txq_drain(sc, txq);
 }
 
 static void
 ath_tx_stopdma(struct ath_softc *sc, struct ath_txq *txq)
 {
 	struct ath_hal *ah = sc->sc_ah;
 
 	DPRINTF(sc, ATH_DEBUG_RESET,
 	    "%s: tx queue [%u] %p, flags 0x%08x, link %p\n",
 	    __func__,
 	    txq->axq_qnum,
 	    (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, txq->axq_qnum),
 	    txq->axq_flags,
 	    txq->axq_link);
 	(void) ath_hal_stoptxdma(ah, txq->axq_qnum);
 }
 
 int
 ath_stoptxdma(struct ath_softc *sc)
 {
 	struct ath_hal *ah = sc->sc_ah;
 	int i;
 
 	/* XXX return value */
 	if (sc->sc_invalid)
 		return 0;
 
 	if (!sc->sc_invalid) {
 		/* don't touch the hardware if marked invalid */
 		DPRINTF(sc, ATH_DEBUG_RESET, "%s: tx queue [%u] %p, link %p\n",
 		    __func__, sc->sc_bhalq,
 		    (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq),
 		    NULL);
 		(void) ath_hal_stoptxdma(ah, sc->sc_bhalq);
 		for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
 			if (ATH_TXQ_SETUP(sc, i))
 				ath_tx_stopdma(sc, &sc->sc_txq[i]);
 	}
 
 	return 1;
 }
 
 /*
  * Drain the transmit queues and reclaim resources.
  */
 void
 ath_legacy_tx_drain(struct ath_softc *sc, ATH_RESET_TYPE reset_type)
 {
 #ifdef	ATH_DEBUG
 	struct ath_hal *ah = sc->sc_ah;
 #endif
 	struct ifnet *ifp = sc->sc_ifp;
 	int i;
 
 	(void) ath_stoptxdma(sc);
 
 	for (i = 0; i < HAL_NUM_TX_QUEUES; i++) {
 		/*
 		 * XXX TODO: should we just handle the completed TX frames
 		 * here, whether or not the reset is a full one or not?
 		 */
 		if (ATH_TXQ_SETUP(sc, i)) {
 			if (reset_type == ATH_RESET_NOLOSS)
 				ath_tx_processq(sc, &sc->sc_txq[i], 0);
 			else
 				ath_tx_draintxq(sc, &sc->sc_txq[i]);
 		}
 	}
 #ifdef ATH_DEBUG
 	if (sc->sc_debug & ATH_DEBUG_RESET) {
 		struct ath_buf *bf = TAILQ_FIRST(&sc->sc_bbuf);
 		if (bf != NULL && bf->bf_m != NULL) {
 			ath_printtxbuf(sc, bf, sc->sc_bhalq, 0,
 				ath_hal_txprocdesc(ah, bf->bf_lastds,
 				    &bf->bf_status.ds_txstat) == HAL_OK);
 			ieee80211_dump_pkt(ifp->if_l2com,
 			    mtod(bf->bf_m, const uint8_t *), bf->bf_m->m_len,
 			    0, -1);
 		}
 	}
 #endif /* ATH_DEBUG */
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 	sc->sc_wd_timer = 0;
 }
 
 /*
  * Update internal state after a channel change.
  */
 static void
 ath_chan_change(struct ath_softc *sc, struct ieee80211_channel *chan)
 {
 	enum ieee80211_phymode mode;
 
 	/*
 	 * Change channels and update the h/w rate map
 	 * if we're switching; e.g. 11a to 11b/g.
 	 */
 	mode = ieee80211_chan2mode(chan);
 	if (mode != sc->sc_curmode)
 		ath_setcurmode(sc, mode);
 	sc->sc_curchan = chan;
 }
 
 /*
  * Set/change channels.  If the channel is really being changed,
  * it's done by resetting the chip.  To accomplish this we must
  * first cleanup any pending DMA, then restart stuff after a la
  * ath_init.
  */
 static int
 ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	int ret = 0;
 
 	/* Treat this as an interface reset */
 	ATH_PCU_UNLOCK_ASSERT(sc);
 	ATH_UNLOCK_ASSERT(sc);
 
 	/* (Try to) stop TX/RX from occuring */
 	taskqueue_block(sc->sc_tq);
 
 	ATH_PCU_LOCK(sc);
 	ath_hal_intrset(ah, 0);		/* Stop new RX/TX completion */
 	ath_txrx_stop_locked(sc);	/* Stop pending RX/TX completion */
 	if (ath_reset_grablock(sc, 1) == 0) {
 		device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n",
 		    __func__);
 	}
 	ATH_PCU_UNLOCK(sc);
 
 	DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, flags 0x%x)\n",
 	    __func__, ieee80211_chan2ieee(ic, chan),
 	    chan->ic_freq, chan->ic_flags);
 	if (chan != sc->sc_curchan) {
 		HAL_STATUS status;
 		/*
 		 * To switch channels clear any pending DMA operations;
 		 * wait long enough for the RX fifo to drain, reset the
 		 * hardware at the new frequency, and then re-enable
 		 * the relevant bits of the h/w.
 		 */
 #if 0
 		ath_hal_intrset(ah, 0);		/* disable interrupts */
 #endif
 		ath_stoprecv(sc, 1);		/* turn off frame recv */
 		/*
 		 * First, handle completed TX/RX frames.
 		 */
 		ath_rx_flush(sc);
 		ath_draintxq(sc, ATH_RESET_NOLOSS);
 		/*
 		 * Next, flush the non-scheduled frames.
 		 */
 		ath_draintxq(sc, ATH_RESET_FULL);	/* clear pending tx frames */
 
 		ath_update_chainmasks(sc, chan);
 		ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
 		    sc->sc_cur_rxchainmask);
 		if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, &status)) {
 			if_printf(ifp, "%s: unable to reset "
 			    "channel %u (%u MHz, flags 0x%x), hal status %u\n",
 			    __func__, ieee80211_chan2ieee(ic, chan),
 			    chan->ic_freq, chan->ic_flags, status);
 			ret = EIO;
 			goto finish;
 		}
 		sc->sc_diversity = ath_hal_getdiversity(ah);
 
 		/* Let DFS at it in case it's a DFS channel */
 		ath_dfs_radar_enable(sc, chan);
 
 		/* Let spectral at in case spectral is enabled */
 		ath_spectral_enable(sc, chan);
 
 		/*
 		 * Re-enable rx framework.
 		 */
 		if (ath_startrecv(sc) != 0) {
 			if_printf(ifp, "%s: unable to restart recv logic\n",
 			    __func__);
 			ret = EIO;
 			goto finish;
 		}
 
 		/*
 		 * Change channels and update the h/w rate map
 		 * if we're switching; e.g. 11a to 11b/g.
 		 */
 		ath_chan_change(sc, chan);
 
 		/*
 		 * Reset clears the beacon timers; reset them
 		 * here if needed.
 		 */
 		if (sc->sc_beacons) {		/* restart beacons */
 #ifdef IEEE80211_SUPPORT_TDMA
 			if (sc->sc_tdma)
 				ath_tdma_config(sc, NULL);
 			else
 #endif
 			ath_beacon_config(sc, NULL);
 		}
 
 		/*
 		 * Re-enable interrupts.
 		 */
 #if 0
 		ath_hal_intrset(ah, sc->sc_imask);
 #endif
 	}
 
 finish:
 	ATH_PCU_LOCK(sc);
 	sc->sc_inreset_cnt--;
 	/* XXX only do this if sc_inreset_cnt == 0? */
 	ath_hal_intrset(ah, sc->sc_imask);
 	ATH_PCU_UNLOCK(sc);
 
 	IF_LOCK(&ifp->if_snd);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	IF_UNLOCK(&ifp->if_snd);
 	ath_txrx_start(sc);
 	/* XXX ath_start? */
 
 	return ret;
 }
 
 /*
  * Periodically recalibrate the PHY to account
  * for temperature/environment changes.
  */
 static void
 ath_calibrate(void *arg)
 {
 	struct ath_softc *sc = arg;
 	struct ath_hal *ah = sc->sc_ah;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	HAL_BOOL longCal, isCalDone = AH_TRUE;
 	HAL_BOOL aniCal, shortCal = AH_FALSE;
 	int nextcal;
 
 	if (ic->ic_flags & IEEE80211_F_SCAN)	/* defer, off channel */
 		goto restart;
 	longCal = (ticks - sc->sc_lastlongcal >= ath_longcalinterval*hz);
 	aniCal = (ticks - sc->sc_lastani >= ath_anicalinterval*hz/1000);
 	if (sc->sc_doresetcal)
 		shortCal = (ticks - sc->sc_lastshortcal >= ath_shortcalinterval*hz/1000);
 
 	DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: shortCal=%d; longCal=%d; aniCal=%d\n", __func__, shortCal, longCal, aniCal);
 	if (aniCal) {
 		sc->sc_stats.ast_ani_cal++;
 		sc->sc_lastani = ticks;
 		ath_hal_ani_poll(ah, sc->sc_curchan);
 	}
 
 	if (longCal) {
 		sc->sc_stats.ast_per_cal++;
 		sc->sc_lastlongcal = ticks;
 		if (ath_hal_getrfgain(ah) == HAL_RFGAIN_NEED_CHANGE) {
 			/*
 			 * Rfgain is out of bounds, reset the chip
 			 * to load new gain values.
 			 */
 			DPRINTF(sc, ATH_DEBUG_CALIBRATE,
 				"%s: rfgain change\n", __func__);
 			sc->sc_stats.ast_per_rfgain++;
 			sc->sc_resetcal = 0;
 			sc->sc_doresetcal = AH_TRUE;
 			taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask);
 			callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc);
 			return;
 		}
 		/*
 		 * If this long cal is after an idle period, then
 		 * reset the data collection state so we start fresh.
 		 */
 		if (sc->sc_resetcal) {
 			(void) ath_hal_calreset(ah, sc->sc_curchan);
 			sc->sc_lastcalreset = ticks;
 			sc->sc_lastshortcal = ticks;
 			sc->sc_resetcal = 0;
 			sc->sc_doresetcal = AH_TRUE;
 		}
 	}
 
 	/* Only call if we're doing a short/long cal, not for ANI calibration */
 	if (shortCal || longCal) {
 		isCalDone = AH_FALSE;
 		if (ath_hal_calibrateN(ah, sc->sc_curchan, longCal, &isCalDone)) {
 			if (longCal) {
 				/*
 				 * Calibrate noise floor data again in case of change.
 				 */
 				ath_hal_process_noisefloor(ah);
 			}
 		} else {
 			DPRINTF(sc, ATH_DEBUG_ANY,
 				"%s: calibration of channel %u failed\n",
 				__func__, sc->sc_curchan->ic_freq);
 			sc->sc_stats.ast_per_calfail++;
 		}
 		if (shortCal)
 			sc->sc_lastshortcal = ticks;
 	}
 	if (!isCalDone) {
 restart:
 		/*
 		 * Use a shorter interval to potentially collect multiple
 		 * data samples required to complete calibration.  Once
 		 * we're told the work is done we drop back to a longer
 		 * interval between requests.  We're more aggressive doing
 		 * work when operating as an AP to improve operation right
 		 * after startup.
 		 */
 		sc->sc_lastshortcal = ticks;
 		nextcal = ath_shortcalinterval*hz/1000;
 		if (sc->sc_opmode != HAL_M_HOSTAP)
 			nextcal *= 10;
 		sc->sc_doresetcal = AH_TRUE;
 	} else {
 		/* nextcal should be the shortest time for next event */
 		nextcal = ath_longcalinterval*hz;
 		if (sc->sc_lastcalreset == 0)
 			sc->sc_lastcalreset = sc->sc_lastlongcal;
 		else if (ticks - sc->sc_lastcalreset >= ath_resetcalinterval*hz)
 			sc->sc_resetcal = 1;	/* setup reset next trip */
 		sc->sc_doresetcal = AH_FALSE;
 	}
 	/* ANI calibration may occur more often than short/long/resetcal */
 	if (ath_anicalinterval > 0)
 		nextcal = MIN(nextcal, ath_anicalinterval*hz/1000);
 
 	if (nextcal != 0) {
 		DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: next +%u (%sisCalDone)\n",
 		    __func__, nextcal, isCalDone ? "" : "!");
 		callout_reset(&sc->sc_cal_ch, nextcal, ath_calibrate, sc);
 	} else {
 		DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: calibration disabled\n",
 		    __func__);
 		/* NB: don't rearm timer */
 	}
 }
 
 static void
 ath_scan_start(struct ieee80211com *ic)
 {
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 	u_int32_t rfilt;
 
 	/* XXX calibration timer? */
 
 	ATH_LOCK(sc);
 	sc->sc_scanning = 1;
 	sc->sc_syncbeacon = 0;
 	rfilt = ath_calcrxfilter(sc);
 	ATH_UNLOCK(sc);
 
 	ATH_PCU_LOCK(sc);
 	ath_hal_setrxfilter(ah, rfilt);
 	ath_hal_setassocid(ah, ifp->if_broadcastaddr, 0);
 	ATH_PCU_UNLOCK(sc);
 
 	DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0\n",
 		 __func__, rfilt, ether_sprintf(ifp->if_broadcastaddr));
 }
 
 static void
 ath_scan_end(struct ieee80211com *ic)
 {
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 	u_int32_t rfilt;
 
 	ATH_LOCK(sc);
 	sc->sc_scanning = 0;
 	rfilt = ath_calcrxfilter(sc);
 	ATH_UNLOCK(sc);
 
 	ATH_PCU_LOCK(sc);
 	ath_hal_setrxfilter(ah, rfilt);
 	ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid);
 
 	ath_hal_process_noisefloor(ah);
 	ATH_PCU_UNLOCK(sc);
 
 	DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n",
 		 __func__, rfilt, ether_sprintf(sc->sc_curbssid),
 		 sc->sc_curaid);
 }
 
 #ifdef	ATH_ENABLE_11N
 /*
  * For now, just do a channel change.
  *
  * Later, we'll go through the hard slog of suspending tx/rx, changing rate
  * control state and resetting the hardware without dropping frames out
  * of the queue.
  *
  * The unfortunate trouble here is making absolutely sure that the
  * channel width change has propagated enough so the hardware
  * absolutely isn't handed bogus frames for it's current operating
  * mode. (Eg, 40MHz frames in 20MHz mode.) Since TX and RX can and
  * does occur in parallel, we need to make certain we've blocked
  * any further ongoing TX (and RX, that can cause raw TX)
  * before we do this.
  */
 static void
 ath_update_chw(struct ieee80211com *ic)
 {
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 
 	DPRINTF(sc, ATH_DEBUG_STATE, "%s: called\n", __func__);
 	ath_set_channel(ic);
 }
 #endif	/* ATH_ENABLE_11N */
 
 static void
 ath_set_channel(struct ieee80211com *ic)
 {
 	struct ifnet *ifp = ic->ic_ifp;
 	struct ath_softc *sc = ifp->if_softc;
 
 	(void) ath_chan_set(sc, ic->ic_curchan);
 	/*
 	 * If we are returning to our bss channel then mark state
 	 * so the next recv'd beacon's tsf will be used to sync the
 	 * beacon timers.  Note that since we only hear beacons in
 	 * sta/ibss mode this has no effect in other operating modes.
 	 */
 	ATH_LOCK(sc);
 	if (!sc->sc_scanning && ic->ic_curchan == ic->ic_bsschan)
 		sc->sc_syncbeacon = 1;
 	ATH_UNLOCK(sc);
 }
 
 /*
  * Walk the vap list and check if there any vap's in RUN state.
  */
 static int
 ath_isanyrunningvaps(struct ieee80211vap *this)
 {
 	struct ieee80211com *ic = this->iv_ic;
 	struct ieee80211vap *vap;
 
 	IEEE80211_LOCK_ASSERT(ic);
 
 	TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
 		if (vap != this && vap->iv_state >= IEEE80211_S_RUN)
 			return 1;
 	}
 	return 0;
 }
 
 static int
 ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
 {
 	struct ieee80211com *ic = vap->iv_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_vap *avp = ATH_VAP(vap);
 	struct ath_hal *ah = sc->sc_ah;
 	struct ieee80211_node *ni = NULL;
 	int i, error, stamode;
 	u_int32_t rfilt;
 	int csa_run_transition = 0;
 
 	static const HAL_LED_STATE leds[] = {
 	    HAL_LED_INIT,	/* IEEE80211_S_INIT */
 	    HAL_LED_SCAN,	/* IEEE80211_S_SCAN */
 	    HAL_LED_AUTH,	/* IEEE80211_S_AUTH */
 	    HAL_LED_ASSOC, 	/* IEEE80211_S_ASSOC */
 	    HAL_LED_RUN, 	/* IEEE80211_S_CAC */
 	    HAL_LED_RUN, 	/* IEEE80211_S_RUN */
 	    HAL_LED_RUN, 	/* IEEE80211_S_CSA */
 	    HAL_LED_RUN, 	/* IEEE80211_S_SLEEP */
 	};
 
 	DPRINTF(sc, ATH_DEBUG_STATE, "%s: %s -> %s\n", __func__,
 		ieee80211_state_name[vap->iv_state],
 		ieee80211_state_name[nstate]);
 
 	/*
 	 * net80211 _should_ have the comlock asserted at this point.
 	 * There are some comments around the calls to vap->iv_newstate
 	 * which indicate that it (newstate) may end up dropping the
 	 * lock.  This and the subsequent lock assert check after newstate
 	 * are an attempt to catch these and figure out how/why.
 	 */
 	IEEE80211_LOCK_ASSERT(ic);
 
 	if (vap->iv_state == IEEE80211_S_CSA && nstate == IEEE80211_S_RUN)
 		csa_run_transition = 1;
 
 	callout_drain(&sc->sc_cal_ch);
 	ath_hal_setledstate(ah, leds[nstate]);	/* set LED */
 
 	if (nstate == IEEE80211_S_SCAN) {
 		/*
 		 * Scanning: turn off beacon miss and don't beacon.
 		 * Mark beacon state so when we reach RUN state we'll
 		 * [re]setup beacons.  Unblock the task q thread so
 		 * deferred interrupt processing is done.
 		 */
 		ath_hal_intrset(ah,
 		    sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS));
 		sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
 		sc->sc_beacons = 0;
 		taskqueue_unblock(sc->sc_tq);
 	}
 
 	ni = ieee80211_ref_node(vap->iv_bss);
 	rfilt = ath_calcrxfilter(sc);
 	stamode = (vap->iv_opmode == IEEE80211_M_STA ||
 		   vap->iv_opmode == IEEE80211_M_AHDEMO ||
 		   vap->iv_opmode == IEEE80211_M_IBSS);
 	if (stamode && nstate == IEEE80211_S_RUN) {
 		sc->sc_curaid = ni->ni_associd;
 		IEEE80211_ADDR_COPY(sc->sc_curbssid, ni->ni_bssid);
 		ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid);
 	}
 	DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n",
 	   __func__, rfilt, ether_sprintf(sc->sc_curbssid), sc->sc_curaid);
 	ath_hal_setrxfilter(ah, rfilt);
 
 	/* XXX is this to restore keycache on resume? */
 	if (vap->iv_opmode != IEEE80211_M_STA &&
 	    (vap->iv_flags & IEEE80211_F_PRIVACY)) {
 		for (i = 0; i < IEEE80211_WEP_NKID; i++)
 			if (ath_hal_keyisvalid(ah, i))
 				ath_hal_keysetmac(ah, i, ni->ni_bssid);
 	}
 
 	/*
 	 * Invoke the parent method to do net80211 work.
 	 */
 	error = avp->av_newstate(vap, nstate, arg);
 	if (error != 0)
 		goto bad;
 
 	/*
 	 * See above: ensure av_newstate() doesn't drop the lock
 	 * on us.
 	 */
 	IEEE80211_LOCK_ASSERT(ic);
 
 	if (nstate == IEEE80211_S_RUN) {
 		/* NB: collect bss node again, it may have changed */
 		ieee80211_free_node(ni);
 		ni = ieee80211_ref_node(vap->iv_bss);
 
 		DPRINTF(sc, ATH_DEBUG_STATE,
 		    "%s(RUN): iv_flags 0x%08x bintvl %d bssid %s "
 		    "capinfo 0x%04x chan %d\n", __func__,
 		    vap->iv_flags, ni->ni_intval, ether_sprintf(ni->ni_bssid),
 		    ni->ni_capinfo, ieee80211_chan2ieee(ic, ic->ic_curchan));
 
 		switch (vap->iv_opmode) {
 #ifdef IEEE80211_SUPPORT_TDMA
 		case IEEE80211_M_AHDEMO:
 			if ((vap->iv_caps & IEEE80211_C_TDMA) == 0)
 				break;
 			/* fall thru... */
 #endif
 		case IEEE80211_M_HOSTAP:
 		case IEEE80211_M_IBSS:
 		case IEEE80211_M_MBSS:
 			/*
 			 * Allocate and setup the beacon frame.
 			 *
 			 * Stop any previous beacon DMA.  This may be
 			 * necessary, for example, when an ibss merge
 			 * causes reconfiguration; there will be a state
 			 * transition from RUN->RUN that means we may
 			 * be called with beacon transmission active.
 			 */
 			ath_hal_stoptxdma(ah, sc->sc_bhalq);
 
 			error = ath_beacon_alloc(sc, ni);
 			if (error != 0)
 				goto bad;
 			/*
 			 * If joining an adhoc network defer beacon timer
 			 * configuration to the next beacon frame so we
 			 * have a current TSF to use.  Otherwise we're
 			 * starting an ibss/bss so there's no need to delay;
 			 * if this is the first vap moving to RUN state, then
 			 * beacon state needs to be [re]configured.
 			 */
 			if (vap->iv_opmode == IEEE80211_M_IBSS &&
 			    ni->ni_tstamp.tsf != 0) {
 				sc->sc_syncbeacon = 1;
 			} else if (!sc->sc_beacons) {
 #ifdef IEEE80211_SUPPORT_TDMA
 				if (vap->iv_caps & IEEE80211_C_TDMA)
 					ath_tdma_config(sc, vap);
 				else
 #endif
 					ath_beacon_config(sc, vap);
 				sc->sc_beacons = 1;
 			}
 			break;
 		case IEEE80211_M_STA:
 			/*
 			 * Defer beacon timer configuration to the next
 			 * beacon frame so we have a current TSF to use
 			 * (any TSF collected when scanning is likely old).
 			 * However if it's due to a CSA -> RUN transition,
 			 * force a beacon update so we pick up a lack of
 			 * beacons from an AP in CAC and thus force a
 			 * scan.
 			 *
 			 * And, there's also corner cases here where
 			 * after a scan, the AP may have disappeared.
 			 * In that case, we may not receive an actual
 			 * beacon to update the beacon timer and thus we
 			 * won't get notified of the missing beacons.
 			 */
 			sc->sc_syncbeacon = 1;
 #if 0
 			if (csa_run_transition)
 #endif
 				ath_beacon_config(sc, vap);
 
 			/*
 			 * PR: kern/175227
 			 *
 			 * Reconfigure beacons during reset; as otherwise
 			 * we won't get the beacon timers reprogrammed
 			 * after a reset and thus we won't pick up a
 			 * beacon miss interrupt.
 			 *
 			 * Hopefully we'll see a beacon before the BMISS
 			 * timer fires (too often), leading to a STA
 			 * disassociation.
 			 */
 			sc->sc_beacons = 1;
 			break;
 		case IEEE80211_M_MONITOR:
 			/*
 			 * Monitor mode vaps have only INIT->RUN and RUN->RUN
 			 * transitions so we must re-enable interrupts here to
 			 * handle the case of a single monitor mode vap.
 			 */
 			ath_hal_intrset(ah, sc->sc_imask);
 			break;
 		case IEEE80211_M_WDS:
 			break;
 		default:
 			break;
 		}
 		/*
 		 * Let the hal process statistics collected during a
 		 * scan so it can provide calibrated noise floor data.
 		 */
 		ath_hal_process_noisefloor(ah);
 		/*
 		 * Reset rssi stats; maybe not the best place...
 		 */
 		sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
 		sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
 		sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
 		/*
 		 * Finally, start any timers and the task q thread
 		 * (in case we didn't go through SCAN state).
 		 */
 		if (ath_longcalinterval != 0) {
 			/* start periodic recalibration timer */
 			callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc);
 		} else {
 			DPRINTF(sc, ATH_DEBUG_CALIBRATE,
 			    "%s: calibration disabled\n", __func__);
 		}
 		taskqueue_unblock(sc->sc_tq);
 	} else if (nstate == IEEE80211_S_INIT) {
 		/*
 		 * If there are no vaps left in RUN state then
 		 * shutdown host/driver operation:
 		 * o disable interrupts
 		 * o disable the task queue thread
 		 * o mark beacon processing as stopped
 		 */
 		if (!ath_isanyrunningvaps(vap)) {
 			sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
 			/* disable interrupts  */
 			ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL);
 			taskqueue_block(sc->sc_tq);
 			sc->sc_beacons = 0;
 		}
 #ifdef IEEE80211_SUPPORT_TDMA
 		ath_hal_setcca(ah, AH_TRUE);
 #endif
 	}
 bad:
 	ieee80211_free_node(ni);
 	return error;
 }
 
 /*
  * Allocate a key cache slot to the station so we can
  * setup a mapping from key index to node. The key cache
  * slot is needed for managing antenna state and for
  * compression when stations do not use crypto.  We do
  * it uniliaterally here; if crypto is employed this slot
  * will be reassigned.
  */
 static void
 ath_setup_stationkey(struct ieee80211_node *ni)
 {
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ath_softc *sc = vap->iv_ic->ic_ifp->if_softc;
 	ieee80211_keyix keyix, rxkeyix;
 
 	/* XXX should take a locked ref to vap->iv_bss */
 	if (!ath_key_alloc(vap, &ni->ni_ucastkey, &keyix, &rxkeyix)) {
 		/*
 		 * Key cache is full; we'll fall back to doing
 		 * the more expensive lookup in software.  Note
 		 * this also means no h/w compression.
 		 */
 		/* XXX msg+statistic */
 	} else {
 		/* XXX locking? */
 		ni->ni_ucastkey.wk_keyix = keyix;
 		ni->ni_ucastkey.wk_rxkeyix = rxkeyix;
 		/* NB: must mark device key to get called back on delete */
 		ni->ni_ucastkey.wk_flags |= IEEE80211_KEY_DEVKEY;
 		IEEE80211_ADDR_COPY(ni->ni_ucastkey.wk_macaddr, ni->ni_macaddr);
 		/* NB: this will create a pass-thru key entry */
 		ath_keyset(sc, vap, &ni->ni_ucastkey, vap->iv_bss);
 	}
 }
 
 /*
  * Setup driver-specific state for a newly associated node.
  * Note that we're called also on a re-associate, the isnew
  * param tells us if this is the first time or not.
  */
 static void
 ath_newassoc(struct ieee80211_node *ni, int isnew)
 {
 	struct ath_node *an = ATH_NODE(ni);
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ath_softc *sc = vap->iv_ic->ic_ifp->if_softc;
 	const struct ieee80211_txparam *tp = ni->ni_txparms;
 
 	an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate);
 	an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate);
 
 	ath_rate_newassoc(sc, an, isnew);
 	if (isnew &&
 	    (vap->iv_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey &&
 	    ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE)
 		ath_setup_stationkey(ni);
 }
 
 static int
 ath_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *reg,
 	int nchans, struct ieee80211_channel chans[])
 {
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_STATUS status;
 
 	DPRINTF(sc, ATH_DEBUG_REGDOMAIN,
 	    "%s: rd %u cc %u location %c%s\n",
 	    __func__, reg->regdomain, reg->country, reg->location,
 	    reg->ecm ? " ecm" : "");
 
 	status = ath_hal_set_channels(ah, chans, nchans,
 	    reg->country, reg->regdomain);
 	if (status != HAL_OK) {
 		DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: failed, status %u\n",
 		    __func__, status);
 		return EINVAL;		/* XXX */
 	}
 
 	return 0;
 }
 
 static void
 ath_getradiocaps(struct ieee80211com *ic,
 	int maxchans, int *nchans, struct ieee80211_channel chans[])
 {
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_hal *ah = sc->sc_ah;
 
 	DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: use rd %u cc %d\n",
 	    __func__, SKU_DEBUG, CTRY_DEFAULT);
 
 	/* XXX check return */
 	(void) ath_hal_getchannels(ah, chans, maxchans, nchans,
 	    HAL_MODE_ALL, CTRY_DEFAULT, SKU_DEBUG, AH_TRUE);
 
 }
 
 static int
 ath_getchannels(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ath_hal *ah = sc->sc_ah;
 	HAL_STATUS status;
 
 	/*
 	 * Collect channel set based on EEPROM contents.
 	 */
 	status = ath_hal_init_channels(ah, ic->ic_channels, IEEE80211_CHAN_MAX,
 	    &ic->ic_nchans, HAL_MODE_ALL, CTRY_DEFAULT, SKU_NONE, AH_TRUE);
 	if (status != HAL_OK) {
 		if_printf(ifp, "%s: unable to collect channel list from hal, "
 		    "status %d\n", __func__, status);
 		return EINVAL;
 	}
 	(void) ath_hal_getregdomain(ah, &sc->sc_eerd);
 	ath_hal_getcountrycode(ah, &sc->sc_eecc);	/* NB: cannot fail */
 	/* XXX map Atheros sku's to net80211 SKU's */
 	/* XXX net80211 types too small */
 	ic->ic_regdomain.regdomain = (uint16_t) sc->sc_eerd;
 	ic->ic_regdomain.country = (uint16_t) sc->sc_eecc;
 	ic->ic_regdomain.isocc[0] = ' ';	/* XXX don't know */
 	ic->ic_regdomain.isocc[1] = ' ';
 
 	ic->ic_regdomain.ecm = 1;
 	ic->ic_regdomain.location = 'I';
 
 	DPRINTF(sc, ATH_DEBUG_REGDOMAIN,
 	    "%s: eeprom rd %u cc %u (mapped rd %u cc %u) location %c%s\n",
 	    __func__, sc->sc_eerd, sc->sc_eecc,
 	    ic->ic_regdomain.regdomain, ic->ic_regdomain.country,
 	    ic->ic_regdomain.location, ic->ic_regdomain.ecm ? " ecm" : "");
 	return 0;
 }
 
 static int
 ath_rate_setup(struct ath_softc *sc, u_int mode)
 {
 	struct ath_hal *ah = sc->sc_ah;
 	const HAL_RATE_TABLE *rt;
 
 	switch (mode) {
 	case IEEE80211_MODE_11A:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A);
 		break;
 	case IEEE80211_MODE_HALF:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A_HALF_RATE);
 		break;
 	case IEEE80211_MODE_QUARTER:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11A_QUARTER_RATE);
 		break;
 	case IEEE80211_MODE_11B:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11B);
 		break;
 	case IEEE80211_MODE_11G:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11G);
 		break;
 	case IEEE80211_MODE_TURBO_A:
 		rt = ath_hal_getratetable(ah, HAL_MODE_108A);
 		break;
 	case IEEE80211_MODE_TURBO_G:
 		rt = ath_hal_getratetable(ah, HAL_MODE_108G);
 		break;
 	case IEEE80211_MODE_STURBO_A:
 		rt = ath_hal_getratetable(ah, HAL_MODE_TURBO);
 		break;
 	case IEEE80211_MODE_11NA:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11NA_HT20);
 		break;
 	case IEEE80211_MODE_11NG:
 		rt = ath_hal_getratetable(ah, HAL_MODE_11NG_HT20);
 		break;
 	default:
 		DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid mode %u\n",
 			__func__, mode);
 		return 0;
 	}
 	sc->sc_rates[mode] = rt;
 	return (rt != NULL);
 }
 
 static void
 ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode)
 {
 #define	N(a)	(sizeof(a)/sizeof(a[0]))
 	/* NB: on/off times from the Atheros NDIS driver, w/ permission */
 	static const struct {
 		u_int		rate;		/* tx/rx 802.11 rate */
 		u_int16_t	timeOn;		/* LED on time (ms) */
 		u_int16_t	timeOff;	/* LED off time (ms) */
 	} blinkrates[] = {
 		{ 108,  40,  10 },
 		{  96,  44,  11 },
 		{  72,  50,  13 },
 		{  48,  57,  14 },
 		{  36,  67,  16 },
 		{  24,  80,  20 },
 		{  22, 100,  25 },
 		{  18, 133,  34 },
 		{  12, 160,  40 },
 		{  10, 200,  50 },
 		{   6, 240,  58 },
 		{   4, 267,  66 },
 		{   2, 400, 100 },
 		{   0, 500, 130 },
 		/* XXX half/quarter rates */
 	};
 	const HAL_RATE_TABLE *rt;
 	int i, j;
 
 	memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap));
 	rt = sc->sc_rates[mode];
 	KASSERT(rt != NULL, ("no h/w rate set for phy mode %u", mode));
 	for (i = 0; i < rt->rateCount; i++) {
 		uint8_t ieeerate = rt->info[i].dot11Rate & IEEE80211_RATE_VAL;
 		if (rt->info[i].phy != IEEE80211_T_HT)
 			sc->sc_rixmap[ieeerate] = i;
 		else
 			sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i;
 	}
 	memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap));
 	for (i = 0; i < N(sc->sc_hwmap); i++) {
 		if (i >= rt->rateCount) {
 			sc->sc_hwmap[i].ledon = (500 * hz) / 1000;
 			sc->sc_hwmap[i].ledoff = (130 * hz) / 1000;
 			continue;
 		}
 		sc->sc_hwmap[i].ieeerate =
 			rt->info[i].dot11Rate & IEEE80211_RATE_VAL;
 		if (rt->info[i].phy == IEEE80211_T_HT)
 			sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS;
 		sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD;
 		if (rt->info[i].shortPreamble ||
 		    rt->info[i].phy == IEEE80211_T_OFDM)
 			sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE;
 		sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags;
 		for (j = 0; j < N(blinkrates)-1; j++)
 			if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate)
 				break;
 		/* NB: this uses the last entry if the rate isn't found */
 		/* XXX beware of overlow */
 		sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000;
 		sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000;
 	}
 	sc->sc_currates = rt;
 	sc->sc_curmode = mode;
 	/*
 	 * All protection frames are transmited at 2Mb/s for
 	 * 11g, otherwise at 1Mb/s.
 	 */
 	if (mode == IEEE80211_MODE_11G)
 		sc->sc_protrix = ath_tx_findrix(sc, 2*2);
 	else
 		sc->sc_protrix = ath_tx_findrix(sc, 2*1);
 	/* NB: caller is responsible for resetting rate control state */
 #undef N
 }
 
 static void
 ath_watchdog(void *arg)
 {
 	struct ath_softc *sc = arg;
 	int do_reset = 0;
 
 	if (sc->sc_wd_timer != 0 && --sc->sc_wd_timer == 0) {
 		struct ifnet *ifp = sc->sc_ifp;
 		uint32_t hangs;
 
 		if (ath_hal_gethangstate(sc->sc_ah, 0xffff, &hangs) &&
 		    hangs != 0) {
 			if_printf(ifp, "%s hang detected (0x%x)\n",
 			    hangs & 0xff ? "bb" : "mac", hangs);
 		} else
 			if_printf(ifp, "device timeout\n");
 		do_reset = 1;
 		ifp->if_oerrors++;
 		sc->sc_stats.ast_watchdog++;
 	}
 
 	/*
 	 * We can't hold the lock across the ath_reset() call.
 	 *
 	 * And since this routine can't hold a lock and sleep,
 	 * do the reset deferred.
 	 */
 	if (do_reset) {
 		taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask);
 	}
 
 	callout_schedule(&sc->sc_wd_ch, hz);
 }
 
 /*
  * Fetch the rate control statistics for the given node.
  */
 static int
 ath_ioctl_ratestats(struct ath_softc *sc, struct ath_rateioctl *rs)
 {
 	struct ath_node *an;
 	struct ieee80211com *ic = sc->sc_ifp->if_l2com;
 	struct ieee80211_node *ni;
 	int error = 0;
 
 	/* Perform a lookup on the given node */
 	ni = ieee80211_find_node(&ic->ic_sta, rs->is_u.macaddr);
 	if (ni == NULL) {
 		error = EINVAL;
 		goto bad;
 	}
 
 	/* Lock the ath_node */
 	an = ATH_NODE(ni);
 	ATH_NODE_LOCK(an);
 
 	/* Fetch the rate control stats for this node */
 	error = ath_rate_fetch_node_stats(sc, an, rs);
 
 	/* No matter what happens here, just drop through */
 
 	/* Unlock the ath_node */
 	ATH_NODE_UNLOCK(an);
 
 	/* Unref the node */
 	ieee80211_node_decref(ni);
 
 bad:
 	return (error);
 }
 
 #ifdef ATH_DIAGAPI
 /*
  * Diagnostic interface to the HAL.  This is used by various
  * tools to do things like retrieve register contents for
  * debugging.  The mechanism is intentionally opaque so that
  * it can change frequently w/o concern for compatiblity.
  */
 static int
 ath_ioctl_diag(struct ath_softc *sc, struct ath_diag *ad)
 {
 	struct ath_hal *ah = sc->sc_ah;
 	u_int id = ad->ad_id & ATH_DIAG_ID;
 	void *indata = NULL;
 	void *outdata = NULL;
 	u_int32_t insize = ad->ad_in_size;
 	u_int32_t outsize = ad->ad_out_size;
 	int error = 0;
 
 	if (ad->ad_id & ATH_DIAG_IN) {
 		/*
 		 * Copy in data.
 		 */
 		indata = malloc(insize, M_TEMP, M_NOWAIT);
 		if (indata == NULL) {
 			error = ENOMEM;
 			goto bad;
 		}
 		error = copyin(ad->ad_in_data, indata, insize);
 		if (error)
 			goto bad;
 	}
 	if (ad->ad_id & ATH_DIAG_DYN) {
 		/*
 		 * Allocate a buffer for the results (otherwise the HAL
 		 * returns a pointer to a buffer where we can read the
 		 * results).  Note that we depend on the HAL leaving this
 		 * pointer for us to use below in reclaiming the buffer;
 		 * may want to be more defensive.
 		 */
 		outdata = malloc(outsize, M_TEMP, M_NOWAIT);
 		if (outdata == NULL) {
 			error = ENOMEM;
 			goto bad;
 		}
 	}
 	if (ath_hal_getdiagstate(ah, id, indata, insize, &outdata, &outsize)) {
 		if (outsize < ad->ad_out_size)
 			ad->ad_out_size = outsize;
 		if (outdata != NULL)
 			error = copyout(outdata, ad->ad_out_data,
 					ad->ad_out_size);
 	} else {
 		error = EINVAL;
 	}
 bad:
 	if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL)
 		free(indata, M_TEMP);
 	if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL)
 		free(outdata, M_TEMP);
 	return error;
 }
 #endif /* ATH_DIAGAPI */
 
 static int
 ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
 #define	IS_RUNNING(ifp) \
 	((ifp->if_flags & IFF_UP) && (ifp->if_drv_flags & IFF_DRV_RUNNING))
 	struct ath_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ifreq *ifr = (struct ifreq *)data;
 	const HAL_RATE_TABLE *rt;
 	int error = 0;
 
 	switch (cmd) {
 	case SIOCSIFFLAGS:
 		ATH_LOCK(sc);
 		if (IS_RUNNING(ifp)) {
 			/*
 			 * To avoid rescanning another access point,
 			 * do not call ath_init() here.  Instead,
 			 * only reflect promisc mode settings.
 			 */
 			ath_mode_init(sc);
 		} else if (ifp->if_flags & IFF_UP) {
 			/*
 			 * Beware of being called during attach/detach
 			 * to reset promiscuous mode.  In that case we
 			 * will still be marked UP but not RUNNING.
 			 * However trying to re-init the interface
 			 * is the wrong thing to do as we've already
 			 * torn down much of our state.  There's
 			 * probably a better way to deal with this.
 			 */
 			if (!sc->sc_invalid)
 				ath_init(sc);	/* XXX lose error */
 		} else {
 			ath_stop_locked(ifp);
 #ifdef notyet
 			/* XXX must wakeup in places like ath_vap_delete */
 			if (!sc->sc_invalid)
 				ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP);
 #endif
 		}
 		ATH_UNLOCK(sc);
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
 		break;
 	case SIOCGATHSTATS:
 		/* NB: embed these numbers to get a consistent view */
 		sc->sc_stats.ast_tx_packets = ifp->if_opackets;
 		sc->sc_stats.ast_rx_packets = ifp->if_ipackets;
 		sc->sc_stats.ast_tx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgtxrssi);
 		sc->sc_stats.ast_rx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgrssi);
 #ifdef IEEE80211_SUPPORT_TDMA
 		sc->sc_stats.ast_tdma_tsfadjp = TDMA_AVG(sc->sc_avgtsfdeltap);
 		sc->sc_stats.ast_tdma_tsfadjm = TDMA_AVG(sc->sc_avgtsfdeltam);
 #endif
 		rt = sc->sc_currates;
 		sc->sc_stats.ast_tx_rate =
 		    rt->info[sc->sc_txrix].dot11Rate &~ IEEE80211_RATE_BASIC;
 		if (rt->info[sc->sc_txrix].phy & IEEE80211_T_HT)
 			sc->sc_stats.ast_tx_rate |= IEEE80211_RATE_MCS;
 		return copyout(&sc->sc_stats,
 		    ifr->ifr_data, sizeof (sc->sc_stats));
 	case SIOCGATHAGSTATS:
 		return copyout(&sc->sc_aggr_stats,
 		    ifr->ifr_data, sizeof (sc->sc_aggr_stats));
 	case SIOCZATHSTATS:
 		error = priv_check(curthread, PRIV_DRIVER);
 		if (error == 0) {
 			memset(&sc->sc_stats, 0, sizeof(sc->sc_stats));
 			memset(&sc->sc_aggr_stats, 0,
 			    sizeof(sc->sc_aggr_stats));
 			memset(&sc->sc_intr_stats, 0,
 			    sizeof(sc->sc_intr_stats));
 		}
 		break;
 #ifdef ATH_DIAGAPI
 	case SIOCGATHDIAG:
 		error = ath_ioctl_diag(sc, (struct ath_diag *) ifr);
 		break;
 	case SIOCGATHPHYERR:
 		error = ath_ioctl_phyerr(sc,(struct ath_diag*) ifr);
 		break;
 #endif
 	case SIOCGATHSPECTRAL:
 		error = ath_ioctl_spectral(sc,(struct ath_diag*) ifr);
 		break;
 	case SIOCGATHNODERATESTATS:
 		error = ath_ioctl_ratestats(sc, (struct ath_rateioctl *) ifr);
 		break;
 	case SIOCGIFADDR:
 		error = ether_ioctl(ifp, cmd, data);
 		break;
 	default:
 		error = EINVAL;
 		break;
 	}
 	return error;
 #undef IS_RUNNING
 }
 
 /*
  * Announce various information on device/driver attach.
  */
 static void
 ath_announce(struct ath_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ath_hal *ah = sc->sc_ah;
 
 	if_printf(ifp, "AR%s mac %d.%d RF%s phy %d.%d\n",
 		ath_hal_mac_name(ah), ah->ah_macVersion, ah->ah_macRev,
 		ath_hal_rf_name(ah), ah->ah_phyRev >> 4, ah->ah_phyRev & 0xf);
 	if_printf(ifp, "2GHz radio: 0x%.4x; 5GHz radio: 0x%.4x\n",
 		ah->ah_analog2GhzRev, ah->ah_analog5GhzRev);
 	if (bootverbose) {
 		int i;
 		for (i = 0; i <= WME_AC_VO; i++) {
 			struct ath_txq *txq = sc->sc_ac2q[i];
 			if_printf(ifp, "Use hw queue %u for %s traffic\n",
 				txq->axq_qnum, ieee80211_wme_acnames[i]);
 		}
 		if_printf(ifp, "Use hw queue %u for CAB traffic\n",
 			sc->sc_cabq->axq_qnum);
 		if_printf(ifp, "Use hw queue %u for beacons\n", sc->sc_bhalq);
 	}
 	if (ath_rxbuf != ATH_RXBUF)
 		if_printf(ifp, "using %u rx buffers\n", ath_rxbuf);
 	if (ath_txbuf != ATH_TXBUF)
 		if_printf(ifp, "using %u tx buffers\n", ath_txbuf);
 	if (sc->sc_mcastkey && bootverbose)
 		if_printf(ifp, "using multicast key search\n");
 }
 
 static void
 ath_dfs_tasklet(void *p, int npending)
 {
 	struct ath_softc *sc = (struct ath_softc *) p;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 
 	/*
 	 * If previous processing has found a radar event,
 	 * signal this to the net80211 layer to begin DFS
 	 * processing.
 	 */
 	if (ath_dfs_process_radar_event(sc, sc->sc_curchan)) {
 		/* DFS event found, initiate channel change */
 		/*
 		 * XXX doesn't currently tell us whether the event
 		 * XXX was found in the primary or extension
 		 * XXX channel!
 		 */
 		IEEE80211_LOCK(ic);
 		ieee80211_dfs_notify_radar(ic, sc->sc_curchan);
 		IEEE80211_UNLOCK(ic);
 	}
 }
 
 /*
  * Enable/disable power save.  This must be called with
  * no TX driver locks currently held, so it should only
  * be called from the RX path (which doesn't hold any
  * TX driver locks.)
  */
 static void
 ath_node_powersave(struct ieee80211_node *ni, int enable)
 {
 #ifdef	ATH_SW_PSQ
 	struct ath_node *an = ATH_NODE(ni);
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_vap *avp = ATH_VAP(ni->ni_vap);
 
 	ATH_NODE_UNLOCK_ASSERT(an);
 	/* XXX and no TXQ locks should be held here */
 
 	DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: ni=%p, enable=%d\n",
 	    __func__, ni, enable);
 
 	/* Suspend or resume software queue handling */
 	if (enable)
 		ath_tx_node_sleep(sc, an);
 	else
 		ath_tx_node_wakeup(sc, an);
 
 	/* Update net80211 state */
 	avp->av_node_ps(ni, enable);
 #else
 	struct ath_vap *avp = ATH_VAP(ni->ni_vap);
 
 	/* Update net80211 state */
 	avp->av_node_ps(ni, enable);
 #endif/* ATH_SW_PSQ */
 }
 
 /*
  * Notification from net80211 that the powersave queue state has
  * changed.
  *
  * Since the software queue also may have some frames:
  *
  * + if the node software queue has frames and the TID state
  *   is 0, we set the TIM;
  * + if the node and the stack are both empty, we clear the TIM bit.
  * + If the stack tries to set the bit, always set it.
  * + If the stack tries to clear the bit, only clear it if the
  *   software queue in question is also cleared.
  *
  * TODO: this is called during node teardown; so let's ensure this
  * is all correctly handled and that the TIM bit is cleared.
  * It may be that the node flush is called _AFTER_ the net80211
  * stack clears the TIM.
  *
  * Here is the racy part.  Since it's possible >1 concurrent,
  * overlapping TXes will appear complete with a TX completion in
  * another thread, it's possible that the concurrent TIM calls will
  * clash.  We can't hold the node lock here because setting the
  * TIM grabs the net80211 comlock and this may cause a LOR.
  * The solution is either to totally serialise _everything_ at
  * this point (ie, all TX, completion and any reset/flush go into
  * one taskqueue) or a new "ath TIM lock" needs to be created that
  * just wraps the driver state change and this call to avp->av_set_tim().
  *
  * The same race exists in the net80211 power save queue handling
  * as well.  Since multiple transmitting threads may queue frames
  * into the driver, as well as ps-poll and the driver transmitting
  * frames (and thus clearing the psq), it's quite possible that
  * a packet entering the PSQ and a ps-poll being handled will
  * race, causing the TIM to be cleared and not re-set.
  */
 static int
 ath_node_set_tim(struct ieee80211_node *ni, int enable)
 {
 #ifdef	ATH_SW_PSQ
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ath_softc *sc = ic->ic_ifp->if_softc;
 	struct ath_node *an = ATH_NODE(ni);
 	struct ath_vap *avp = ATH_VAP(ni->ni_vap);
 	int changed = 0;
 
 	ATH_NODE_UNLOCK_ASSERT(an);
 
 	/*
 	 * For now, just track and then update the TIM.
 	 */
 	ATH_NODE_LOCK(an);
 	an->an_stack_psq = enable;
 
 	/*
 	 * This will get called for all operating modes,
 	 * even if avp->av_set_tim is unset.
 	 * It's currently set for hostap/ibss modes; but
 	 * the same infrastructure is used for both STA
 	 * and AP/IBSS node power save.
 	 */
 	if (avp->av_set_tim == NULL) {
 		ATH_NODE_UNLOCK(an);
 		return (0);
 	}
 
 	/*
 	 * If setting the bit, always set it here.
 	 * If clearing the bit, only clear it if the
 	 * software queue is also empty.
 	 *
 	 * If the node has left power save, just clear the TIM
 	 * bit regardless of the state of the power save queue.
 	 *
 	 * XXX TODO: although atomics are used, it's quite possible
 	 * that a race will occur between this and setting/clearing
 	 * in another thread.  TX completion will occur always in
 	 * one thread, however setting/clearing the TIM bit can come
 	 * from a variety of different process contexts!
 	 */
 	if (enable && an->an_tim_set == 1) {
 		DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 		    "%s: an=%p, enable=%d, tim_set=1, ignoring\n",
 		    __func__, an, enable);
 		ATH_NODE_UNLOCK(an);
 	} else if (enable) {
 		DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 		    "%s: an=%p, enable=%d, enabling TIM\n",
 		    __func__, an, enable);
 		an->an_tim_set = 1;
 		ATH_NODE_UNLOCK(an);
 		changed = avp->av_set_tim(ni, enable);
 	} else if (atomic_load_acq_int(&an->an_swq_depth) == 0) {
 		/* disable */
 		DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 		    "%s: an=%p, enable=%d, an_swq_depth == 0, disabling\n",
 		    __func__, an, enable);
 		an->an_tim_set = 0;
 		ATH_NODE_UNLOCK(an);
 		changed = avp->av_set_tim(ni, enable);
 	} else if (! an->an_is_powersave) {
 		/*
 		 * disable regardless; the node isn't in powersave now
 		 */
 		DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 		    "%s: an=%p, enable=%d, an_pwrsave=0, disabling\n",
 		    __func__, an, enable);
 		an->an_tim_set = 0;
 		ATH_NODE_UNLOCK(an);
 		changed = avp->av_set_tim(ni, enable);
 	} else {
 		/*
 		 * psq disable, node is currently in powersave, node
 		 * software queue isn't empty, so don't clear the TIM bit
 		 * for now.
 		 */
 		ATH_NODE_UNLOCK(an);
 		DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 		    "%s: enable=%d, an_swq_depth > 0, ignoring\n",
 		    __func__, enable);
 		changed = 0;
 	}
 
 	return (changed);
 #else
 	struct ath_vap *avp = ATH_VAP(ni->ni_vap);
 
 	/*
 	 * Some operating modes don't set av_set_tim(), so don't
 	 * update it here.
 	 */
 	if (avp->av_set_tim == NULL)
 		return (0);
 
 	return (avp->av_set_tim(ni, enable));
 #endif /* ATH_SW_PSQ */
 }
 
 /*
  * Set or update the TIM from the software queue.
  *
  * Check the software queue depth before attempting to do lock
  * anything; that avoids trying to obtain the lock.  Then,
  * re-check afterwards to ensure nothing has changed in the
  * meantime.
  *
  * set:   This is designed to be called from the TX path, after
  *        a frame has been queued; to see if the swq > 0.
  *
  * clear: This is designed to be called from the buffer completion point
  *        (right now it's ath_tx_default_comp()) where the state of
  *        a software queue has changed.
  *
  * It makes sense to place it at buffer free / completion rather
  * than after each software queue operation, as there's no real
  * point in churning the TIM bit as the last frames in the software
  * queue are transmitted.  If they fail and we retry them, we'd
  * just be setting the TIM bit again anyway.
  */
 void
 ath_tx_update_tim(struct ath_softc *sc, struct ieee80211_node *ni,
      int enable)
 {
 #ifdef	ATH_SW_PSQ
 	struct ath_node *an;
 	struct ath_vap *avp;
 
 	/* Don't do this for broadcast/etc frames */
 	if (ni == NULL)
 		return;
 
 	an = ATH_NODE(ni);
 	avp = ATH_VAP(ni->ni_vap);
 
 	/*
 	 * And for operating modes without the TIM handler set, let's
 	 * just skip those.
 	 */
 	if (avp->av_set_tim == NULL)
 		return;
 
 	ATH_NODE_UNLOCK_ASSERT(an);
 
 	if (enable) {
 		/*
 		 * Don't bother grabbing the lock unless the queue is not
 		 * empty.
 		 */
 		if (atomic_load_acq_int(&an->an_swq_depth) == 0)
 			return;
 
 		ATH_NODE_LOCK(an);
 		if (an->an_is_powersave &&
 		    an->an_tim_set == 0 &&
 		    atomic_load_acq_int(&an->an_swq_depth) != 0) {
 			DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 			    "%s: an=%p, swq_depth>0, tim_set=0, set!\n",
 			    __func__, an);
 			an->an_tim_set = 1;
 			ATH_NODE_UNLOCK(an);
 			(void) avp->av_set_tim(ni, 1);
 		} else {
 			ATH_NODE_UNLOCK(an);
 		}
 	} else {
 		/*
 		 * Don't bother grabbing the lock unless the queue is empty.
 		 */
 		if (atomic_load_acq_int(&an->an_swq_depth) != 0)
 			return;
 
 		ATH_NODE_LOCK(an);
 		if (an->an_is_powersave &&
 		    an->an_stack_psq == 0 &&
 		    an->an_tim_set == 1 &&
 		    atomic_load_acq_int(&an->an_swq_depth) == 0) {
 			DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE,
 			    "%s: an=%p, swq_depth=0, tim_set=1, psq_set=0,"
 			    " clear!\n",
 			    __func__, an);
 			an->an_tim_set = 0;
 			ATH_NODE_UNLOCK(an);
 			(void) avp->av_set_tim(ni, 0);
 		} else {
 			ATH_NODE_UNLOCK(an);
 		}
 	}
 #else
 	return;
 #endif	/* ATH_SW_PSQ */
 }
 
 MODULE_VERSION(if_ath, 1);
 MODULE_DEPEND(if_ath, wlan, 1, 1, 1);          /* 802.11 media layer */
 #if	defined(IEEE80211_ALQ) || defined(AH_DEBUG_ALQ)
 MODULE_DEPEND(if_ath, alq, 1, 1, 1);
 #endif
Index: user/attilio/vmcontention/sys/dev/etherswitch/ukswitch/ukswitch.c
===================================================================
--- user/attilio/vmcontention/sys/dev/etherswitch/ukswitch/ukswitch.c	(nonexistent)
+++ user/attilio/vmcontention/sys/dev/etherswitch/ukswitch/ukswitch.c	(revision 249699)
@@ -0,0 +1,570 @@
+/*-
+ * Copyright (c) 2013 Luiz Otavio O Souza.
+ * Copyright (c) 2011-2012 Stefan Bethke.
+ * Copyright (c) 2012 Adrian Chadd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "mdio_if.h"
+#include "miibus_if.h"
+#include "etherswitch_if.h"
+
+MALLOC_DECLARE(M_UKSWITCH);
+MALLOC_DEFINE(M_UKSWITCH, "ukswitch", "ukswitch data structures");
+
+struct ukswitch_softc {
+	struct mtx	sc_mtx;		/* serialize access to softc */
+	device_t	sc_dev;
+	int		media;		/* cpu port media */
+	int		cpuport;	/* which PHY is connected to the CPU */
+	int		phymask;	/* PHYs we manage */
+	int		numports;	/* number of ports */
+	int		ifpport[MII_NPHY];
+	int		*portphy;
+	char		**ifname;
+	device_t	**miibus;
+	struct ifnet	**ifp;
+	struct callout	callout_tick;
+	etherswitch_info_t	info;
+};
+
+#define UKSWITCH_LOCK(_sc)			\
+	    mtx_lock(&(_sc)->sc_mtx)
+#define UKSWITCH_UNLOCK(_sc)			\
+	    mtx_unlock(&(_sc)->sc_mtx)
+#define UKSWITCH_LOCK_ASSERT(_sc, _what)	\
+	    mtx_assert(&(_sc)->sc_mtx, (_what))
+#define UKSWITCH_TRYLOCK(_sc)			\
+	    mtx_trylock(&(_sc)->sc_mtx)
+
+#if defined(DEBUG)
+#define	DPRINTF(dev, args...) device_printf(dev, args)
+#else
+#define	DPRINTF(dev, args...)
+#endif
+
+static inline int ukswitch_portforphy(struct ukswitch_softc *, int);
+static void ukswitch_tick(void *);
+static int ukswitch_ifmedia_upd(struct ifnet *);
+static void ukswitch_ifmedia_sts(struct ifnet *, struct ifmediareq *);
+
+static int
+ukswitch_probe(device_t dev)
+{
+	struct ukswitch_softc *sc;
+
+	sc = device_get_softc(dev);
+	bzero(sc, sizeof(*sc));
+
+	device_set_desc_copy(dev, "Generic MDIO switch driver");
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ukswitch_attach_phys(struct ukswitch_softc *sc)
+{
+	int phy, port = 0, err = 0;
+	char name[IFNAMSIZ];
+
+	/* PHYs need an interface, so we generate a dummy one */
+	snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev));
+	for (phy = 0; phy < MII_NPHY; phy++) {
+		if (((1 << phy) & sc->phymask) == 0)
+			continue;
+		sc->ifpport[phy] = port;
+		sc->portphy[port] = phy;
+//		if (phy == sc->cpuport)
+//			sc->info.es_cpuport = port;
+		sc->ifp[port] = if_alloc(IFT_ETHER);
+		sc->ifp[port]->if_softc = sc;
+		sc->ifp[port]->if_flags |= IFF_UP | IFF_BROADCAST |
+		    IFF_DRV_RUNNING | IFF_SIMPLEX;
+		sc->ifname[port] = malloc(strlen(name)+1, M_UKSWITCH, M_WAITOK);
+		bcopy(name, sc->ifname[port], strlen(name)+1);
+		if_initname(sc->ifp[port], sc->ifname[port], port);
+		sc->miibus[port] = malloc(sizeof(device_t), M_UKSWITCH,
+		    M_WAITOK | M_ZERO);
+		err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port],
+		    ukswitch_ifmedia_upd, ukswitch_ifmedia_sts, \
+		    BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
+		DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n",
+		    device_get_nameunit(*sc->miibus[port]),
+		    sc->ifp[port]->if_xname);
+		if (err != 0) {
+			device_printf(sc->sc_dev,
+			    "attaching PHY %d failed\n",
+			    phy);
+			break;
+		}
+		sc->info.es_nports = port + 1;
+		if (++port >= sc->numports)
+			break;
+	}
+	return (err);
+}
+
+static int
+ukswitch_attach(device_t dev)
+{
+	struct ukswitch_softc *sc;
+	int err = 0;
+
+	sc = device_get_softc(dev);
+
+	sc->sc_dev = dev;
+	mtx_init(&sc->sc_mtx, "ukswitch", NULL, MTX_DEF);
+	strlcpy(sc->info.es_name, device_get_desc(dev),
+	    sizeof(sc->info.es_name));
+
+	/* XXX Defaults */
+	sc->numports = 6;
+	sc->phymask = 0x0f;
+	sc->cpuport = 5;
+	sc->media = 100;
+
+	(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
+	    "numports", &sc->numports);
+	(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
+	    "phymask", &sc->phymask);
+	(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
+	    "cpuport", &sc->cpuport);
+	(void) resource_int_value(device_get_name(dev), device_get_unit(dev),
+	    "media", &sc->media);
+
+	/* Support only fast and giga ethernet. */
+	if (sc->media != 100 && sc->media != 1000)
+		sc->media = 100;
+
+	/* Always attach the cpu port. */
+	sc->phymask |= (1 << sc->cpuport);
+//	sc->info.es_cpuport = sc->cpuport;
+
+	/* We do not support any vlan groups. */
+	sc->info.es_nvlangroups = 0;
+
+	sc->ifp = malloc(sizeof(struct ifnet *) * sc->numports, M_UKSWITCH,
+	    M_WAITOK | M_ZERO);
+	sc->ifname = malloc(sizeof(char *) * sc->numports, M_UKSWITCH,
+	    M_WAITOK | M_ZERO);
+	sc->miibus = malloc(sizeof(device_t *) * sc->numports, M_UKSWITCH,
+	    M_WAITOK | M_ZERO);
+	sc->portphy = malloc(sizeof(int) * sc->numports, M_UKSWITCH,
+	    M_WAITOK | M_ZERO);
+
+	/*
+	 * Attach the PHYs and complete the bus enumeration.
+	 */
+	err = ukswitch_attach_phys(sc);
+	if (err != 0)
+		return (err);
+
+	bus_generic_probe(dev);
+	bus_enumerate_hinted_children(dev);
+	err = bus_generic_attach(dev);
+	if (err != 0)
+		return (err);
+	
+	callout_init(&sc->callout_tick, 0);
+
+	ukswitch_tick(sc);
+	
+	return (err);
+}
+
+static int
+ukswitch_detach(device_t dev)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+	int i, port;
+
+	callout_drain(&sc->callout_tick);
+
+	for (i=0; i < MII_NPHY; i++) {
+		if (((1 << i) & sc->phymask) == 0)
+			continue;
+		port = ukswitch_portforphy(sc, i);
+		if (sc->miibus[port] != NULL)
+			device_delete_child(dev, (*sc->miibus[port]));
+		if (sc->ifp[port] != NULL)
+			if_free(sc->ifp[port]);
+		free(sc->ifname[port], M_UKSWITCH);
+		free(sc->miibus[port], M_UKSWITCH);
+	}
+
+	free(sc->portphy, M_UKSWITCH);
+	free(sc->miibus, M_UKSWITCH);
+	free(sc->ifname, M_UKSWITCH);
+	free(sc->ifp, M_UKSWITCH);
+
+	bus_generic_detach(dev);
+	mtx_destroy(&sc->sc_mtx);
+
+	return (0);
+}
+
+/*
+ * Convert PHY number to port number.
+ */
+static inline int
+ukswitch_portforphy(struct ukswitch_softc *sc, int phy)
+{
+
+	return (sc->ifpport[phy]);
+}
+
+static inline struct mii_data *
+ukswitch_miiforport(struct ukswitch_softc *sc, int port)
+{
+
+	if (port < 0 || port > sc->numports)
+		return (NULL);
+	return (device_get_softc(*sc->miibus[port]));
+}
+
+static inline struct ifnet *
+ukswitch_ifpforport(struct ukswitch_softc *sc, int port)
+{
+
+	if (port < 0 || port > sc->numports)
+		return (NULL);
+	return (sc->ifp[port]);
+}
+
+/*
+ * Poll the status for all PHYs.
+ */
+static void
+ukswitch_miipollstat(struct ukswitch_softc *sc)
+{
+	int i, port;
+	struct mii_data *mii;
+	struct mii_softc *miisc;
+
+	UKSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
+
+	for (i = 0; i < MII_NPHY; i++) {
+		if (((1 << i) & sc->phymask) == 0)
+			continue;
+		port = ukswitch_portforphy(sc, i);
+		if ((*sc->miibus[port]) == NULL)
+			continue;
+		mii = device_get_softc(*sc->miibus[port]);
+		LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
+			if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) !=
+			    miisc->mii_inst)
+				continue;
+			ukphy_status(miisc);
+			mii_phy_update(miisc, MII_POLLSTAT);
+		}
+	}
+}
+
+static void
+ukswitch_tick(void *arg)
+{
+	struct ukswitch_softc *sc = arg;
+
+	ukswitch_miipollstat(sc);
+	callout_reset(&sc->callout_tick, hz, ukswitch_tick, sc);
+}
+
+static void
+ukswitch_lock(device_t dev)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+
+	UKSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
+	UKSWITCH_LOCK(sc);
+}
+
+static void
+ukswitch_unlock(device_t dev)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+
+	UKSWITCH_LOCK_ASSERT(sc, MA_OWNED);
+	UKSWITCH_UNLOCK(sc);
+}
+
+static etherswitch_info_t *
+ukswitch_getinfo(device_t dev)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+	
+	return (&sc->info);
+}
+
+static int
+ukswitch_getport(device_t dev, etherswitch_port_t *p)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+	struct mii_data *mii;
+	struct ifmediareq *ifmr = &p->es_ifmr;
+	int err;
+
+	if (p->es_port < 0 || p->es_port >= sc->numports)
+		return (ENXIO);
+	p->es_vlangroup = 0;
+
+	mii = ukswitch_miiforport(sc, p->es_port);
+	if (sc->portphy[p->es_port] == sc->cpuport) {
+		/* fill in fixed values for CPU port */
+		ifmr->ifm_count = 0;
+		if (sc->media == 100)
+			ifmr->ifm_current = ifmr->ifm_active =
+			    IFM_ETHER | IFM_100_TX | IFM_FDX;
+		else
+			ifmr->ifm_current = ifmr->ifm_active =
+			    IFM_ETHER | IFM_1000_T | IFM_FDX;
+		ifmr->ifm_mask = 0;
+		ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID;
+	} else if (mii != NULL) {
+		err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr,
+		    &mii->mii_media, SIOCGIFMEDIA);
+		if (err)
+			return (err);
+	} else {
+		return (ENXIO);
+	}
+	return (0);
+}
+
+static int
+ukswitch_setport(device_t dev, etherswitch_port_t *p)
+{
+	struct ukswitch_softc *sc = device_get_softc(dev);
+	struct ifmedia *ifm;
+	struct mii_data *mii;
+	struct ifnet *ifp;
+	int err;
+
+	if (p->es_port < 0 || p->es_port >= sc->numports)
+		return (ENXIO);
+
+	if (sc->portphy[p->es_port] == sc->cpuport)
+		return (ENXIO);
+
+	mii = ukswitch_miiforport(sc, p->es_port);
+	if (mii == NULL)
+		return (ENXIO);
+
+	ifp = ukswitch_ifpforport(sc, p->es_port);
+
+	ifm = &mii->mii_media;
+	err = ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA);
+	return (err);
+}
+
+static int
+ukswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *vg)
+{
+
+	/* Not supported. */
+	vg->es_vid = 0;
+	vg->es_member_ports = 0;
+	vg->es_untagged_ports = 0;
+	vg->es_fid = 0;
+	return (0);
+}
+
+static int
+ukswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *vg)
+{
+
+	/* Not supported. */
+	return (0);
+}
+
+static void
+ukswitch_statchg(device_t dev)
+{
+
+	DPRINTF(dev, "%s\n", __func__);
+}
+
+static int
+ukswitch_ifmedia_upd(struct ifnet *ifp)
+{
+	struct ukswitch_softc *sc = ifp->if_softc;
+	struct mii_data *mii = ukswitch_miiforport(sc, ifp->if_dunit);
+
+	DPRINTF(sc->sc_dev, "%s\n", __func__);
+	if (mii == NULL)
+		return (ENXIO);
+	mii_mediachg(mii);
+	return (0);
+}
+
+static void
+ukswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+	struct ukswitch_softc *sc = ifp->if_softc;
+	struct mii_data *mii = ukswitch_miiforport(sc, ifp->if_dunit);
+
+	DPRINTF(sc->sc_dev, "%s\n", __func__);
+
+	if (mii == NULL)
+		return;
+	mii_pollstat(mii);
+	ifmr->ifm_active = mii->mii_media_active;
+	ifmr->ifm_status = mii->mii_media_status;
+}
+
+static int
+ukswitch_readphy(device_t dev, int phy, int reg)
+{
+	struct ukswitch_softc *sc;
+	int data;
+
+	sc = device_get_softc(dev);
+	UKSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
+
+	if (phy < 0 || phy >= 32)
+		return (ENXIO);
+	if (reg < 0 || reg >= 32)
+		return (ENXIO);
+
+	UKSWITCH_LOCK(sc);
+	data = MDIO_READREG(device_get_parent(dev), phy, reg);
+	UKSWITCH_UNLOCK(sc);
+
+	return (data);
+}
+
+static int
+ukswitch_writephy(device_t dev, int phy, int reg, int data)
+{
+	struct ukswitch_softc *sc;
+	int err;
+
+	sc = device_get_softc(dev);
+	UKSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED);
+
+	if (phy < 0 || phy >= 32)
+		return (ENXIO);
+	if (reg < 0 || reg >= 32)
+		return (ENXIO);
+
+	UKSWITCH_LOCK(sc);
+	err = MDIO_WRITEREG(device_get_parent(dev), phy, reg, data);
+	UKSWITCH_UNLOCK(sc);
+
+	return (err);
+}
+
+static int
+ukswitch_readreg(device_t dev, int addr)
+{
+	struct ukswitch_softc *sc;
+
+	sc = device_get_softc(dev);
+	UKSWITCH_LOCK_ASSERT(sc, MA_OWNED);
+
+	/* Not supported. */
+	return (0);
+}
+
+static int
+ukswitch_writereg(device_t dev, int addr, int value)
+{
+	struct ukswitch_softc *sc;
+
+	sc = device_get_softc(dev);
+	UKSWITCH_LOCK_ASSERT(sc, MA_OWNED);
+
+	/* Not supported. */
+	return (0);
+}
+
+static device_method_t ukswitch_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		ukswitch_probe),
+	DEVMETHOD(device_attach,	ukswitch_attach),
+	DEVMETHOD(device_detach,	ukswitch_detach),
+	
+	/* bus interface */
+	DEVMETHOD(bus_add_child,	device_add_child_ordered),
+	
+	/* MII interface */
+	DEVMETHOD(miibus_readreg,	ukswitch_readphy),
+	DEVMETHOD(miibus_writereg,	ukswitch_writephy),
+	DEVMETHOD(miibus_statchg,	ukswitch_statchg),
+
+	/* MDIO interface */
+	DEVMETHOD(mdio_readreg,		ukswitch_readphy),
+	DEVMETHOD(mdio_writereg,	ukswitch_writephy),
+
+	/* etherswitch interface */
+	DEVMETHOD(etherswitch_lock,	ukswitch_lock),
+	DEVMETHOD(etherswitch_unlock,	ukswitch_unlock),
+	DEVMETHOD(etherswitch_getinfo,	ukswitch_getinfo),
+	DEVMETHOD(etherswitch_readreg,	ukswitch_readreg),
+	DEVMETHOD(etherswitch_writereg,	ukswitch_writereg),
+	DEVMETHOD(etherswitch_readphyreg,	ukswitch_readphy),
+	DEVMETHOD(etherswitch_writephyreg,	ukswitch_writephy),
+	DEVMETHOD(etherswitch_getport,	ukswitch_getport),
+	DEVMETHOD(etherswitch_setport,	ukswitch_setport),
+	DEVMETHOD(etherswitch_getvgroup,	ukswitch_getvgroup),
+	DEVMETHOD(etherswitch_setvgroup,	ukswitch_setvgroup),
+
+	DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(ukswitch, ukswitch_driver, ukswitch_methods,
+    sizeof(struct ukswitch_softc));
+static devclass_t ukswitch_devclass;
+
+DRIVER_MODULE(ukswitch, mdio, ukswitch_driver, ukswitch_devclass, 0, 0);
+DRIVER_MODULE(miibus, ukswitch, miibus_driver, miibus_devclass, 0, 0);
+DRIVER_MODULE(mdio, ukswitch, mdio_driver, mdio_devclass, 0, 0);
+DRIVER_MODULE(etherswitch, ukswitch, etherswitch_driver, etherswitch_devclass, 0, 0);
+MODULE_VERSION(ukswitch, 1);
+MODULE_DEPEND(ukswitch, miibus, 1, 1, 1); /* XXX which versions? */
+MODULE_DEPEND(ukswitch, etherswitch, 1, 1, 1); /* XXX which versions? */

Property changes on: user/attilio/vmcontention/sys/dev/etherswitch/ukswitch/ukswitch.c
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Index: user/attilio/vmcontention/sys/dev/netmap/netmap.c
===================================================================
--- user/attilio/vmcontention/sys/dev/netmap/netmap.c	(revision 249698)
+++ user/attilio/vmcontention/sys/dev/netmap/netmap.c	(revision 249699)
@@ -1,2515 +1,2511 @@
 /*
  * Copyright (C) 2011-2012 Matteo Landi, Luigi Rizzo. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *   1. Redistributions of source code must retain the above copyright
  *      notice, this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright
  *      notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #define NM_BRIDGE
 
 /*
  * This module supports memory mapped access to network devices,
  * see netmap(4).
  *
  * The module uses a large, memory pool allocated by the kernel
  * and accessible as mmapped memory by multiple userspace threads/processes.
  * The memory pool contains packet buffers and "netmap rings",
  * i.e. user-accessible copies of the interface's queues.
  *
  * Access to the network card works like this:
  * 1. a process/thread issues one or more open() on /dev/netmap, to create
  *    select()able file descriptor on which events are reported.
  * 2. on each descriptor, the process issues an ioctl() to identify
  *    the interface that should report events to the file descriptor.
  * 3. on each descriptor, the process issues an mmap() request to
  *    map the shared memory region within the process' address space.
  *    The list of interesting queues is indicated by a location in
  *    the shared memory region.
  * 4. using the functions in the netmap(4) userspace API, a process
  *    can look up the occupation state of a queue, access memory buffers,
  *    and retrieve received packets or enqueue packets to transmit.
  * 5. using some ioctl()s the process can synchronize the userspace view
  *    of the queue with the actual status in the kernel. This includes both
  *    receiving the notification of new packets, and transmitting new
  *    packets on the output interface.
  * 6. select() or poll() can be used to wait for events on individual
  *    transmit or receive queues (or all queues for a given interface).
  */
 
 #ifdef linux
 #include "bsd_glue.h"
 static netdev_tx_t linux_netmap_start(struct sk_buff *skb, struct net_device *dev);
 #endif /* linux */
 
 #ifdef __APPLE__
 #include "osx_glue.h"
 #endif /* __APPLE__ */
 
 #ifdef __FreeBSD__
 #include  /* prerequisite */
 __FBSDID("$FreeBSD$");
 
 #include 
 #include 
 #include 
 #include 	/* defines used in kernel.h */
 #include 
 #include 	/* types used in module initialization */
 #include 	/* cdevsw struct */
 #include 	/* uio struct */
 #include 
 #include 	/* struct socket */
 #include 
 #include 	/* PROT_EXEC */
 #include 
 #include 
 #include 
 #include 	/* vtophys */
 #include 	/* vtophys */
 #include  /* sockaddrs */
 #include 
 #include 
 #include 
 #include 
 #include 		/* BIOCIMMEDIATE */
 #include 
 #include 	/* bus_dmamap_* */
 
 MALLOC_DEFINE(M_NETMAP, "netmap", "Network memory map");
 #endif /* __FreeBSD__ */
 
 #include 
 #include 
 
 u_int netmap_total_buffers;
 u_int netmap_buf_size;
 char *netmap_buffer_base;	/* address of an invalid buffer */
 
 /* user-controlled variables */
 int netmap_verbose;
 
 static int netmap_no_timestamp; /* don't timestamp on rxsync */
 
 SYSCTL_NODE(_dev, OID_AUTO, netmap, CTLFLAG_RW, 0, "Netmap args");
 SYSCTL_INT(_dev_netmap, OID_AUTO, verbose,
     CTLFLAG_RW, &netmap_verbose, 0, "Verbose mode");
 SYSCTL_INT(_dev_netmap, OID_AUTO, no_timestamp,
     CTLFLAG_RW, &netmap_no_timestamp, 0, "no_timestamp");
 int netmap_mitigate = 1;
 SYSCTL_INT(_dev_netmap, OID_AUTO, mitigate, CTLFLAG_RW, &netmap_mitigate, 0, "");
 int netmap_no_pendintr = 1;
 SYSCTL_INT(_dev_netmap, OID_AUTO, no_pendintr,
     CTLFLAG_RW, &netmap_no_pendintr, 0, "Always look for new received packets.");
 
 int netmap_drop = 0;	/* debugging */
 int netmap_flags = 0;	/* debug flags */
 int netmap_fwd = 0;	/* force transparent mode */
 int netmap_copy = 0;	/* debugging, copy content */
 
 SYSCTL_INT(_dev_netmap, OID_AUTO, drop, CTLFLAG_RW, &netmap_drop, 0 , "");
 SYSCTL_INT(_dev_netmap, OID_AUTO, flags, CTLFLAG_RW, &netmap_flags, 0 , "");
 SYSCTL_INT(_dev_netmap, OID_AUTO, fwd, CTLFLAG_RW, &netmap_fwd, 0 , "");
 SYSCTL_INT(_dev_netmap, OID_AUTO, copy, CTLFLAG_RW, &netmap_copy, 0 , "");
 
 #ifdef NM_BRIDGE /* support for netmap bridge */
 
 /*
  * system parameters.
  *
  * All switched ports have prefix NM_NAME.
  * The switch has a max of NM_BDG_MAXPORTS ports (often stored in a bitmap,
  * so a practical upper bound is 64).
  * Each tx ring is read-write, whereas rx rings are readonly (XXX not done yet).
  * The virtual interfaces use per-queue lock instead of core lock.
  * In the tx loop, we aggregate traffic in batches to make all operations
  * faster. The batch size is NM_BDG_BATCH
  */
 #define	NM_NAME			"vale"	/* prefix for the interface */
 #define NM_BDG_MAXPORTS		16	/* up to 64 ? */
 #define NM_BRIDGE_RINGSIZE	1024	/* in the device */
 #define NM_BDG_HASH		1024	/* forwarding table entries */
 #define NM_BDG_BATCH		1024	/* entries in the forwarding buffer */
 #define	NM_BRIDGES		4	/* number of bridges */
 int netmap_bridge = NM_BDG_BATCH; /* bridge batch size */
 SYSCTL_INT(_dev_netmap, OID_AUTO, bridge, CTLFLAG_RW, &netmap_bridge, 0 , "");
 
 #ifdef linux
 #define	ADD_BDG_REF(ifp)	(NA(ifp)->if_refcount++)
 #define	DROP_BDG_REF(ifp)	(NA(ifp)->if_refcount-- <= 1)
 #else /* !linux */
 #define	ADD_BDG_REF(ifp)	(ifp)->if_refcount++
 #define	DROP_BDG_REF(ifp)	refcount_release(&(ifp)->if_refcount)
 #ifdef __FreeBSD__
 #include 
 #include 
 #endif /* __FreeBSD__ */
 #define prefetch(x)	__builtin_prefetch(x)
 #endif /* !linux */
 
 static void bdg_netmap_attach(struct ifnet *ifp);
 static int bdg_netmap_reg(struct ifnet *ifp, int onoff);
 /* per-tx-queue entry */
 struct nm_bdg_fwd {	/* forwarding entry for a bridge */
 	void *buf;
 	uint64_t dst;	/* dst mask */
 	uint32_t src;	/* src index ? */
 	uint16_t len;	/* src len */
 };
 
 struct nm_hash_ent {
 	uint64_t	mac;	/* the top 2 bytes are the epoch */
 	uint64_t	ports;
 };
 
 /*
  * Interfaces for a bridge are all in ports[].
  * The array has fixed size, an empty entry does not terminate
  * the search.
  */
 struct nm_bridge {
 	struct ifnet *bdg_ports[NM_BDG_MAXPORTS];
 	int n_ports;
 	uint64_t act_ports;
 	int freelist;	/* first buffer index */
 	NM_SELINFO_T si;	/* poll/select wait queue */
 	NM_LOCK_T bdg_lock;	/* protect the selinfo ? */
 
 	/* the forwarding table, MAC+ports */
 	struct nm_hash_ent ht[NM_BDG_HASH];
 
 	int namelen;	/* 0 means free */
 	char basename[IFNAMSIZ];
 };
 
 struct nm_bridge nm_bridges[NM_BRIDGES];
 
 #define BDG_LOCK(b)	mtx_lock(&(b)->bdg_lock)
 #define BDG_UNLOCK(b)	mtx_unlock(&(b)->bdg_lock)
 
 /*
  * NA(ifp)->bdg_port	port index
  */
 
 // XXX only for multiples of 64 bytes, non overlapped.
 static inline void
 pkt_copy(void *_src, void *_dst, int l)
 {
         uint64_t *src = _src;
         uint64_t *dst = _dst;
         if (unlikely(l >= 1024)) {
                 bcopy(src, dst, l);
                 return;
         }
         for (; likely(l > 0); l-=64) {
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
                 *dst++ = *src++;
         }
 }
 
 /*
  * locate a bridge among the existing ones.
  * a ':' in the name terminates the bridge name. Otherwise, just NM_NAME.
  * We assume that this is called with a name of at least NM_NAME chars.
  */
 static struct nm_bridge *
 nm_find_bridge(const char *name)
 {
 	int i, l, namelen, e;
 	struct nm_bridge *b = NULL;
 
 	namelen = strlen(NM_NAME);	/* base length */
 	l = strlen(name);		/* actual length */
 	for (i = namelen + 1; i < l; i++) {
 		if (name[i] == ':') {
 			namelen = i;
 			break;
 		}
 	}
 	if (namelen >= IFNAMSIZ)
 		namelen = IFNAMSIZ;
 	ND("--- prefix is '%.*s' ---", namelen, name);
 
 	/* use the first entry for locking */
 	BDG_LOCK(nm_bridges); // XXX do better
 	for (e = -1, i = 1; i < NM_BRIDGES; i++) {
 		b = nm_bridges + i;
 		if (b->namelen == 0)
 			e = i;	/* record empty slot */
 		else if (strncmp(name, b->basename, namelen) == 0) {
 			ND("found '%.*s' at %d", namelen, name, i);
 			break;
 		}
 	}
 	if (i == NM_BRIDGES) { /* all full */
 		if (e == -1) { /* no empty slot */
 			b = NULL;
 		} else {
 			b = nm_bridges + e;
 			strncpy(b->basename, name, namelen);
 			b->namelen = namelen;
 		}
 	}
 	BDG_UNLOCK(nm_bridges);
 	return b;
 }
 #endif /* NM_BRIDGE */
 
 
 /*
  * Fetch configuration from the device, to cope with dynamic
  * reconfigurations after loading the module.
  */
 static int
 netmap_update_config(struct netmap_adapter *na)
 {
 	struct ifnet *ifp = na->ifp;
 	u_int txr, txd, rxr, rxd;
 
 	txr = txd = rxr = rxd = 0;
 	if (na->nm_config) {
 		na->nm_config(ifp, &txr, &txd, &rxr, &rxd);
 	} else {
 		/* take whatever we had at init time */
 		txr = na->num_tx_rings;
 		txd = na->num_tx_desc;
 		rxr = na->num_rx_rings;
 		rxd = na->num_rx_desc;
 	}	
 
 	if (na->num_tx_rings == txr && na->num_tx_desc == txd &&
 	    na->num_rx_rings == rxr && na->num_rx_desc == rxd)
 		return 0; /* nothing changed */
 	if (netmap_verbose || na->refcount > 0) {
 		D("stored config %s: txring %d x %d, rxring %d x %d",
 			ifp->if_xname,
 			na->num_tx_rings, na->num_tx_desc,
 			na->num_rx_rings, na->num_rx_desc);
 		D("new config %s: txring %d x %d, rxring %d x %d",
 			ifp->if_xname, txr, txd, rxr, rxd);
 	}
 	if (na->refcount == 0) {
 		D("configuration changed (but fine)");
 		na->num_tx_rings = txr;
 		na->num_tx_desc = txd;
 		na->num_rx_rings = rxr;
 		na->num_rx_desc = rxd;
 		return 0;
 	}
 	D("configuration changed while active, this is bad...");
 	return 1;
 }
 
 /*------------- memory allocator -----------------*/
-#ifdef NETMAP_MEM2
 #include "netmap_mem2.c"
-#else /* !NETMAP_MEM2 */
-#include "netmap_mem1.c"
-#endif /* !NETMAP_MEM2 */
 /*------------ end of memory allocator ----------*/
 
 
 /* Structure associated to each thread which registered an interface.
  *
  * The first 4 fields of this structure are written by NIOCREGIF and
  * read by poll() and NIOC?XSYNC.
  * There is low contention among writers (actually, a correct user program
  * should have no contention among writers) and among writers and readers,
  * so we use a single global lock to protect the structure initialization.
  * Since initialization involves the allocation of memory, we reuse the memory
  * allocator lock.
  * Read access to the structure is lock free. Readers must check that
  * np_nifp is not NULL before using the other fields.
  * If np_nifp is NULL initialization has not been performed, so they should
  * return an error to userlevel.
  *
  * The ref_done field is used to regulate access to the refcount in the
  * memory allocator. The refcount must be incremented at most once for
  * each open("/dev/netmap"). The increment is performed by the first
  * function that calls netmap_get_memory() (currently called by
  * mmap(), NIOCGINFO and NIOCREGIF).
  * If the refcount is incremented, it is then decremented when the
  * private structure is destroyed.
  */
 struct netmap_priv_d {
 	struct netmap_if * volatile np_nifp;	/* netmap interface descriptor. */
 
 	struct ifnet	*np_ifp;	/* device for which we hold a reference */
 	int		np_ringid;	/* from the ioctl */
 	u_int		np_qfirst, np_qlast;	/* range of rings to scan */
 	uint16_t	np_txpoll;
 
 	unsigned long	ref_done;	/* use with NMA_LOCK held */
 };
 
 
 static int
 netmap_get_memory(struct netmap_priv_d* p)
 {
 	int error = 0;
 	NMA_LOCK();
 	if (!p->ref_done) {
 		error = netmap_memory_finalize();
 		if (!error)
 			p->ref_done = 1;
 	}
 	NMA_UNLOCK();
 	return error;
 }
 
 /*
  * File descriptor's private data destructor.
  *
  * Call nm_register(ifp,0) to stop netmap mode on the interface and
  * revert to normal operation. We expect that np_ifp has not gone.
  */
 /* call with NMA_LOCK held */
 static void
 netmap_dtor_locked(void *data)
 {
 	struct netmap_priv_d *priv = data;
 	struct ifnet *ifp = priv->np_ifp;
 	struct netmap_adapter *na = NA(ifp);
 	struct netmap_if *nifp = priv->np_nifp;
 
 	na->refcount--;
 	if (na->refcount <= 0) {	/* last instance */
 		u_int i, j, lim;
 
 		if (netmap_verbose)
 			D("deleting last instance for %s", ifp->if_xname);
 		/*
 		 * there is a race here with *_netmap_task() and
 		 * netmap_poll(), which don't run under NETMAP_REG_LOCK.
 		 * na->refcount == 0 && na->ifp->if_capenable & IFCAP_NETMAP
 		 * (aka NETMAP_DELETING(na)) are a unique marker that the
 		 * device is dying.
 		 * Before destroying stuff we sleep a bit, and then complete
 		 * the job. NIOCREG should realize the condition and
 		 * loop until they can continue; the other routines
 		 * should check the condition at entry and quit if
 		 * they cannot run.
 		 */
 		na->nm_lock(ifp, NETMAP_REG_UNLOCK, 0);
 		tsleep(na, 0, "NIOCUNREG", 4);
 		na->nm_lock(ifp, NETMAP_REG_LOCK, 0);
 		na->nm_register(ifp, 0); /* off, clear IFCAP_NETMAP */
 		/* Wake up any sleeping threads. netmap_poll will
 		 * then return POLLERR
 		 */
 		for (i = 0; i < na->num_tx_rings + 1; i++)
 			selwakeuppri(&na->tx_rings[i].si, PI_NET);
 		for (i = 0; i < na->num_rx_rings + 1; i++)
 			selwakeuppri(&na->rx_rings[i].si, PI_NET);
 		selwakeuppri(&na->tx_si, PI_NET);
 		selwakeuppri(&na->rx_si, PI_NET);
 		/* release all buffers */
 		for (i = 0; i < na->num_tx_rings + 1; i++) {
 			struct netmap_ring *ring = na->tx_rings[i].ring;
 			lim = na->tx_rings[i].nkr_num_slots;
 			for (j = 0; j < lim; j++)
 				netmap_free_buf(nifp, ring->slot[j].buf_idx);
 			/* knlist_destroy(&na->tx_rings[i].si.si_note); */
 			mtx_destroy(&na->tx_rings[i].q_lock);
 		}
 		for (i = 0; i < na->num_rx_rings + 1; i++) {
 			struct netmap_ring *ring = na->rx_rings[i].ring;
 			lim = na->rx_rings[i].nkr_num_slots;
 			for (j = 0; j < lim; j++)
 				netmap_free_buf(nifp, ring->slot[j].buf_idx);
 			/* knlist_destroy(&na->rx_rings[i].si.si_note); */
 			mtx_destroy(&na->rx_rings[i].q_lock);
 		}
 		/* XXX kqueue(9) needed; these will mirror knlist_init. */
 		/* knlist_destroy(&na->tx_si.si_note); */
 		/* knlist_destroy(&na->rx_si.si_note); */
 		netmap_free_rings(na);
 		wakeup(na);
 	}
 	netmap_if_free(nifp);
 }
 
 static void
 nm_if_rele(struct ifnet *ifp)
 {
 #ifndef NM_BRIDGE
 	if_rele(ifp);
 #else /* NM_BRIDGE */
 	int i, full;
 	struct nm_bridge *b;
 
 	if (strncmp(ifp->if_xname, NM_NAME, sizeof(NM_NAME) - 1)) {
 		if_rele(ifp);
 		return;
 	}
 	if (!DROP_BDG_REF(ifp))
 		return;
 	b = ifp->if_bridge;
 	BDG_LOCK(nm_bridges);
 	BDG_LOCK(b);
 	ND("want to disconnect %s from the bridge", ifp->if_xname);
 	full = 0;
 	for (i = 0; i < NM_BDG_MAXPORTS; i++) {
 		if (b->bdg_ports[i] == ifp) {
 			b->bdg_ports[i] = NULL;
 			bzero(ifp, sizeof(*ifp));
 			free(ifp, M_DEVBUF);
 			break;
 		}
 		else if (b->bdg_ports[i] != NULL)
 			full = 1;
 	}
 	BDG_UNLOCK(b);
 	if (full == 0) {
 		ND("freeing bridge %d", b - nm_bridges);
 		b->namelen = 0;
 	}
 	BDG_UNLOCK(nm_bridges);
 	if (i == NM_BDG_MAXPORTS)
 		D("ouch, cannot find ifp to remove");
 #endif /* NM_BRIDGE */
 }
 
 static void
 netmap_dtor(void *data)
 {
 	struct netmap_priv_d *priv = data;
 	struct ifnet *ifp = priv->np_ifp;
-	struct netmap_adapter *na;
 
 	NMA_LOCK();
 	if (ifp) {
-		na = NA(ifp);
+		struct netmap_adapter *na = NA(ifp);
+
 		na->nm_lock(ifp, NETMAP_REG_LOCK, 0);
 		netmap_dtor_locked(data);
 		na->nm_lock(ifp, NETMAP_REG_UNLOCK, 0);
 
-		nm_if_rele(ifp);
+		nm_if_rele(ifp); /* might also destroy *na */
 	}
 	if (priv->ref_done) {
 		netmap_memory_deref();
 	}
 	NMA_UNLOCK();
 	bzero(priv, sizeof(*priv));	/* XXX for safety */
 	free(priv, M_DEVBUF);
 }
 
 #ifdef __FreeBSD__
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 static struct cdev_pager_ops saved_cdev_pager_ops;
 
 static int
 netmap_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
     vm_ooffset_t foff, struct ucred *cred, u_short *color)
 {
 	if (netmap_verbose)
 		D("first mmap for %p", handle);
 	return saved_cdev_pager_ops.cdev_pg_ctor(handle,
 			size, prot, foff, cred, color);
 }
 
 static void
 netmap_dev_pager_dtor(void *handle)
 {
 	saved_cdev_pager_ops.cdev_pg_dtor(handle);
 	ND("ready to release memory for %p", handle);
 }
 
 
 static struct cdev_pager_ops netmap_cdev_pager_ops = {
         .cdev_pg_ctor = netmap_dev_pager_ctor,
         .cdev_pg_dtor = netmap_dev_pager_dtor,
         .cdev_pg_fault = NULL,
 };
 
 static int
 netmap_mmap_single(struct cdev *cdev, vm_ooffset_t *foff,
 	vm_size_t objsize,  vm_object_t *objp, int prot)
 {
 	vm_object_t obj;
 
 	ND("cdev %p foff %jd size %jd objp %p prot %d", cdev,
 	    (intmax_t )*foff, (intmax_t )objsize, objp, prot);
 	obj = vm_pager_allocate(OBJT_DEVICE, cdev, objsize, prot, *foff,
             curthread->td_ucred);
 	ND("returns obj %p", obj);
 	if (obj == NULL)
 		return EINVAL;
 	if (saved_cdev_pager_ops.cdev_pg_fault == NULL) {
 		ND("initialize cdev_pager_ops");
 		saved_cdev_pager_ops = *(obj->un_pager.devp.ops);
 		netmap_cdev_pager_ops.cdev_pg_fault =
 			saved_cdev_pager_ops.cdev_pg_fault;
 	};
 	obj->un_pager.devp.ops = &netmap_cdev_pager_ops;
 	*objp = obj;
 	return 0;
 }
 #endif /* __FreeBSD__ */
 
 
 /*
  * mmap(2) support for the "netmap" device.
  *
  * Expose all the memory previously allocated by our custom memory
  * allocator: this way the user has only to issue a single mmap(2), and
  * can work on all the data structures flawlessly.
  *
  * Return 0 on success, -1 otherwise.
  */
 
 #ifdef __FreeBSD__
 static int
 netmap_mmap(__unused struct cdev *dev,
 #if __FreeBSD_version < 900000
 		vm_offset_t offset, vm_paddr_t *paddr, int nprot
 #else
 		vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
 		__unused vm_memattr_t *memattr
 #endif
 	)
 {
 	int error = 0;
 	struct netmap_priv_d *priv;
 
 	if (nprot & PROT_EXEC)
 		return (-1);	// XXX -1 or EINVAL ?
 
 	error = devfs_get_cdevpriv((void **)&priv);
 	if (error == EBADF) {	/* called on fault, memory is initialized */
 		ND(5, "handling fault at ofs 0x%x", offset);
 		error = 0;
 	} else if (error == 0)	/* make sure memory is set */
 		error = netmap_get_memory(priv);
 	if (error)
 		return (error);
 
 	ND("request for offset 0x%x", (uint32_t)offset);
 	*paddr = netmap_ofstophys(offset);
 
 	return (*paddr ? 0 : ENOMEM);
 }
 
 static int
 netmap_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
 {
 	if (netmap_verbose)
 		D("dev %p fflag 0x%x devtype %d td %p",
 			dev, fflag, devtype, td);
 	return 0;
 }
 
 static int
 netmap_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
 {
 	struct netmap_priv_d *priv;
 	int error;
 
 	priv = malloc(sizeof(struct netmap_priv_d), M_DEVBUF,
 			      M_NOWAIT | M_ZERO);
 	if (priv == NULL)
 		return ENOMEM;
 
 	error = devfs_set_cdevpriv(priv, netmap_dtor);
 	if (error)
 	        return error;
 
 	return 0;
 }
 #endif /* __FreeBSD__ */
 
 
 /*
  * Handlers for synchronization of the queues from/to the host.
  * Netmap has two operating modes:
  * - in the default mode, the rings connected to the host stack are
  *   just another ring pair managed by userspace;
  * - in transparent mode (XXX to be defined) incoming packets
  *   (from the host or the NIC) are marked as NS_FORWARD upon
  *   arrival, and the user application has a chance to reset the
  *   flag for packets that should be dropped.
  *   On the RXSYNC or poll(), packets in RX rings between
  *   kring->nr_kcur and ring->cur with NS_FORWARD still set are moved
  *   to the other side.
  * The transfer NIC --> host is relatively easy, just encapsulate
  * into mbufs and we are done. The host --> NIC side is slightly
  * harder because there might not be room in the tx ring so it
  * might take a while before releasing the buffer.
  */
 
 /*
  * pass a chain of buffers to the host stack as coming from 'dst'
  */
 static void
 netmap_send_up(struct ifnet *dst, struct mbuf *head)
 {
 	struct mbuf *m;
 
 	/* send packets up, outside the lock */
 	while ((m = head) != NULL) {
 		head = head->m_nextpkt;
 		m->m_nextpkt = NULL;
 		if (netmap_verbose & NM_VERB_HOST)
 			D("sending up pkt %p size %d", m, MBUF_LEN(m));
 		NM_SEND_UP(dst, m);
 	}
 }
 
 struct mbq {
 	struct mbuf *head;
 	struct mbuf *tail;
 	int count;
 };
 
 /*
  * put a copy of the buffers marked NS_FORWARD into an mbuf chain.
  * Run from hwcur to cur - reserved
  */
 static void
 netmap_grab_packets(struct netmap_kring *kring, struct mbq *q, int force)
 {
 	/* Take packets from hwcur to cur-reserved and pass them up.
 	 * In case of no buffers we give up. At the end of the loop,
 	 * the queue is drained in all cases.
 	 * XXX handle reserved
 	 */
 	int k = kring->ring->cur - kring->ring->reserved;
 	u_int n, lim = kring->nkr_num_slots - 1;
 	struct mbuf *m, *tail = q->tail;
 
 	if (k < 0)
 		k = k + kring->nkr_num_slots;
 	for (n = kring->nr_hwcur; n != k;) {
 		struct netmap_slot *slot = &kring->ring->slot[n];
 
 		n = (n == lim) ? 0 : n + 1;
 		if ((slot->flags & NS_FORWARD) == 0 && !force)
 			continue;
 		if (slot->len < 14 || slot->len > NETMAP_BUF_SIZE) {
 			D("bad pkt at %d len %d", n, slot->len);
 			continue;
 		}
 		slot->flags &= ~NS_FORWARD; // XXX needed ?
 		m = m_devget(NMB(slot), slot->len, 0, kring->na->ifp, NULL);
 
 		if (m == NULL)
 			break;
 		if (tail)
 			tail->m_nextpkt = m;
 		else
 			q->head = m;
 		tail = m;
 		q->count++;
 		m->m_nextpkt = NULL;
 	}
 	q->tail = tail;
 }
 
 /*
  * called under main lock to send packets from the host to the NIC
  * The host ring has packets from nr_hwcur to (cur - reserved)
  * to be sent down. We scan the tx rings, which have just been
  * flushed so nr_hwcur == cur. Pushing packets down means
  * increment cur and decrement avail.
  * XXX to be verified
  */
 static void
 netmap_sw_to_nic(struct netmap_adapter *na)
 {
 	struct netmap_kring *kring = &na->rx_rings[na->num_rx_rings];
 	struct netmap_kring *k1 = &na->tx_rings[0];
 	int i, howmany, src_lim, dst_lim;
 
 	howmany = kring->nr_hwavail;	/* XXX otherwise cur - reserved - nr_hwcur */
 
 	src_lim = kring->nkr_num_slots;
 	for (i = 0; howmany > 0 && i < na->num_tx_rings; i++, k1++) {
 		ND("%d packets left to ring %d (space %d)", howmany, i, k1->nr_hwavail);
 		dst_lim = k1->nkr_num_slots;
 		while (howmany > 0 && k1->ring->avail > 0) {
 			struct netmap_slot *src, *dst, tmp;
 			src = &kring->ring->slot[kring->nr_hwcur];
 			dst = &k1->ring->slot[k1->ring->cur];
 			tmp = *src;
 			src->buf_idx = dst->buf_idx;
 			src->flags = NS_BUF_CHANGED;
 
 			dst->buf_idx = tmp.buf_idx;
 			dst->len = tmp.len;
 			dst->flags = NS_BUF_CHANGED;
 			ND("out len %d buf %d from %d to %d",
 				dst->len, dst->buf_idx,
 				kring->nr_hwcur, k1->ring->cur);
 
 			if (++kring->nr_hwcur >= src_lim)
 				kring->nr_hwcur = 0;
 			howmany--;
 			kring->nr_hwavail--;
 			if (++k1->ring->cur >= dst_lim)
 				k1->ring->cur = 0;
 			k1->ring->avail--;
 		}
 		kring->ring->cur = kring->nr_hwcur; // XXX
 		k1++;
 	}
 }
 
 /*
  * netmap_sync_to_host() passes packets up. We are called from a
  * system call in user process context, and the only contention
  * can be among multiple user threads erroneously calling
  * this routine concurrently.
  */
 static void
 netmap_sync_to_host(struct netmap_adapter *na)
 {
 	struct netmap_kring *kring = &na->tx_rings[na->num_tx_rings];
 	struct netmap_ring *ring = kring->ring;
 	u_int k, lim = kring->nkr_num_slots - 1;
 	struct mbq q = { NULL, NULL };
 
 	k = ring->cur;
 	if (k > lim) {
 		netmap_ring_reinit(kring);
 		return;
 	}
 	// na->nm_lock(na->ifp, NETMAP_CORE_LOCK, 0);
 
 	/* Take packets from hwcur to cur and pass them up.
 	 * In case of no buffers we give up. At the end of the loop,
 	 * the queue is drained in all cases.
 	 */
 	netmap_grab_packets(kring, &q, 1);
 	kring->nr_hwcur = k;
 	kring->nr_hwavail = ring->avail = lim;
 	// na->nm_lock(na->ifp, NETMAP_CORE_UNLOCK, 0);
 
 	netmap_send_up(na->ifp, q.head);
 }
 
 /*
  * rxsync backend for packets coming from the host stack.
  * They have been put in the queue by netmap_start() so we
  * need to protect access to the kring using a lock.
  *
  * This routine also does the selrecord if called from the poll handler
  * (we know because td != NULL).
  *
  * NOTE: on linux, selrecord() is defined as a macro and uses pwait
  *     as an additional hidden argument.
  */
 static void
 netmap_sync_from_host(struct netmap_adapter *na, struct thread *td, void *pwait)
 {
 	struct netmap_kring *kring = &na->rx_rings[na->num_rx_rings];
 	struct netmap_ring *ring = kring->ring;
 	u_int j, n, lim = kring->nkr_num_slots;
 	u_int k = ring->cur, resvd = ring->reserved;
 
 	(void)pwait;	/* disable unused warnings */
 	na->nm_lock(na->ifp, NETMAP_CORE_LOCK, 0);
 	if (k >= lim) {
 		netmap_ring_reinit(kring);
 		return;
 	}
 	/* new packets are already set in nr_hwavail */
 	/* skip past packets that userspace has released */
 	j = kring->nr_hwcur;
 	if (resvd > 0) {
 		if (resvd + ring->avail >= lim + 1) {
 			D("XXX invalid reserve/avail %d %d", resvd, ring->avail);
 			ring->reserved = resvd = 0; // XXX panic...
 		}
 		k = (k >= resvd) ? k - resvd : k + lim - resvd;
         }
 	if (j != k) {
 		n = k >= j ? k - j : k + lim - j;
 		kring->nr_hwavail -= n;
 		kring->nr_hwcur = k;
 	}
 	k = ring->avail = kring->nr_hwavail - resvd;
 	if (k == 0 && td)
 		selrecord(td, &kring->si);
 	if (k && (netmap_verbose & NM_VERB_HOST))
 		D("%d pkts from stack", k);
 	na->nm_lock(na->ifp, NETMAP_CORE_UNLOCK, 0);
 }
 
 
 /*
  * get a refcounted reference to an interface.
  * Return ENXIO if the interface does not exist, EINVAL if netmap
  * is not supported by the interface.
  * If successful, hold a reference.
  */
 static int
 get_ifp(const char *name, struct ifnet **ifp)
 {
 #ifdef NM_BRIDGE
 	struct ifnet *iter = NULL;
 
 	do {
 		struct nm_bridge *b;
 		int i, l, cand = -1;
 
 		if (strncmp(name, NM_NAME, sizeof(NM_NAME) - 1))
 			break;
 		b = nm_find_bridge(name);
 		if (b == NULL) {
 			D("no bridges available for '%s'", name);
 			return (ENXIO);
 		}
 		/* XXX locking */
 		BDG_LOCK(b);
 		/* lookup in the local list of ports */
 		for (i = 0; i < NM_BDG_MAXPORTS; i++) {
 			iter = b->bdg_ports[i];
 			if (iter == NULL) {
 				if (cand == -1)
 					cand = i; /* potential insert point */
 				continue;
 			}
 			if (!strcmp(iter->if_xname, name)) {
 				ADD_BDG_REF(iter);
 				ND("found existing interface");
 				BDG_UNLOCK(b);
 				break;
 			}
 		}
 		if (i < NM_BDG_MAXPORTS) /* already unlocked */
 			break;
 		if (cand == -1) {
 			D("bridge full, cannot create new port");
 no_port:
 			BDG_UNLOCK(b);
 			*ifp = NULL;
 			return EINVAL;
 		}
 		ND("create new bridge port %s", name);
 		/* space for forwarding list after the ifnet */
 		l = sizeof(*iter) +
 			 sizeof(struct nm_bdg_fwd)*NM_BDG_BATCH ;
 		iter = malloc(l, M_DEVBUF, M_NOWAIT | M_ZERO);
 		if (!iter)
 			goto no_port;
 		strcpy(iter->if_xname, name);
 		bdg_netmap_attach(iter);
 		b->bdg_ports[cand] = iter;
 		iter->if_bridge = b;
 		ADD_BDG_REF(iter);
 		BDG_UNLOCK(b);
 		ND("attaching virtual bridge %p", b);
 	} while (0);
 	*ifp = iter;
 	if (! *ifp)
 #endif /* NM_BRIDGE */
 	*ifp = ifunit_ref(name);
 	if (*ifp == NULL)
 		return (ENXIO);
 	/* can do this if the capability exists and if_pspare[0]
 	 * points to the netmap descriptor.
 	 */
 	if (NETMAP_CAPABLE(*ifp))
 		return 0;	/* valid pointer, we hold the refcount */
 	nm_if_rele(*ifp);
 	return EINVAL;	// not NETMAP capable
 }
 
 
 /*
  * Error routine called when txsync/rxsync detects an error.
  * Can't do much more than resetting cur = hwcur, avail = hwavail.
  * Return 1 on reinit.
  *
  * This routine is only called by the upper half of the kernel.
  * It only reads hwcur (which is changed only by the upper half, too)
  * and hwavail (which may be changed by the lower half, but only on
  * a tx ring and only to increase it, so any error will be recovered
  * on the next call). For the above, we don't strictly need to call
  * it under lock.
  */
 int
 netmap_ring_reinit(struct netmap_kring *kring)
 {
 	struct netmap_ring *ring = kring->ring;
 	u_int i, lim = kring->nkr_num_slots - 1;
 	int errors = 0;
 
 	RD(10, "called for %s", kring->na->ifp->if_xname);
 	if (ring->cur > lim)
 		errors++;
 	for (i = 0; i <= lim; i++) {
 		u_int idx = ring->slot[i].buf_idx;
 		u_int len = ring->slot[i].len;
 		if (idx < 2 || idx >= netmap_total_buffers) {
 			if (!errors++)
 				D("bad buffer at slot %d idx %d len %d ", i, idx, len);
 			ring->slot[i].buf_idx = 0;
 			ring->slot[i].len = 0;
 		} else if (len > NETMAP_BUF_SIZE) {
 			ring->slot[i].len = 0;
 			if (!errors++)
 				D("bad len %d at slot %d idx %d",
 					len, i, idx);
 		}
 	}
 	if (errors) {
 		int pos = kring - kring->na->tx_rings;
 		int n = kring->na->num_tx_rings + 1;
 
 		RD(10, "total %d errors", errors);
 		errors++;
 		RD(10, "%s %s[%d] reinit, cur %d -> %d avail %d -> %d",
 			kring->na->ifp->if_xname,
 			pos < n ?  "TX" : "RX", pos < n ? pos : pos - n,
 			ring->cur, kring->nr_hwcur,
 			ring->avail, kring->nr_hwavail);
 		ring->cur = kring->nr_hwcur;
 		ring->avail = kring->nr_hwavail;
 	}
 	return (errors ? 1 : 0);
 }
 
 
 /*
  * Set the ring ID. For devices with a single queue, a request
  * for all rings is the same as a single ring.
  */
 static int
 netmap_set_ringid(struct netmap_priv_d *priv, u_int ringid)
 {
 	struct ifnet *ifp = priv->np_ifp;
 	struct netmap_adapter *na = NA(ifp);
 	u_int i = ringid & NETMAP_RING_MASK;
 	/* initially (np_qfirst == np_qlast) we don't want to lock */
 	int need_lock = (priv->np_qfirst != priv->np_qlast);
 	int lim = na->num_rx_rings;
 
 	if (na->num_tx_rings > lim)
 		lim = na->num_tx_rings;
 	if ( (ringid & NETMAP_HW_RING) && i >= lim) {
 		D("invalid ring id %d", i);
 		return (EINVAL);
 	}
 	if (need_lock)
 		na->nm_lock(ifp, NETMAP_CORE_LOCK, 0);
 	priv->np_ringid = ringid;
 	if (ringid & NETMAP_SW_RING) {
 		priv->np_qfirst = NETMAP_SW_RING;
 		priv->np_qlast = 0;
 	} else if (ringid & NETMAP_HW_RING) {
 		priv->np_qfirst = i;
 		priv->np_qlast = i + 1;
 	} else {
 		priv->np_qfirst = 0;
 		priv->np_qlast = NETMAP_HW_RING ;
 	}
 	priv->np_txpoll = (ringid & NETMAP_NO_TX_POLL) ? 0 : 1;
 	if (need_lock)
 		na->nm_lock(ifp, NETMAP_CORE_UNLOCK, 0);
     if (netmap_verbose) {
 	if (ringid & NETMAP_SW_RING)
 		D("ringid %s set to SW RING", ifp->if_xname);
 	else if (ringid & NETMAP_HW_RING)
 		D("ringid %s set to HW RING %d", ifp->if_xname,
 			priv->np_qfirst);
 	else
 		D("ringid %s set to all %d HW RINGS", ifp->if_xname, lim);
     }
 	return 0;
 }
 
 /*
  * ioctl(2) support for the "netmap" device.
  *
  * Following a list of accepted commands:
  * - NIOCGINFO
  * - SIOCGIFADDR	just for convenience
  * - NIOCREGIF
  * - NIOCUNREGIF
  * - NIOCTXSYNC
  * - NIOCRXSYNC
  *
  * Return 0 on success, errno otherwise.
  */
 static int
 netmap_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
 	int fflag, struct thread *td)
 {
 	struct netmap_priv_d *priv = NULL;
 	struct ifnet *ifp;
 	struct nmreq *nmr = (struct nmreq *) data;
 	struct netmap_adapter *na;
 	int error;
 	u_int i, lim;
 	struct netmap_if *nifp;
 
 	(void)dev;	/* UNUSED */
 	(void)fflag;	/* UNUSED */
 #ifdef linux
 #define devfs_get_cdevpriv(pp)				\
 	({ *(struct netmap_priv_d **)pp = ((struct file *)td)->private_data; 	\
 		(*pp ? 0 : ENOENT); })
 
 /* devfs_set_cdevpriv cannot fail on linux */
 #define devfs_set_cdevpriv(p, fn)				\
 	({ ((struct file *)td)->private_data = p; (p ? 0 : EINVAL); })
 
 
 #define devfs_clear_cdevpriv()	do {				\
 		netmap_dtor(priv); ((struct file *)td)->private_data = 0;	\
 	} while (0)
 #endif /* linux */
 
 	CURVNET_SET(TD_TO_VNET(td));
 
 	error = devfs_get_cdevpriv((void **)&priv);
 	if (error) {
 		CURVNET_RESTORE();
 		/* XXX ENOENT should be impossible, since the priv
 		 * is now created in the open */
 		return (error == ENOENT ? ENXIO : error);
 	}
 
 	nmr->nr_name[sizeof(nmr->nr_name) - 1] = '\0';	/* truncate name */
 	switch (cmd) {
 	case NIOCGINFO:		/* return capabilities etc */
 		if (nmr->nr_version != NETMAP_API) {
 			D("API mismatch got %d have %d",
 				nmr->nr_version, NETMAP_API);
 			nmr->nr_version = NETMAP_API;
 			error = EINVAL;
 			break;
 		}
 		/* update configuration */
 		error = netmap_get_memory(priv);
 		ND("get_memory returned %d", error);
 		if (error)
 			break;
 		/* memsize is always valid */
 		nmr->nr_memsize = nm_mem.nm_totalsize;
 		nmr->nr_offset = 0;
 		nmr->nr_rx_rings = nmr->nr_tx_rings = 0;
 		nmr->nr_rx_slots = nmr->nr_tx_slots = 0;
 		if (nmr->nr_name[0] == '\0')	/* just get memory info */
 			break;
 		error = get_ifp(nmr->nr_name, &ifp); /* get a refcount */
 		if (error)
 			break;
 		na = NA(ifp); /* retrieve netmap_adapter */
 		netmap_update_config(na);
 		nmr->nr_rx_rings = na->num_rx_rings;
 		nmr->nr_tx_rings = na->num_tx_rings;
 		nmr->nr_rx_slots = na->num_rx_desc;
 		nmr->nr_tx_slots = na->num_tx_desc;
 		nm_if_rele(ifp);	/* return the refcount */
 		break;
 
 	case NIOCREGIF:
 		if (nmr->nr_version != NETMAP_API) {
 			nmr->nr_version = NETMAP_API;
 			error = EINVAL;
 			break;
 		}
 		/* ensure allocators are ready */
 		error = netmap_get_memory(priv);
 		ND("get_memory returned %d", error);
 		if (error)
 			break;
 
 		/* protect access to priv from concurrent NIOCREGIF */
 		NMA_LOCK();
 		if (priv->np_ifp != NULL) {	/* thread already registered */
 			error = netmap_set_ringid(priv, nmr->nr_ringid);
 			NMA_UNLOCK();
 			break;
 		}
 		/* find the interface and a reference */
 		error = get_ifp(nmr->nr_name, &ifp); /* keep reference */
 		if (error) {
 			NMA_UNLOCK();
 			break;
 		}
 		na = NA(ifp); /* retrieve netmap adapter */
 
 		for (i = 10; i > 0; i--) {
 			na->nm_lock(ifp, NETMAP_REG_LOCK, 0);
 			if (!NETMAP_DELETING(na))
 				break;
 			na->nm_lock(ifp, NETMAP_REG_UNLOCK, 0);
 			tsleep(na, 0, "NIOCREGIF", hz/10);
 		}
 		if (i == 0) {
 			D("too many NIOCREGIF attempts, give up");
 			error = EINVAL;
 			nm_if_rele(ifp);	/* return the refcount */
 			NMA_UNLOCK();
 			break;
 		}
 
 		/* ring configuration may have changed, fetch from the card */
 		netmap_update_config(na);
 		priv->np_ifp = ifp;	/* store the reference */
 		error = netmap_set_ringid(priv, nmr->nr_ringid);
 		if (error)
 			goto error;
 		nifp = netmap_if_new(nmr->nr_name, na);
 		if (nifp == NULL) { /* allocation failed */
 			error = ENOMEM;
 		} else if (ifp->if_capenable & IFCAP_NETMAP) {
 			/* was already set */
 		} else {
 			/* Otherwise set the card in netmap mode
 			 * and make it use the shared buffers.
 			 */
 			for (i = 0 ; i < na->num_tx_rings + 1; i++)
 				mtx_init(&na->tx_rings[i].q_lock, "nm_txq_lock", MTX_NETWORK_LOCK, MTX_DEF);
 			for (i = 0 ; i < na->num_rx_rings + 1; i++) {
 				mtx_init(&na->rx_rings[i].q_lock, "nm_rxq_lock", MTX_NETWORK_LOCK, MTX_DEF);
 			}
 			error = na->nm_register(ifp, 1); /* mode on */
 			if (error) {
 				netmap_dtor_locked(priv);
 				netmap_if_free(nifp);
 			}
 		}
 
 		if (error) {	/* reg. failed, release priv and ref */
 error:
 			na->nm_lock(ifp, NETMAP_REG_UNLOCK, 0);
 			nm_if_rele(ifp);	/* return the refcount */
 			priv->np_ifp = NULL;
 			priv->np_nifp = NULL;
 			NMA_UNLOCK();
 			break;
 		}
 
 		na->nm_lock(ifp, NETMAP_REG_UNLOCK, 0);
 
 		/* the following assignment is a commitment.
 		 * Readers (i.e., poll and *SYNC) check for
 		 * np_nifp != NULL without locking
 		 */
 		wmb(); /* make sure previous writes are visible to all CPUs */
 		priv->np_nifp = nifp;
 		NMA_UNLOCK();
 
 		/* return the offset of the netmap_if object */
 		nmr->nr_rx_rings = na->num_rx_rings;
 		nmr->nr_tx_rings = na->num_tx_rings;
 		nmr->nr_rx_slots = na->num_rx_desc;
 		nmr->nr_tx_slots = na->num_tx_desc;
 		nmr->nr_memsize = nm_mem.nm_totalsize;
 		nmr->nr_offset = netmap_if_offset(nifp);
 		break;
 
 	case NIOCUNREGIF:
 		// XXX we have no data here ?
 		D("deprecated, data is %p", nmr);
 		error = EINVAL;
 		break;
 
 	case NIOCTXSYNC:
 	case NIOCRXSYNC:
 		nifp = priv->np_nifp;
 
 		if (nifp == NULL) {
 			error = ENXIO;
 			break;
 		}
 		rmb(); /* make sure following reads are not from cache */
 
 
 		ifp = priv->np_ifp;	/* we have a reference */
 
 		if (ifp == NULL) {
 			D("Internal error: nifp != NULL && ifp == NULL");
 			error = ENXIO;
 			break;
 		}
 
 		na = NA(ifp); /* retrieve netmap adapter */
 		if (priv->np_qfirst == NETMAP_SW_RING) { /* host rings */
 			if (cmd == NIOCTXSYNC)
 				netmap_sync_to_host(na);
 			else
 				netmap_sync_from_host(na, NULL, NULL);
 			break;
 		}
 		/* find the last ring to scan */
 		lim = priv->np_qlast;
 		if (lim == NETMAP_HW_RING)
 			lim = (cmd == NIOCTXSYNC) ?
 			    na->num_tx_rings : na->num_rx_rings;
 
 		for (i = priv->np_qfirst; i < lim; i++) {
 			if (cmd == NIOCTXSYNC) {
 				struct netmap_kring *kring = &na->tx_rings[i];
 				if (netmap_verbose & NM_VERB_TXSYNC)
 					D("pre txsync ring %d cur %d hwcur %d",
 					    i, kring->ring->cur,
 					    kring->nr_hwcur);
 				na->nm_txsync(ifp, i, 1 /* do lock */);
 				if (netmap_verbose & NM_VERB_TXSYNC)
 					D("post txsync ring %d cur %d hwcur %d",
 					    i, kring->ring->cur,
 					    kring->nr_hwcur);
 			} else {
 				na->nm_rxsync(ifp, i, 1 /* do lock */);
 				microtime(&na->rx_rings[i].ring->ts);
 			}
 		}
 
 		break;
 
 #ifdef __FreeBSD__
 	case BIOCIMMEDIATE:
 	case BIOCGHDRCMPLT:
 	case BIOCSHDRCMPLT:
 	case BIOCSSEESENT:
 		D("ignore BIOCIMMEDIATE/BIOCSHDRCMPLT/BIOCSHDRCMPLT/BIOCSSEESENT");
 		break;
 
 	default:	/* allow device-specific ioctls */
 	    {
 		struct socket so;
 		bzero(&so, sizeof(so));
 		error = get_ifp(nmr->nr_name, &ifp); /* keep reference */
 		if (error)
 			break;
 		so.so_vnet = ifp->if_vnet;
 		// so->so_proto not null.
 		error = ifioctl(&so, cmd, data, td);
 		nm_if_rele(ifp);
 		break;
 	    }
 
 #else /* linux */
 	default:
 		error = EOPNOTSUPP;
 #endif /* linux */
 	}
 
 	CURVNET_RESTORE();
 	return (error);
 }
 
 
 /*
  * select(2) and poll(2) handlers for the "netmap" device.
  *
  * Can be called for one or more queues.
  * Return true the event mask corresponding to ready events.
  * If there are no ready events, do a selrecord on either individual
  * selfd or on the global one.
  * Device-dependent parts (locking and sync of tx/rx rings)
  * are done through callbacks.
  *
  * On linux, arguments are really pwait, the poll table, and 'td' is struct file *
  * The first one is remapped to pwait as selrecord() uses the name as an
  * hidden argument.
  */
 static int
 netmap_poll(struct cdev *dev, int events, struct thread *td)
 {
 	struct netmap_priv_d *priv = NULL;
 	struct netmap_adapter *na;
 	struct ifnet *ifp;
 	struct netmap_kring *kring;
 	u_int core_lock, i, check_all, want_tx, want_rx, revents = 0;
 	u_int lim_tx, lim_rx, host_forwarded = 0;
 	struct mbq q = { NULL, NULL, 0 };
 	enum {NO_CL, NEED_CL, LOCKED_CL }; /* see below */
 	void *pwait = dev;	/* linux compatibility */
 
 	(void)pwait;
 
 	if (devfs_get_cdevpriv((void **)&priv) != 0 || priv == NULL)
 		return POLLERR;
 
 	if (priv->np_nifp == NULL) {
 		D("No if registered");
 		return POLLERR;
 	}
 	rmb(); /* make sure following reads are not from cache */
 
 	ifp = priv->np_ifp;
 	// XXX check for deleting() ?
 	if ( (ifp->if_capenable & IFCAP_NETMAP) == 0)
 		return POLLERR;
 
 	if (netmap_verbose & 0x8000)
 		D("device %s events 0x%x", ifp->if_xname, events);
 	want_tx = events & (POLLOUT | POLLWRNORM);
 	want_rx = events & (POLLIN | POLLRDNORM);
 
 	na = NA(ifp); /* retrieve netmap adapter */
 
 	lim_tx = na->num_tx_rings;
 	lim_rx = na->num_rx_rings;
 	/* how many queues we are scanning */
 	if (priv->np_qfirst == NETMAP_SW_RING) {
 		if (priv->np_txpoll || want_tx) {
 			/* push any packets up, then we are always ready */
 			kring = &na->tx_rings[lim_tx];
 			netmap_sync_to_host(na);
 			revents |= want_tx;
 		}
 		if (want_rx) {
 			kring = &na->rx_rings[lim_rx];
 			if (kring->ring->avail == 0)
 				netmap_sync_from_host(na, td, dev);
 			if (kring->ring->avail > 0) {
 				revents |= want_rx;
 			}
 		}
 		return (revents);
 	}
 
 	/* if we are in transparent mode, check also the host rx ring */
 	kring = &na->rx_rings[lim_rx];
 	if ( (priv->np_qlast == NETMAP_HW_RING) // XXX check_all
 			&& want_rx
 			&& (netmap_fwd || kring->ring->flags & NR_FORWARD) ) {
 		if (kring->ring->avail == 0)
 			netmap_sync_from_host(na, td, dev);
 		if (kring->ring->avail > 0)
 			revents |= want_rx;
 	}
 
 	/*
 	 * check_all is set if the card has more than one queue and
 	 * the client is polling all of them. If true, we sleep on
 	 * the "global" selfd, otherwise we sleep on individual selfd
 	 * (we can only sleep on one of them per direction).
 	 * The interrupt routine in the driver should always wake on
 	 * the individual selfd, and also on the global one if the card
 	 * has more than one ring.
 	 *
 	 * If the card has only one lock, we just use that.
 	 * If the card has separate ring locks, we just use those
 	 * unless we are doing check_all, in which case the whole
 	 * loop is wrapped by the global lock.
 	 * We acquire locks only when necessary: if poll is called
 	 * when buffers are available, we can just return without locks.
 	 *
 	 * rxsync() is only called if we run out of buffers on a POLLIN.
 	 * txsync() is called if we run out of buffers on POLLOUT, or
 	 * there are pending packets to send. The latter can be disabled
 	 * passing NETMAP_NO_TX_POLL in the NIOCREG call.
 	 */
 	check_all = (priv->np_qlast == NETMAP_HW_RING) && (lim_tx > 1 || lim_rx > 1);
 
 	/*
 	 * core_lock indicates what to do with the core lock.
 	 * The core lock is used when either the card has no individual
 	 * locks, or it has individual locks but we are cheking all
 	 * rings so we need the core lock to avoid missing wakeup events.
 	 *
 	 * It has three possible states:
 	 * NO_CL	we don't need to use the core lock, e.g.
 	 *		because we are protected by individual locks.
 	 * NEED_CL	we need the core lock. In this case, when we
 	 *		call the lock routine, move to LOCKED_CL
 	 *		to remember to release the lock once done.
 	 * LOCKED_CL	core lock is set, so we need to release it.
 	 */
 	core_lock = (check_all || !na->separate_locks) ? NEED_CL : NO_CL;
 #ifdef NM_BRIDGE
 	/* the bridge uses separate locks */
 	if (na->nm_register == bdg_netmap_reg) {
 		ND("not using core lock for %s", ifp->if_xname);
 		core_lock = NO_CL;
 	}
 #endif /* NM_BRIDGE */
 	if (priv->np_qlast != NETMAP_HW_RING) {
 		lim_tx = lim_rx = priv->np_qlast;
 	}
 
 	/*
 	 * We start with a lock free round which is good if we have
 	 * data available. If this fails, then lock and call the sync
 	 * routines.
 	 */
 	for (i = priv->np_qfirst; want_rx && i < lim_rx; i++) {
 		kring = &na->rx_rings[i];
 		if (kring->ring->avail > 0) {
 			revents |= want_rx;
 			want_rx = 0;	/* also breaks the loop */
 		}
 	}
 	for (i = priv->np_qfirst; want_tx && i < lim_tx; i++) {
 		kring = &na->tx_rings[i];
 		if (kring->ring->avail > 0) {
 			revents |= want_tx;
 			want_tx = 0;	/* also breaks the loop */
 		}
 	}
 
 	/*
 	 * If we to push packets out (priv->np_txpoll) or want_tx is
 	 * still set, we do need to run the txsync calls (on all rings,
 	 * to avoid that the tx rings stall).
 	 */
 	if (priv->np_txpoll || want_tx) {
 flush_tx:
 		for (i = priv->np_qfirst; i < lim_tx; i++) {
 			kring = &na->tx_rings[i];
 			/*
 			 * Skip the current ring if want_tx == 0
 			 * (we have already done a successful sync on
 			 * a previous ring) AND kring->cur == kring->hwcur
 			 * (there are no pending transmissions for this ring).
 			 */
 			if (!want_tx && kring->ring->cur == kring->nr_hwcur)
 				continue;
 			if (core_lock == NEED_CL) {
 				na->nm_lock(ifp, NETMAP_CORE_LOCK, 0);
 				core_lock = LOCKED_CL;
 			}
 			if (na->separate_locks)
 				na->nm_lock(ifp, NETMAP_TX_LOCK, i);
 			if (netmap_verbose & NM_VERB_TXSYNC)
 				D("send %d on %s %d",
 					kring->ring->cur,
 					ifp->if_xname, i);
 			if (na->nm_txsync(ifp, i, 0 /* no lock */))
 				revents |= POLLERR;
 
 			/* Check avail/call selrecord only if called with POLLOUT */
 			if (want_tx) {
 				if (kring->ring->avail > 0) {
 					/* stop at the first ring. We don't risk
 					 * starvation.
 					 */
 					revents |= want_tx;
 					want_tx = 0;
 				} else if (!check_all)
 					selrecord(td, &kring->si);
 			}
 			if (na->separate_locks)
 				na->nm_lock(ifp, NETMAP_TX_UNLOCK, i);
 		}
 	}
 
 	/*
 	 * now if want_rx is still set we need to lock and rxsync.
 	 * Do it on all rings because otherwise we starve.
 	 */
 	if (want_rx) {
 		for (i = priv->np_qfirst; i < lim_rx; i++) {
 			kring = &na->rx_rings[i];
 			if (core_lock == NEED_CL) {
 				na->nm_lock(ifp, NETMAP_CORE_LOCK, 0);
 				core_lock = LOCKED_CL;
 			}
 			if (na->separate_locks)
 				na->nm_lock(ifp, NETMAP_RX_LOCK, i);
 			if (netmap_fwd ||kring->ring->flags & NR_FORWARD) {
 				ND(10, "forwarding some buffers up %d to %d",
 				    kring->nr_hwcur, kring->ring->cur);
 				netmap_grab_packets(kring, &q, netmap_fwd);
 			}
 
 			if (na->nm_rxsync(ifp, i, 0 /* no lock */))
 				revents |= POLLERR;
 			if (netmap_no_timestamp == 0 ||
 					kring->ring->flags & NR_TIMESTAMP) {
 				microtime(&kring->ring->ts);
 			}
 
 			if (kring->ring->avail > 0)
 				revents |= want_rx;
 			else if (!check_all)
 				selrecord(td, &kring->si);
 			if (na->separate_locks)
 				na->nm_lock(ifp, NETMAP_RX_UNLOCK, i);
 		}
 	}
 	if (check_all && revents == 0) { /* signal on the global queue */
 		if (want_tx)
 			selrecord(td, &na->tx_si);
 		if (want_rx)
 			selrecord(td, &na->rx_si);
 	}
 
 	/* forward host to the netmap ring */
 	kring = &na->rx_rings[lim_rx];
 	if (kring->nr_hwavail > 0)
 		ND("host rx %d has %d packets", lim_rx, kring->nr_hwavail);
 	if ( (priv->np_qlast == NETMAP_HW_RING) // XXX check_all
 			&& (netmap_fwd || kring->ring->flags & NR_FORWARD)
 			 && kring->nr_hwavail > 0 && !host_forwarded) {
 		if (core_lock == NEED_CL) {
 			na->nm_lock(ifp, NETMAP_CORE_LOCK, 0);
 			core_lock = LOCKED_CL;
 		}
 		netmap_sw_to_nic(na);
 		host_forwarded = 1; /* prevent another pass */
 		want_rx = 0;
 		goto flush_tx;
 	}
 
 	if (core_lock == LOCKED_CL)
 		na->nm_lock(ifp, NETMAP_CORE_UNLOCK, 0);
 	if (q.head)
 		netmap_send_up(na->ifp, q.head);
 
 	return (revents);
 }
 
 /*------- driver support routines ------*/
 
 /*
  * default lock wrapper.
  */
 static void
 netmap_lock_wrapper(struct ifnet *dev, int what, u_int queueid)
 {
 	struct netmap_adapter *na = NA(dev);
 
 	switch (what) {
 #ifdef linux	/* some system do not need lock on register */
 	case NETMAP_REG_LOCK:
 	case NETMAP_REG_UNLOCK:
 		break;
 #endif /* linux */
 
 	case NETMAP_CORE_LOCK:
 		mtx_lock(&na->core_lock);
 		break;
 
 	case NETMAP_CORE_UNLOCK:
 		mtx_unlock(&na->core_lock);
 		break;
 
 	case NETMAP_TX_LOCK:
 		mtx_lock(&na->tx_rings[queueid].q_lock);
 		break;
 
 	case NETMAP_TX_UNLOCK:
 		mtx_unlock(&na->tx_rings[queueid].q_lock);
 		break;
 
 	case NETMAP_RX_LOCK:
 		mtx_lock(&na->rx_rings[queueid].q_lock);
 		break;
 
 	case NETMAP_RX_UNLOCK:
 		mtx_unlock(&na->rx_rings[queueid].q_lock);
 		break;
 	}
 }
 
 
 /*
  * Initialize a ``netmap_adapter`` object created by driver on attach.
  * We allocate a block of memory with room for a struct netmap_adapter
  * plus two sets of N+2 struct netmap_kring (where N is the number
  * of hardware rings):
  * krings	0..N-1	are for the hardware queues.
  * kring	N	is for the host stack queue
  * kring	N+1	is only used for the selinfo for all queues.
  * Return 0 on success, ENOMEM otherwise.
  *
  * By default the receive and transmit adapter ring counts are both initialized
  * to num_queues.  na->num_tx_rings can be set for cards with different tx/rx
  * setups.
  */
 int
 netmap_attach(struct netmap_adapter *arg, int num_queues)
 {
 	struct netmap_adapter *na = NULL;
 	struct ifnet *ifp = arg ? arg->ifp : NULL;
 
 	if (arg == NULL || ifp == NULL)
 		goto fail;
 	na = malloc(sizeof(*na), M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (na == NULL)
 		goto fail;
 	WNA(ifp) = na;
 	*na = *arg; /* copy everything, trust the driver to not pass junk */
 	NETMAP_SET_CAPABLE(ifp);
 	if (na->num_tx_rings == 0)
 		na->num_tx_rings = num_queues;
 	na->num_rx_rings = num_queues;
 	na->refcount = na->na_single = na->na_multi = 0;
 	/* Core lock initialized here, others after netmap_if_new. */
 	mtx_init(&na->core_lock, "netmap core lock", MTX_NETWORK_LOCK, MTX_DEF);
 	if (na->nm_lock == NULL) {
 		ND("using default locks for %s", ifp->if_xname);
 		na->nm_lock = netmap_lock_wrapper;
 	}
 #ifdef linux
 	if (ifp->netdev_ops) {
 		ND("netdev_ops %p", ifp->netdev_ops);
 		/* prepare a clone of the netdev ops */
 		na->nm_ndo = *ifp->netdev_ops;
 	}
 	na->nm_ndo.ndo_start_xmit = linux_netmap_start;
 #endif
 	D("success for %s", ifp->if_xname);
 	return 0;
 
 fail:
 	D("fail, arg %p ifp %p na %p", arg, ifp, na);
 	return (na ? EINVAL : ENOMEM);
 }
 
 
 /*
  * Free the allocated memory linked to the given ``netmap_adapter``
  * object.
  */
 void
 netmap_detach(struct ifnet *ifp)
 {
 	struct netmap_adapter *na = NA(ifp);
 
 	if (!na)
 		return;
 
 	mtx_destroy(&na->core_lock);
 
 	if (na->tx_rings) { /* XXX should not happen */
 		D("freeing leftover tx_rings");
 		free(na->tx_rings, M_DEVBUF);
 	}
 	bzero(na, sizeof(*na));
 	WNA(ifp) = NULL;
 	free(na, M_DEVBUF);
 }
 
 
 /*
  * Intercept packets from the network stack and pass them
  * to netmap as incoming packets on the 'software' ring.
  * We are not locked when called.
  */
 int
 netmap_start(struct ifnet *ifp, struct mbuf *m)
 {
 	struct netmap_adapter *na = NA(ifp);
 	struct netmap_kring *kring = &na->rx_rings[na->num_rx_rings];
 	u_int i, len = MBUF_LEN(m);
 	u_int error = EBUSY, lim = kring->nkr_num_slots - 1;
 	struct netmap_slot *slot;
 
 	if (netmap_verbose & NM_VERB_HOST)
 		D("%s packet %d len %d from the stack", ifp->if_xname,
 			kring->nr_hwcur + kring->nr_hwavail, len);
 	na->nm_lock(ifp, NETMAP_CORE_LOCK, 0);
 	if (kring->nr_hwavail >= lim) {
 		if (netmap_verbose)
 			D("stack ring %s full\n", ifp->if_xname);
 		goto done;	/* no space */
 	}
 	if (len > NETMAP_BUF_SIZE) {
 		D("%s from_host, drop packet size %d > %d", ifp->if_xname,
 			len, NETMAP_BUF_SIZE);
 		goto done;	/* too long for us */
 	}
 
 	/* compute the insert position */
 	i = kring->nr_hwcur + kring->nr_hwavail;
 	if (i > lim)
 		i -= lim + 1;
 	slot = &kring->ring->slot[i];
 	m_copydata(m, 0, len, NMB(slot));
 	slot->len = len;
 	slot->flags = kring->nkr_slot_flags;
 	kring->nr_hwavail++;
 	if (netmap_verbose  & NM_VERB_HOST)
 		D("wake up host ring %s %d", na->ifp->if_xname, na->num_rx_rings);
 	selwakeuppri(&kring->si, PI_NET);
 	error = 0;
 done:
 	na->nm_lock(ifp, NETMAP_CORE_UNLOCK, 0);
 
 	/* release the mbuf in either cases of success or failure. As an
 	 * alternative, put the mbuf in a free list and free the list
 	 * only when really necessary.
 	 */
 	m_freem(m);
 
 	return (error);
 }
 
 
 /*
  * netmap_reset() is called by the driver routines when reinitializing
  * a ring. The driver is in charge of locking to protect the kring.
  * If netmap mode is not set just return NULL.
  */
 struct netmap_slot *
 netmap_reset(struct netmap_adapter *na, enum txrx tx, int n,
 	u_int new_cur)
 {
 	struct netmap_kring *kring;
 	int new_hwofs, lim;
 
 	if (na == NULL)
 		return NULL;	/* no netmap support here */
 	if (!(na->ifp->if_capenable & IFCAP_NETMAP))
 		return NULL;	/* nothing to reinitialize */
 
 	if (tx == NR_TX) {
 		if (n >= na->num_tx_rings)
 			return NULL;
 		kring = na->tx_rings + n;
 		new_hwofs = kring->nr_hwcur - new_cur;
 	} else {
 		if (n >= na->num_rx_rings)
 			return NULL;
 		kring = na->rx_rings + n;
 		new_hwofs = kring->nr_hwcur + kring->nr_hwavail - new_cur;
 	}
 	lim = kring->nkr_num_slots - 1;
 	if (new_hwofs > lim)
 		new_hwofs -= lim + 1;
 
 	/* Alwayws set the new offset value and realign the ring. */
 	kring->nkr_hwofs = new_hwofs;
 	if (tx == NR_TX)
 		kring->nr_hwavail = kring->nkr_num_slots - 1;
 	ND(10, "new hwofs %d on %s %s[%d]",
 			kring->nkr_hwofs, na->ifp->if_xname,
 			tx == NR_TX ? "TX" : "RX", n);
 
 #if 0 // def linux
 	/* XXX check that the mappings are correct */
 	/* need ring_nr, adapter->pdev, direction */
 	buffer_info->dma = dma_map_single(&pdev->dev, addr, adapter->rx_buffer_len, DMA_FROM_DEVICE);
 	if (dma_mapping_error(&adapter->pdev->dev, buffer_info->dma)) {
 		D("error mapping rx netmap buffer %d", i);
 		// XXX fix error handling
 	}
 
 #endif /* linux */
 	/*
 	 * Wakeup on the individual and global lock
 	 * We do the wakeup here, but the ring is not yet reconfigured.
 	 * However, we are under lock so there are no races.
 	 */
 	selwakeuppri(&kring->si, PI_NET);
 	selwakeuppri(tx == NR_TX ? &na->tx_si : &na->rx_si, PI_NET);
 	return kring->ring->slot;
 }
 
 
 /*
  * Default functions to handle rx/tx interrupts
  * we have 4 cases:
  * 1 ring, single lock:
  *	lock(core); wake(i=0); unlock(core)
  * N rings, single lock:
  *	lock(core); wake(i); wake(N+1) unlock(core)
  * 1 ring, separate locks: (i=0)
  *	lock(i); wake(i); unlock(i)
  * N rings, separate locks:
  *	lock(i); wake(i); unlock(i); lock(core) wake(N+1) unlock(core)
  * work_done is non-null on the RX path.
  */
 int
 netmap_rx_irq(struct ifnet *ifp, int q, int *work_done)
 {
 	struct netmap_adapter *na;
 	struct netmap_kring *r;
 	NM_SELINFO_T *main_wq;
 
 	if (!(ifp->if_capenable & IFCAP_NETMAP))
 		return 0;
 	ND(5, "received %s queue %d", work_done ? "RX" : "TX" , q);
 	na = NA(ifp);
 	if (na->na_flags & NAF_SKIP_INTR) {
 		ND("use regular interrupt");
 		return 0;
 	}
 
 	if (work_done) { /* RX path */
 		if (q >= na->num_rx_rings)
 			return 0;	// regular queue
 		r = na->rx_rings + q;
 		r->nr_kflags |= NKR_PENDINTR;
 		main_wq = (na->num_rx_rings > 1) ? &na->rx_si : NULL;
 	} else { /* tx path */
 		if (q >= na->num_tx_rings)
 			return 0;	// regular queue
 		r = na->tx_rings + q;
 		main_wq = (na->num_tx_rings > 1) ? &na->tx_si : NULL;
 		work_done = &q; /* dummy */
 	}
 	if (na->separate_locks) {
 		mtx_lock(&r->q_lock);
 		selwakeuppri(&r->si, PI_NET);
 		mtx_unlock(&r->q_lock);
 		if (main_wq) {
 			mtx_lock(&na->core_lock);
 			selwakeuppri(main_wq, PI_NET);
 			mtx_unlock(&na->core_lock);
 		}
 	} else {
 		mtx_lock(&na->core_lock);
 		selwakeuppri(&r->si, PI_NET);
 		if (main_wq)
 			selwakeuppri(main_wq, PI_NET);
 		mtx_unlock(&na->core_lock);
 	}
 	*work_done = 1; /* do not fire napi again */
 	return 1;
 }
 
 
 #ifdef linux	/* linux-specific routines */
 
 /*
  * Remap linux arguments into the FreeBSD call.
  * - pwait is the poll table, passed as 'dev';
  *   If pwait == NULL someone else already woke up before. We can report
  *   events but they are filtered upstream.
  *   If pwait != NULL, then pwait->key contains the list of events.
  * - events is computed from pwait as above.
  * - file is passed as 'td';
  */
 static u_int
 linux_netmap_poll(struct file * file, struct poll_table_struct *pwait)
 {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
 	int events = pwait ? pwait->key : POLLIN | POLLOUT;
 #else /* in 3.4.0 field 'key' was renamed to '_key' */
 	int events = pwait ? pwait->_key : POLLIN | POLLOUT;
 #endif
 	return netmap_poll((void *)pwait, events, (void *)file);
 }
 
 static int
 linux_netmap_mmap(struct file *f, struct vm_area_struct *vma)
 {
 	int lut_skip, i, j;
 	int user_skip = 0;
 	struct lut_entry *l_entry;
 	int error = 0;
 	unsigned long off, tomap;
 	/*
 	 * vma->vm_start: start of mapping user address space
 	 * vma->vm_end: end of the mapping user address space
 	 * vma->vm_pfoff: offset of first page in the device
 	 */
 
 	// XXX security checks
 
 	error = netmap_get_memory(f->private_data);
 	ND("get_memory returned %d", error);
 	if (error)
 	    return -error;
 
 	off = vma->vm_pgoff << PAGE_SHIFT; /* offset in bytes */
 	tomap = vma->vm_end - vma->vm_start;
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {  /* loop through obj_pools */
 		const struct netmap_obj_pool *p = &nm_mem.pools[i];
 		/*
 		 * In each pool memory is allocated in clusters
 		 * of size _clustsize, each containing clustentries
 		 * entries. For each object k we already store the
 		 * vtophys mapping in lut[k] so we use that, scanning
 		 * the lut[] array in steps of clustentries,
 		 * and we map each cluster (not individual pages,
 		 * it would be overkill).
 		 */
 
 		/*
 		 * We interpret vm_pgoff as an offset into the whole
 		 * netmap memory, as if all clusters where contiguous.
 		 */
 		for (lut_skip = 0, j = 0; j < p->_numclusters; j++, lut_skip += p->clustentries) {
 			unsigned long paddr, mapsize;
 			if (p->_clustsize <= off) {
 				off -= p->_clustsize;
 				continue;
 			}
 			l_entry = &p->lut[lut_skip]; /* first obj in the cluster */
 			paddr = l_entry->paddr + off;
 			mapsize = p->_clustsize - off;
 			off = 0;
 			if (mapsize > tomap)
 				mapsize = tomap;
 			ND("remap_pfn_range(%lx, %lx, %lx)",
 				vma->vm_start + user_skip,
 				paddr >> PAGE_SHIFT, mapsize);
 			if (remap_pfn_range(vma, vma->vm_start + user_skip,
 					paddr >> PAGE_SHIFT, mapsize,
 					vma->vm_page_prot))
 				return -EAGAIN; // XXX check return value
 			user_skip += mapsize;
 			tomap -= mapsize;
 			if (tomap == 0)
 				goto done;
 		}
 	}
 done:
 
 	return 0;
 }
 
 static netdev_tx_t
 linux_netmap_start(struct sk_buff *skb, struct net_device *dev)
 {
 	netmap_start(dev, skb);
 	return (NETDEV_TX_OK);
 }
 
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)	// XXX was 38
 #define LIN_IOCTL_NAME	.ioctl
 int
 linux_netmap_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long data /* arg */)
 #else
 #define LIN_IOCTL_NAME	.unlocked_ioctl
 long
 linux_netmap_ioctl(struct file *file, u_int cmd, u_long data /* arg */)
 #endif
 {
 	int ret;
 	struct nmreq nmr;
 	bzero(&nmr, sizeof(nmr));
 
 	if (data && copy_from_user(&nmr, (void *)data, sizeof(nmr) ) != 0)
 		return -EFAULT;
 	ret = netmap_ioctl(NULL, cmd, (caddr_t)&nmr, 0, (void *)file);
 	if (data && copy_to_user((void*)data, &nmr, sizeof(nmr) ) != 0)
 		return -EFAULT;
 	return -ret;
 }
 
 
 static int
 netmap_release(struct inode *inode, struct file *file)
 {
 	(void)inode;	/* UNUSED */
 	if (file->private_data)
 		netmap_dtor(file->private_data);
 	return (0);
 }
 
 static int
 linux_netmap_open(struct inode *inode, struct file *file)
 {
 	struct netmap_priv_d *priv;
 	(void)inode;	/* UNUSED */
 
 	priv = malloc(sizeof(struct netmap_priv_d), M_DEVBUF,
 			      M_NOWAIT | M_ZERO);
 	if (priv == NULL)
 		return -ENOMEM;
 
 	file->private_data = priv;
 
 	return (0);
 }
 
 static struct file_operations netmap_fops = {
     .open = linux_netmap_open,
     .mmap = linux_netmap_mmap,
     LIN_IOCTL_NAME = linux_netmap_ioctl,
     .poll = linux_netmap_poll,
     .release = netmap_release,
 };
 
 static struct miscdevice netmap_cdevsw = {	/* same name as FreeBSD */
 	MISC_DYNAMIC_MINOR,
 	"netmap",
 	&netmap_fops,
 };
 
 static int netmap_init(void);
 static void netmap_fini(void);
 
 /* Errors have negative values on linux */
 static int linux_netmap_init(void)
 {
 	return -netmap_init();
 }
 
 module_init(linux_netmap_init);
 module_exit(netmap_fini);
 /* export certain symbols to other modules */
 EXPORT_SYMBOL(netmap_attach);		// driver attach routines
 EXPORT_SYMBOL(netmap_detach);		// driver detach routines
 EXPORT_SYMBOL(netmap_ring_reinit);	// ring init on error
 EXPORT_SYMBOL(netmap_buffer_lut);
 EXPORT_SYMBOL(netmap_total_buffers);	// index check
 EXPORT_SYMBOL(netmap_buffer_base);
 EXPORT_SYMBOL(netmap_reset);		// ring init routines
 EXPORT_SYMBOL(netmap_buf_size);
 EXPORT_SYMBOL(netmap_rx_irq);		// default irq handler
 EXPORT_SYMBOL(netmap_no_pendintr);	// XXX mitigation - should go away
 
 
 MODULE_AUTHOR("http://info.iet.unipi.it/~luigi/netmap/");
 MODULE_DESCRIPTION("The netmap packet I/O framework");
 MODULE_LICENSE("Dual BSD/GPL"); /* the code here is all BSD. */
 
 #else /* __FreeBSD__ */
 
 static struct cdevsw netmap_cdevsw = {
 	.d_version = D_VERSION,
 	.d_name = "netmap",
 	.d_open = netmap_open,
 	.d_mmap = netmap_mmap,
 	.d_mmap_single = netmap_mmap_single,
 	.d_ioctl = netmap_ioctl,
 	.d_poll = netmap_poll,
 	.d_close = netmap_close,
 };
 #endif /* __FreeBSD__ */
 
 #ifdef NM_BRIDGE
 /*
  *---- support for virtual bridge -----
  */
 
 /* ----- FreeBSD if_bridge hash function ------- */
 
 /*
  * The following hash function is adapted from "Hash Functions" by Bob Jenkins
  * ("Algorithm Alley", Dr. Dobbs Journal, September 1997).
  *
  * http://www.burtleburtle.net/bob/hash/spooky.html
  */
 #define mix(a, b, c)                                                    \
 do {                                                                    \
         a -= b; a -= c; a ^= (c >> 13);                                 \
         b -= c; b -= a; b ^= (a << 8);                                  \
         c -= a; c -= b; c ^= (b >> 13);                                 \
         a -= b; a -= c; a ^= (c >> 12);                                 \
         b -= c; b -= a; b ^= (a << 16);                                 \
         c -= a; c -= b; c ^= (b >> 5);                                  \
         a -= b; a -= c; a ^= (c >> 3);                                  \
         b -= c; b -= a; b ^= (a << 10);                                 \
         c -= a; c -= b; c ^= (b >> 15);                                 \
 } while (/*CONSTCOND*/0)
 
 static __inline uint32_t
 nm_bridge_rthash(const uint8_t *addr)
 {
         uint32_t a = 0x9e3779b9, b = 0x9e3779b9, c = 0; // hask key
 
         b += addr[5] << 8;
         b += addr[4];
         a += addr[3] << 24;
         a += addr[2] << 16;
         a += addr[1] << 8;
         a += addr[0];
 
         mix(a, b, c);
 #define BRIDGE_RTHASH_MASK	(NM_BDG_HASH-1)
         return (c & BRIDGE_RTHASH_MASK);
 }
 
 #undef mix
 
 
 static int
 bdg_netmap_reg(struct ifnet *ifp, int onoff)
 {
 	int i, err = 0;
 	struct nm_bridge *b = ifp->if_bridge;
 
 	BDG_LOCK(b);
 	if (onoff) {
 		/* the interface must be already in the list.
 		 * only need to mark the port as active
 		 */
 		ND("should attach %s to the bridge", ifp->if_xname);
 		for (i=0; i < NM_BDG_MAXPORTS; i++)
 			if (b->bdg_ports[i] == ifp)
 				break;
 		if (i == NM_BDG_MAXPORTS) {
 			D("no more ports available");
 			err = EINVAL;
 			goto done;
 		}
 		ND("setting %s in netmap mode", ifp->if_xname);
 		ifp->if_capenable |= IFCAP_NETMAP;
 		NA(ifp)->bdg_port = i;
 		b->act_ports |= (1<bdg_ports[i] = ifp;
 	} else {
 		/* should be in the list, too -- remove from the mask */
 		ND("removing %s from netmap mode", ifp->if_xname);
 		ifp->if_capenable &= ~IFCAP_NETMAP;
 		i = NA(ifp)->bdg_port;
 		b->act_ports &= ~(1<bdg_port;
 	uint64_t smac, dmac;
 	struct netmap_slot *slot;
 	struct nm_bridge *b = ifp->if_bridge;
 
 	ND("prepare to send %d packets, act_ports 0x%x", n, b->act_ports);
 	/* only consider valid destinations */
 	all_dst = (b->act_ports & ~mysrc);
 	/* first pass: hash and find destinations */
 	for (i = 0; likely(i < n); i++) {
 		uint8_t *buf = ft[i].buf;
 		dmac = le64toh(*(uint64_t *)(buf)) & 0xffffffffffff;
 		smac = le64toh(*(uint64_t *)(buf + 4));
 		smac >>= 16;
 		if (unlikely(netmap_verbose)) {
 		    uint8_t *s = buf+6, *d = buf;
 		    D("%d len %4d %02x:%02x:%02x:%02x:%02x:%02x -> %02x:%02x:%02x:%02x:%02x:%02x",
 			i,
 			ft[i].len,
 			s[0], s[1], s[2], s[3], s[4], s[5],
 			d[0], d[1], d[2], d[3], d[4], d[5]);
 		}
 		/*
 		 * The hash is somewhat expensive, there might be some
 		 * worthwhile optimizations here.
 		 */
 		if ((buf[6] & 1) == 0) { /* valid src */
 		    	uint8_t *s = buf+6;
 			sh = nm_bridge_rthash(buf+6); // XXX hash of source
 			/* update source port forwarding entry */
 			b->ht[sh].mac = smac;	/* XXX expire ? */
 			b->ht[sh].ports = mysrc;
 			if (netmap_verbose)
 			    D("src %02x:%02x:%02x:%02x:%02x:%02x on port %d",
 				s[0], s[1], s[2], s[3], s[4], s[5], NA(ifp)->bdg_port);
 		}
 		dst = 0;
 		if ( (buf[0] & 1) == 0) { /* unicast */
 		    	uint8_t *d = buf;
 			dh = nm_bridge_rthash(buf); // XXX hash of dst
 			if (b->ht[dh].mac == dmac) {	/* found dst */
 				dst = b->ht[dh].ports;
 				if (netmap_verbose)
 				    D("dst %02x:%02x:%02x:%02x:%02x:%02x to port %x",
 					d[0], d[1], d[2], d[3], d[4], d[5], (uint32_t)(dst >> 16));
 			}
 		}
 		if (dst == 0)
 			dst = all_dst;
 		dst &= all_dst; /* only consider valid ports */
 		if (unlikely(netmap_verbose))
 			D("pkt goes to ports 0x%x", (uint32_t)dst);
 		ft[i].dst = dst;
 	}
 
 	/* second pass, scan interfaces and forward */
 	all_dst = (b->act_ports & ~mysrc);
 	for (ifn = 0; all_dst; ifn++) {
 		struct ifnet *dst_ifp = b->bdg_ports[ifn];
 		struct netmap_adapter *na;
 		struct netmap_kring *kring;
 		struct netmap_ring *ring;
 		int j, lim, sent, locked;
 
 		if (!dst_ifp)
 			continue;
 		ND("scan port %d %s", ifn, dst_ifp->if_xname);
 		dst = 1 << ifn;
 		if ((dst & all_dst) == 0)	/* skip if not set */
 			continue;
 		all_dst &= ~dst;	/* clear current node */
 		na = NA(dst_ifp);
 
 		ring = NULL;
 		kring = NULL;
 		lim = sent = locked = 0;
 		/* inside, scan slots */
 		for (i = 0; likely(i < n); i++) {
 			if ((ft[i].dst & dst) == 0)
 				continue;	/* not here */
 			if (!locked) {
 				kring = &na->rx_rings[0];
 				ring = kring->ring;
 				lim = kring->nkr_num_slots - 1;
 				na->nm_lock(dst_ifp, NETMAP_RX_LOCK, 0);
 				locked = 1;
 			}
 			if (unlikely(kring->nr_hwavail >= lim)) {
 				if (netmap_verbose)
 					D("rx ring full on %s", ifp->if_xname);
 				break;
 			}
 			j = kring->nr_hwcur + kring->nr_hwavail;
 			if (j > lim)
 				j -= kring->nkr_num_slots;
 			slot = &ring->slot[j];
 			ND("send %d %d bytes at %s:%d", i, ft[i].len, dst_ifp->if_xname, j);
 			pkt_copy(ft[i].buf, NMB(slot), ft[i].len);
 			slot->len = ft[i].len;
 			kring->nr_hwavail++;
 			sent++;
 		}
 		if (locked) {
 			ND("sent %d on %s", sent, dst_ifp->if_xname);
 			if (sent)
 				selwakeuppri(&kring->si, PI_NET);
 			na->nm_lock(dst_ifp, NETMAP_RX_UNLOCK, 0);
 		}
 	}
 	return 0;
 }
 
 /*
  * main dispatch routine
  */
 static int
 bdg_netmap_txsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
 {
 	struct netmap_adapter *na = NA(ifp);
 	struct netmap_kring *kring = &na->tx_rings[ring_nr];
 	struct netmap_ring *ring = kring->ring;
 	int i, j, k, lim = kring->nkr_num_slots - 1;
 	struct nm_bdg_fwd *ft = (struct nm_bdg_fwd *)(ifp + 1);
 	int ft_i;	/* position in the forwarding table */
 
 	k = ring->cur;
 	if (k > lim)
 		return netmap_ring_reinit(kring);
 	if (do_lock)
 		na->nm_lock(ifp, NETMAP_TX_LOCK, ring_nr);
 
 	if (netmap_bridge <= 0) { /* testing only */
 		j = k; // used all
 		goto done;
 	}
 	if (netmap_bridge > NM_BDG_BATCH)
 		netmap_bridge = NM_BDG_BATCH;
 
 	ft_i = 0;	/* start from 0 */
 	for (j = kring->nr_hwcur; likely(j != k); j = unlikely(j == lim) ? 0 : j+1) {
 		struct netmap_slot *slot = &ring->slot[j];
 		int len = ft[ft_i].len = slot->len;
 		char *buf = ft[ft_i].buf = NMB(slot);
 
 		prefetch(buf);
 		if (unlikely(len < 14))
 			continue;
 		if (unlikely(++ft_i == netmap_bridge))
 			ft_i = nm_bdg_flush(ft, ft_i, ifp);
 	}
 	if (ft_i)
 		ft_i = nm_bdg_flush(ft, ft_i, ifp);
 	/* count how many packets we sent */
 	i = k - j;
 	if (i < 0)
 		i += kring->nkr_num_slots;
 	kring->nr_hwavail = kring->nkr_num_slots - 1 - i;
 	if (j != k)
 		D("early break at %d/ %d, avail %d", j, k, kring->nr_hwavail);
 
 done:
 	kring->nr_hwcur = j;
 	ring->avail = kring->nr_hwavail;
 	if (do_lock)
 		na->nm_lock(ifp, NETMAP_TX_UNLOCK, ring_nr);
 
 	if (netmap_verbose)
 		D("%s ring %d lock %d", ifp->if_xname, ring_nr, do_lock);
 	return 0;
 }
 
 static int
 bdg_netmap_rxsync(struct ifnet *ifp, u_int ring_nr, int do_lock)
 {
 	struct netmap_adapter *na = NA(ifp);
 	struct netmap_kring *kring = &na->rx_rings[ring_nr];
 	struct netmap_ring *ring = kring->ring;
 	u_int j, n, lim = kring->nkr_num_slots - 1;
 	u_int k = ring->cur, resvd = ring->reserved;
 
 	ND("%s ring %d lock %d avail %d",
 		ifp->if_xname, ring_nr, do_lock, kring->nr_hwavail);
 
 	if (k > lim)
 		return netmap_ring_reinit(kring);
 	if (do_lock)
 		na->nm_lock(ifp, NETMAP_RX_LOCK, ring_nr);
 
 	/* skip past packets that userspace has released */
 	j = kring->nr_hwcur;    /* netmap ring index */
 	if (resvd > 0) {
 		if (resvd + ring->avail >= lim + 1) {
 			D("XXX invalid reserve/avail %d %d", resvd, ring->avail);
 			ring->reserved = resvd = 0; // XXX panic...
 		}
 		k = (k >= resvd) ? k - resvd : k + lim + 1 - resvd;
 	}
 
 	if (j != k) { /* userspace has released some packets. */
 		n = k - j;
 		if (n < 0)
 			n += kring->nkr_num_slots;
 		ND("userspace releases %d packets", n);
                 for (n = 0; likely(j != k); n++) {
                         struct netmap_slot *slot = &ring->slot[j];
                         void *addr = NMB(slot);
 
                         if (addr == netmap_buffer_base) { /* bad buf */
                                 if (do_lock)
                                         na->nm_lock(ifp, NETMAP_RX_UNLOCK, ring_nr);
                                 return netmap_ring_reinit(kring);
                         }
 			/* decrease refcount for buffer */
 
 			slot->flags &= ~NS_BUF_CHANGED;
                         j = unlikely(j == lim) ? 0 : j + 1;
                 }
                 kring->nr_hwavail -= n;
                 kring->nr_hwcur = k;
         }
         /* tell userspace that there are new packets */
         ring->avail = kring->nr_hwavail - resvd;
 
 	if (do_lock)
 		na->nm_lock(ifp, NETMAP_RX_UNLOCK, ring_nr);
 	return 0;
 }
 
 static void
 bdg_netmap_attach(struct ifnet *ifp)
 {
 	struct netmap_adapter na;
 
 	ND("attaching virtual bridge");
 	bzero(&na, sizeof(na));
 
 	na.ifp = ifp;
 	na.separate_locks = 1;
 	na.num_tx_desc = NM_BRIDGE_RINGSIZE;
 	na.num_rx_desc = NM_BRIDGE_RINGSIZE;
 	na.nm_txsync = bdg_netmap_txsync;
 	na.nm_rxsync = bdg_netmap_rxsync;
 	na.nm_register = bdg_netmap_reg;
 	netmap_attach(&na, 1);
 }
 
 #endif /* NM_BRIDGE */
 
 static struct cdev *netmap_dev; /* /dev/netmap character device. */
 
 
 /*
  * Module loader.
  *
  * Create the /dev/netmap device and initialize all global
  * variables.
  *
  * Return 0 on success, errno on failure.
  */
 static int
 netmap_init(void)
 {
 	int error;
 
 	error = netmap_memory_init();
 	if (error != 0) {
 		printf("netmap: unable to initialize the memory allocator.\n");
 		return (error);
 	}
 	printf("netmap: loaded module\n");
 	netmap_dev = make_dev(&netmap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0660,
 			      "netmap");
 
 #ifdef NM_BRIDGE
 	{
 	int i;
 	for (i = 0; i < NM_BRIDGES; i++)
 		mtx_init(&nm_bridges[i].bdg_lock, "bdg lock", "bdg_lock", MTX_DEF);
 	}
 #endif
 	return (error);
 }
 
 
 /*
  * Module unloader.
  *
  * Free all the memory, and destroy the ``/dev/netmap`` device.
  */
 static void
 netmap_fini(void)
 {
 	destroy_dev(netmap_dev);
 	netmap_memory_fini();
 	printf("netmap: unloaded module.\n");
 }
 
 
 #ifdef __FreeBSD__
 /*
  * Kernel entry point.
  *
  * Initialize/finalize the module and return.
  *
  * Return 0 on success, errno on failure.
  */
 static int
 netmap_loader(__unused struct module *module, int event, __unused void *arg)
 {
 	int error = 0;
 
 	switch (event) {
 	case MOD_LOAD:
 		error = netmap_init();
 		break;
 
 	case MOD_UNLOAD:
 		netmap_fini();
 		break;
 
 	default:
 		error = EOPNOTSUPP;
 		break;
 	}
 
 	return (error);
 }
 
 
 DEV_MODULE(netmap, netmap_loader, NULL);
 #endif /* __FreeBSD__ */
Index: user/attilio/vmcontention/sys/dev/netmap/netmap_kern.h
===================================================================
--- user/attilio/vmcontention/sys/dev/netmap/netmap_kern.h	(revision 249698)
+++ user/attilio/vmcontention/sys/dev/netmap/netmap_kern.h	(revision 249699)
@@ -1,478 +1,470 @@
 /*
- * Copyright (C) 2011-2012 Matteo Landi, Luigi Rizzo. All rights reserved.
+ * Copyright (C) 2011-2013 Matteo Landi, Luigi Rizzo. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *   1. Redistributions of source code must retain the above copyright
  *      notice, this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright
  *      notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 /*
  * $FreeBSD$
  * $Id: netmap_kern.h 11829 2012-09-26 04:06:34Z luigi $
  *
  * The header contains the definitions of constants and function
  * prototypes used only in kernelspace.
  */
 
 #ifndef _NET_NETMAP_KERN_H_
 #define _NET_NETMAP_KERN_H_
 
-#define NETMAP_MEM2    // use the new memory allocator
-
 #if defined(__FreeBSD__)
 #define likely(x)	__builtin_expect(!!(x), 1)
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 
 #define	NM_LOCK_T	struct mtx
 #define	NM_SELINFO_T	struct selinfo
 #define	MBUF_LEN(m)	((m)->m_pkthdr.len)
 #define	NM_SEND_UP(ifp, m)	((ifp)->if_input)(ifp, m)
 #elif defined (linux)
-#define	NM_LOCK_T	spinlock_t
+#define	NM_LOCK_T	safe_spinlock_t // see bsd_glue.h
 #define	NM_SELINFO_T	wait_queue_head_t
 #define	MBUF_LEN(m)	((m)->len)
 #define	NM_SEND_UP(ifp, m)	netif_rx(m)
 
 #ifndef DEV_NETMAP
 #define DEV_NETMAP
 #endif
 
 /*
  * IFCAP_NETMAP goes into net_device's priv_flags (if_capenable).
  * This was 16 bits up to linux 2.6.36, so we need a 16 bit value on older
  * platforms and tolerate the clash with IFF_DYNAMIC and IFF_BRIDGE_PORT.
  * For the 32-bit value, 0x100000 has no clashes until at least 3.5.1
  */
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
 #define IFCAP_NETMAP	0x8000
 #else
 #define IFCAP_NETMAP	0x100000
 #endif
 
 #elif defined (__APPLE__)
 #warning apple support is incomplete.
 #define likely(x)	__builtin_expect(!!(x), 1)
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 #define	NM_LOCK_T	IOLock *
 #define	NM_SELINFO_T	struct selinfo
 #define	MBUF_LEN(m)	((m)->m_pkthdr.len)
 #define	NM_SEND_UP(ifp, m)	((ifp)->if_input)(ifp, m)
 
 #else
 #error unsupported platform
 #endif
 
 #define ND(format, ...)
 #define D(format, ...)						\
 	do {							\
 		struct timeval __xxts;				\
 		microtime(&__xxts);				\
 		printf("%03d.%06d %s [%d] " format "\n",	\
 		(int)__xxts.tv_sec % 1000, (int)__xxts.tv_usec,	\
 		__FUNCTION__, __LINE__, ##__VA_ARGS__);		\
 	} while (0)
 
 /* rate limited, lps indicates how many per second */
 #define RD(lps, format, ...)					\
 	do {							\
 		static int t0, __cnt;				\
 		if (t0 != time_second) {			\
 			t0 = time_second;			\
 			__cnt = 0;				\
 		}						\
 		if (__cnt++ < lps)				\
 			D(format, ##__VA_ARGS__);		\
 	} while (0)
 
 struct netmap_adapter;
 
 /*
  * private, kernel view of a ring. Keeps track of the status of
  * a ring across system calls.
  *
  *	nr_hwcur	index of the next buffer to refill.
  *			It corresponds to ring->cur - ring->reserved
  *
  *	nr_hwavail	the number of slots "owned" by userspace.
  *			nr_hwavail =:= ring->avail + ring->reserved
  *
  * The indexes in the NIC and netmap rings are offset by nkr_hwofs slots.
  * This is so that, on a reset, buffers owned by userspace are not
  * modified by the kernel. In particular:
  * RX rings: the next empty buffer (hwcur + hwavail + hwofs) coincides with
  * 	the next empty buffer as known by the hardware (next_to_check or so).
  * TX rings: hwcur + hwofs coincides with next_to_send
  *
  * For received packets, slot->flags is set to nkr_slot_flags
  * so we can provide a proper initial value (e.g. set NS_FORWARD
  * when operating in 'transparent' mode).
  */
 struct netmap_kring {
 	struct netmap_ring *ring;
 	u_int nr_hwcur;
 	int nr_hwavail;
 	u_int nr_kflags;	/* private driver flags */
 #define NKR_PENDINTR	0x1	// Pending interrupt.
 	u_int nkr_num_slots;
 
 	uint16_t	nkr_slot_flags;	/* initial value for flags */
 	int	nkr_hwofs;	/* offset between NIC and netmap ring */
 	struct netmap_adapter *na;
 	NM_SELINFO_T si;	/* poll/select wait queue */
 	NM_LOCK_T q_lock;	/* used if no device lock available */
 } __attribute__((__aligned__(64)));
 
 /*
  * This struct extends the 'struct adapter' (or
  * equivalent) device descriptor. It contains all fields needed to
  * support netmap operation.
  */
 struct netmap_adapter {
 	/*
 	 * On linux we do not have a good way to tell if an interface
 	 * is netmap-capable. So we use the following trick:
 	 * NA(ifp) points here, and the first entry (which hopefully
 	 * always exists and is at least 32 bits) contains a magic
 	 * value which we can use to detect that the interface is good.
 	 */
 	uint32_t magic;
 	uint32_t na_flags;	/* future place for IFCAP_NETMAP */
 #define NAF_SKIP_INTR	1	/* use the regular interrupt handler.
 				 * useful during initialization
 				 */
 	int refcount; /* number of user-space descriptors using this
 			 interface, which is equal to the number of
 			 struct netmap_if objs in the mapped region. */
 	/*
 	 * The selwakeup in the interrupt thread can use per-ring
 	 * and/or global wait queues. We track how many clients
 	 * of each type we have so we can optimize the drivers,
 	 * and especially avoid huge contention on the locks.
 	 */
 	int na_single;	/* threads attached to a single hw queue */
 	int na_multi;	/* threads attached to multiple hw queues */
 
 	int separate_locks; /* set if the interface suports different
 			       locks for rx, tx and core. */
 
 	u_int num_rx_rings; /* number of adapter receive rings */
 	u_int num_tx_rings; /* number of adapter transmit rings */
 
 	u_int num_tx_desc; /* number of descriptor in each queue */
 	u_int num_rx_desc;
 
 	/* tx_rings and rx_rings are private but allocated
 	 * as a contiguous chunk of memory. Each array has
 	 * N+1 entries, for the adapter queues and for the host queue.
 	 */
 	struct netmap_kring *tx_rings; /* array of TX rings. */
 	struct netmap_kring *rx_rings; /* array of RX rings. */
 
 	NM_SELINFO_T tx_si, rx_si;	/* global wait queues */
 
 	/* copy of if_qflush and if_transmit pointers, to intercept
 	 * packets from the network stack when netmap is active.
 	 */
 	int     (*if_transmit)(struct ifnet *, struct mbuf *);
 
 	/* references to the ifnet and device routines, used by
 	 * the generic netmap functions.
 	 */
 	struct ifnet *ifp; /* adapter is ifp->if_softc */
 
 	NM_LOCK_T core_lock;	/* used if no device lock available */
 
 	int (*nm_register)(struct ifnet *, int onoff);
 	void (*nm_lock)(struct ifnet *, int what, u_int ringid);
 	int (*nm_txsync)(struct ifnet *, u_int ring, int lock);
 	int (*nm_rxsync)(struct ifnet *, u_int ring, int lock);
 	/* return configuration information */
 	int (*nm_config)(struct ifnet *, u_int *txr, u_int *txd,
 					u_int *rxr, u_int *rxd);
 
 	int bdg_port;
 #ifdef linux
 	struct net_device_ops nm_ndo;
 	int if_refcount;	// XXX additions for bridge
 #endif /* linux */
 };
 
 /*
  * The combination of "enable" (ifp->if_capenable & IFCAP_NETMAP)
  * and refcount gives the status of the interface, namely:
  *
  *	enable	refcount	Status
  *
  *	FALSE	0		normal operation
  *	FALSE	!= 0		-- (impossible)
  *	TRUE	1		netmap mode
  *	TRUE	0		being deleted.
  */
 
 #define NETMAP_DELETING(_na)  (  ((_na)->refcount == 0) &&	\
 	( (_na)->ifp->if_capenable & IFCAP_NETMAP) )
 
 /*
  * parameters for (*nm_lock)(adapter, what, index)
  */
 enum {
 	NETMAP_NO_LOCK = 0,
 	NETMAP_CORE_LOCK, NETMAP_CORE_UNLOCK,
 	NETMAP_TX_LOCK, NETMAP_TX_UNLOCK,
 	NETMAP_RX_LOCK, NETMAP_RX_UNLOCK,
 #ifdef __FreeBSD__
 #define	NETMAP_REG_LOCK		NETMAP_CORE_LOCK
 #define	NETMAP_REG_UNLOCK	NETMAP_CORE_UNLOCK
 #else
 	NETMAP_REG_LOCK, NETMAP_REG_UNLOCK
 #endif
 };
 
 /*
  * The following are support routines used by individual drivers to
  * support netmap operation.
  *
  * netmap_attach() initializes a struct netmap_adapter, allocating the
  * 	struct netmap_ring's and the struct selinfo.
  *
  * netmap_detach() frees the memory allocated by netmap_attach().
  *
  * netmap_start() replaces the if_transmit routine of the interface,
  *	and is used to intercept packets coming from the stack.
  *
  * netmap_load_map/netmap_reload_map are helper routines to set/reset
  *	the dmamap for a packet buffer
  *
  * netmap_reset() is a helper routine to be called in the driver
  *	when reinitializing a ring.
  */
 int netmap_attach(struct netmap_adapter *, int);
 void netmap_detach(struct ifnet *);
 int netmap_start(struct ifnet *, struct mbuf *);
 enum txrx { NR_RX = 0, NR_TX = 1 };
 struct netmap_slot *netmap_reset(struct netmap_adapter *na,
 	enum txrx tx, int n, u_int new_cur);
 int netmap_ring_reinit(struct netmap_kring *);
 
 extern u_int netmap_buf_size;
 #define NETMAP_BUF_SIZE	netmap_buf_size
 extern int netmap_mitigate;
 extern int netmap_no_pendintr;
 extern u_int netmap_total_buffers;
 extern char *netmap_buffer_base;
 extern int netmap_verbose;	// XXX debugging
 enum {                                  /* verbose flags */
 	NM_VERB_ON = 1,                 /* generic verbose */
 	NM_VERB_HOST = 0x2,             /* verbose host stack */
 	NM_VERB_RXSYNC = 0x10,          /* verbose on rxsync/txsync */
 	NM_VERB_TXSYNC = 0x20,
 	NM_VERB_RXINTR = 0x100,         /* verbose on rx/tx intr (driver) */
 	NM_VERB_TXINTR = 0x200,
 	NM_VERB_NIC_RXSYNC = 0x1000,    /* verbose on rx/tx intr (driver) */
 	NM_VERB_NIC_TXSYNC = 0x2000,
 };
 
 /*
  * NA returns a pointer to the struct netmap adapter from the ifp,
  * WNA is used to write it.
  */
 #ifndef WNA
 #define	WNA(_ifp)	(_ifp)->if_pspare[0]
 #endif
 #define	NA(_ifp)	((struct netmap_adapter *)WNA(_ifp))
 
 /*
  * Macros to determine if an interface is netmap capable or netmap enabled.
  * See the magic field in struct netmap_adapter.
  */
 #ifdef __FreeBSD__
 /*
  * on FreeBSD just use if_capabilities and if_capenable.
  */
 #define NETMAP_CAPABLE(ifp)	(NA(ifp) &&		\
 	(ifp)->if_capabilities & IFCAP_NETMAP )
 
 #define	NETMAP_SET_CAPABLE(ifp)				\
 	(ifp)->if_capabilities |= IFCAP_NETMAP
 
 #else	/* linux */
 
 /*
  * on linux:
  * we check if NA(ifp) is set and its first element has a related
  * magic value. The capenable is within the struct netmap_adapter.
  */
 #define	NETMAP_MAGIC	0x52697a7a
 
 #define NETMAP_CAPABLE(ifp)	(NA(ifp) &&		\
 	((uint32_t)(uintptr_t)NA(ifp) ^ NA(ifp)->magic) == NETMAP_MAGIC )
 
 #define	NETMAP_SET_CAPABLE(ifp)				\
 	NA(ifp)->magic = ((uint32_t)(uintptr_t)NA(ifp)) ^ NETMAP_MAGIC
 
 #endif	/* linux */
 
 #ifdef __FreeBSD__
 /* Callback invoked by the dma machinery after a successfull dmamap_load */
 static void netmap_dmamap_cb(__unused void *arg,
     __unused bus_dma_segment_t * segs, __unused int nseg, __unused int error)
 {
 }
 
 /* bus_dmamap_load wrapper: call aforementioned function if map != NULL.
  * XXX can we do it without a callback ?
  */
 static inline void
 netmap_load_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
 {
 	if (map)
 		bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
 		    netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
 }
 
 /* update the map when a buffer changes. */
 static inline void
 netmap_reload_map(bus_dma_tag_t tag, bus_dmamap_t map, void *buf)
 {
 	if (map) {
 		bus_dmamap_unload(tag, map);
 		bus_dmamap_load(tag, map, buf, NETMAP_BUF_SIZE,
 		    netmap_dmamap_cb, NULL, BUS_DMA_NOWAIT);
 	}
 }
 #else /* linux */
 
 /*
  * XXX How do we redefine these functions:
  *
  * on linux we need
  *	dma_map_single(&pdev->dev, virt_addr, len, direction)
  *	dma_unmap_single(&adapter->pdev->dev, phys_addr, len, direction
  * The len can be implicit (on netmap it is NETMAP_BUF_SIZE)
  * unfortunately the direction is not, so we need to change
  * something to have a cross API
  */
 #define netmap_load_map(_t, _m, _b)
 #define netmap_reload_map(_t, _m, _b)
 #if 0
 	struct e1000_buffer *buffer_info =  &tx_ring->buffer_info[l];
 	/* set time_stamp *before* dma to help avoid a possible race */
 	buffer_info->time_stamp = jiffies;
 	buffer_info->mapped_as_page = false;
 	buffer_info->length = len;
 	//buffer_info->next_to_watch = l;
 	/* reload dma map */
 	dma_unmap_single(&adapter->pdev->dev, buffer_info->dma,
 			NETMAP_BUF_SIZE, DMA_TO_DEVICE);
 	buffer_info->dma = dma_map_single(&adapter->pdev->dev,
 			addr, NETMAP_BUF_SIZE, DMA_TO_DEVICE);
 
 	if (dma_mapping_error(&adapter->pdev->dev, buffer_info->dma)) {
 		D("dma mapping error");
 		/* goto dma_error; See e1000_put_txbuf() */
 		/* XXX reset */
 	}
 	tx_desc->buffer_addr = htole64(buffer_info->dma); //XXX
 
 #endif
 
 /*
  * The bus_dmamap_sync() can be one of wmb() or rmb() depending on direction.
  */
 #define bus_dmamap_sync(_a, _b, _c)
 
 #endif /* linux */
 
 /*
  * functions to map NIC to KRING indexes (n2k) and vice versa (k2n)
  */
 static inline int
 netmap_idx_n2k(struct netmap_kring *kr, int idx)
 {
 	int n = kr->nkr_num_slots;
 	idx += kr->nkr_hwofs;
 	if (idx < 0)
 		return idx + n;
 	else if (idx < n)
 		return idx;
 	else
 		return idx - n;
 }
 
 
 static inline int
 netmap_idx_k2n(struct netmap_kring *kr, int idx)
 {
 	int n = kr->nkr_num_slots;
 	idx -= kr->nkr_hwofs;
 	if (idx < 0)
 		return idx + n;
 	else if (idx < n)
 		return idx;
 	else
 		return idx - n;
 }
 
 
-#ifdef NETMAP_MEM2
 /* Entries of the look-up table. */
 struct lut_entry {
 	void *vaddr;		/* virtual address. */
 	vm_paddr_t paddr;	/* phisical address. */
 };
 
 struct netmap_obj_pool;
 extern struct lut_entry *netmap_buffer_lut;
 #define NMB_VA(i)	(netmap_buffer_lut[i].vaddr)
 #define NMB_PA(i)	(netmap_buffer_lut[i].paddr)
-#else /* NETMAP_MEM1 */
-#define NMB_VA(i)	(netmap_buffer_base + (i * NETMAP_BUF_SIZE) )
-#endif /* NETMAP_MEM2 */
 
 /*
  * NMB return the virtual address of a buffer (buffer 0 on bad index)
  * PNMB also fills the physical address
  */
 static inline void *
 NMB(struct netmap_slot *slot)
 {
 	uint32_t i = slot->buf_idx;
 	return (unlikely(i >= netmap_total_buffers)) ?  NMB_VA(0) : NMB_VA(i);
 }
 
 static inline void *
 PNMB(struct netmap_slot *slot, uint64_t *pp)
 {
 	uint32_t i = slot->buf_idx;
 	void *ret = (i >= netmap_total_buffers) ? NMB_VA(0) : NMB_VA(i);
-#ifdef NETMAP_MEM2
+
 	*pp = (i >= netmap_total_buffers) ? NMB_PA(0) : NMB_PA(i);
-#else
-	*pp = vtophys(ret);
-#endif
 	return ret;
 }
 
 /* default functions to handle rx/tx interrupts */
 int netmap_rx_irq(struct ifnet *, int, int *);
 #define netmap_tx_irq(_n, _q) netmap_rx_irq(_n, _q, NULL)
+
 
 extern int netmap_copy;
 #endif /* _NET_NETMAP_KERN_H_ */
Index: user/attilio/vmcontention/sys/dev/netmap/netmap_mem2.c
===================================================================
--- user/attilio/vmcontention/sys/dev/netmap/netmap_mem2.c	(revision 249698)
+++ user/attilio/vmcontention/sys/dev/netmap/netmap_mem2.c	(revision 249699)
@@ -1,974 +1,973 @@
 /*
- * Copyright (C) 2012 Matteo Landi, Luigi Rizzo, Giuseppe Lettieri. All rights reserved.
+ * Copyright (C) 2012-2013 Matteo Landi, Luigi Rizzo, Giuseppe Lettieri. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *   1. Redistributions of source code must retain the above copyright
  *      notice, this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright
  *      notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 /*
  * $FreeBSD$
  * $Id: netmap_mem2.c 11881 2012-10-18 23:24:15Z luigi $
  *
  * (New) memory allocator for netmap
  */
 
 /*
- * This allocator creates three memory regions:
+ * This allocator creates three memory pools:
  *	nm_if_pool	for the struct netmap_if
  *	nm_ring_pool	for the struct netmap_ring
  *	nm_buf_pool	for the packet buffers.
  *
- * All regions need to be multiple of a page size as we export them to
- * userspace through mmap. Only the latter needs to be dma-able,
+ * that contain netmap objects. Each pool is made of a number of clusters,
+ * multiple of a page size, each containing an integer number of objects.
+ * The clusters are contiguous in user space but not in the kernel.
+ * Only nm_buf_pool needs to be dma-able,
  * but for convenience use the same type of allocator for all.
  *
- * Once mapped, the three regions are exported to userspace
+ * Once mapped, the three pools are exported to userspace
  * as a contiguous block, starting from nm_if_pool. Each
  * cluster (and pool) is an integral number of pages.
  *   [ . . . ][ . . . . . .][ . . . . . . . . . .]
  *    nm_if     nm_ring            nm_buf
  *
  * The userspace areas contain offsets of the objects in userspace.
  * When (at init time) we write these offsets, we find out the index
  * of the object, and from there locate the offset from the beginning
  * of the region.
  *
  * The invididual allocators manage a pool of memory for objects of
  * the same size.
  * The pool is split into smaller clusters, whose size is a
  * multiple of the page size. The cluster size is chosen
  * to minimize the waste for a given max cluster size
- * (we do it by brute force, as we have relatively few object
+ * (we do it by brute force, as we have relatively few objects
  * per cluster).
  *
  * Objects are aligned to the cache line (64 bytes) rounding up object
  * sizes when needed. A bitmap contains the state of each object.
  * Allocation scans the bitmap; this is done only on attach, so we are not
  * too worried about performance
  *
  * For each allocator we can define (thorugh sysctl) the size and
  * number of each object. Memory is allocated at the first use of a
  * netmap file descriptor, and can be freed when all such descriptors
  * have been released (including unmapping the memory).
  * If memory is scarce, the system tries to get as much as possible
  * and the sysctl values reflect the actual allocation.
  * Together with desired values, the sysctl export also absolute
  * min and maximum values that cannot be overridden.
  *
  * struct netmap_if:
  *	variable size, max 16 bytes per ring pair plus some fixed amount.
  *	1024 bytes should be large enough in practice.
  *
  *	In the worst case we have one netmap_if per ring in the system.
  *
  * struct netmap_ring
- *	variable too, 8 byte per slot plus some fixed amount.
+ *	variable size, 8 byte per slot plus some fixed amount.
  *	Rings can be large (e.g. 4k slots, or >32Kbytes).
  *	We default to 36 KB (9 pages), and a few hundred rings.
  *
  * struct netmap_buffer
  *	The more the better, both because fast interfaces tend to have
  *	many slots, and because we may want to use buffers to store
  *	packets in userspace avoiding copies.
  *	Must contain a full frame (eg 1518, or more for vlans, jumbo
  *	frames etc.) plus be nicely aligned, plus some NICs restrict
  *	the size to multiple of 1K or so. Default to 2K
  */
 
-#ifndef CONSERVATIVE
 #define NETMAP_BUF_MAX_NUM	20*4096*2	/* large machine */
-#else /* CONSERVATIVE */
-#define NETMAP_BUF_MAX_NUM      20000   /* 40MB */
-#endif
 
 #ifdef linux
 #define NMA_LOCK_T		struct semaphore
 #define NMA_LOCK_INIT()		sema_init(&nm_mem.nm_mtx, 1)
 #define NMA_LOCK_DESTROY()	
 #define NMA_LOCK()		down(&nm_mem.nm_mtx)
 #define NMA_UNLOCK()		up(&nm_mem.nm_mtx)
 #else /* !linux */
 #define NMA_LOCK_T		struct mtx
 #define NMA_LOCK_INIT()		mtx_init(&nm_mem.nm_mtx, "netmap memory allocator lock", NULL, MTX_DEF)
 #define NMA_LOCK_DESTROY()	mtx_destroy(&nm_mem.nm_mtx)
 #define NMA_LOCK()		mtx_lock(&nm_mem.nm_mtx)
 #define NMA_UNLOCK()		mtx_unlock(&nm_mem.nm_mtx)
 #endif /* linux */
 
 enum {
 	NETMAP_IF_POOL   = 0,
 	NETMAP_RING_POOL,
 	NETMAP_BUF_POOL,
 	NETMAP_POOLS_NR
 };
 
 
 struct netmap_obj_params {
 	u_int size;
 	u_int num;
 };
 
 
 struct netmap_obj_params netmap_params[NETMAP_POOLS_NR] = {
 	[NETMAP_IF_POOL] = {
 		.size = 1024,
 		.num  = 100,
 	},
 	[NETMAP_RING_POOL] = {
 		.size = 9*PAGE_SIZE,
 		.num  = 200,
 	},
 	[NETMAP_BUF_POOL] = {
 		.size = 2048,
 		.num  = NETMAP_BUF_MAX_NUM,
 	},
 };
 
 
 struct netmap_obj_pool {
 	char name[16];		/* name of the allocator */
 	u_int objtotal;         /* actual total number of objects. */
 	u_int objfree;          /* number of free objects. */
 	u_int clustentries;	/* actual objects per cluster */
 
 	/* limits */
 	u_int objminsize;	/* minimum object size */
 	u_int objmaxsize;	/* maximum object size */
 	u_int nummin;		/* minimum number of objects */
 	u_int nummax;		/* maximum number of objects */
 
 	/* the total memory space is _numclusters*_clustsize */
 	u_int _numclusters;	/* how many clusters */
 	u_int _clustsize;        /* cluster size */
 	u_int _objsize;		/* actual object size */
 
 	u_int _memtotal;	/* _numclusters*_clustsize */
 	struct lut_entry *lut;  /* virt,phys addresses, objtotal entries */
 	uint32_t *bitmap;       /* one bit per buffer, 1 means free */
 	uint32_t bitmap_slots;	/* number of uint32 entries in bitmap */
 };
 
 
 struct netmap_mem_d {
 	NMA_LOCK_T nm_mtx;  /* protect the allocator */
 	u_int nm_totalsize; /* shorthand */
 
 	int finalized;		/* !=0 iff preallocation done */
 	int lasterr;		/* last error for curr config */
 	int refcount;		/* existing priv structures */
 	/* the three allocators */
 	struct netmap_obj_pool pools[NETMAP_POOLS_NR];
 };
 
-
+/*
+ * nm_mem is the memory allocator used for all physical interfaces
+ * running in netmap mode.
+ * Virtual (VALE) ports will have each its own allocator.
+ */
 static struct netmap_mem_d nm_mem = {	/* Our memory allocator. */
 	.pools = {
 		[NETMAP_IF_POOL] = {
 			.name 	= "netmap_if",
 			.objminsize = sizeof(struct netmap_if),
 			.objmaxsize = 4096,
 			.nummin     = 10,	/* don't be stingy */
 			.nummax	    = 10000,	/* XXX very large */
 		},
 		[NETMAP_RING_POOL] = {
 			.name 	= "netmap_ring",
 			.objminsize = sizeof(struct netmap_ring),
 			.objmaxsize = 32*PAGE_SIZE,
 			.nummin     = 2,
 			.nummax	    = 1024,
 		},
 		[NETMAP_BUF_POOL] = {
 			.name	= "netmap_buf",
 			.objminsize = 64,
 			.objmaxsize = 65536,
 			.nummin     = 4,
 			.nummax	    = 1000000, /* one million! */
 		},
 	},
 };
 
+// XXX logically belongs to nm_mem
 struct lut_entry *netmap_buffer_lut;	/* exported */
 
 /* memory allocator related sysctls */
 
 #define STRINGIFY(x) #x
 
 #define DECLARE_SYSCTLS(id, name) \
-	/* TUNABLE_INT("hw.netmap." STRINGIFY(name) "_size", &netmap_params[id].size); */ \
 	SYSCTL_INT(_dev_netmap, OID_AUTO, name##_size, \
 	    CTLFLAG_RW, &netmap_params[id].size, 0, "Requested size of netmap " STRINGIFY(name) "s"); \
         SYSCTL_INT(_dev_netmap, OID_AUTO, name##_curr_size, \
             CTLFLAG_RD, &nm_mem.pools[id]._objsize, 0, "Current size of netmap " STRINGIFY(name) "s"); \
-	/* TUNABLE_INT("hw.netmap." STRINGIFY(name) "_num", &netmap_params[id].num); */ \
         SYSCTL_INT(_dev_netmap, OID_AUTO, name##_num, \
             CTLFLAG_RW, &netmap_params[id].num, 0, "Requested number of netmap " STRINGIFY(name) "s"); \
         SYSCTL_INT(_dev_netmap, OID_AUTO, name##_curr_num, \
             CTLFLAG_RD, &nm_mem.pools[id].objtotal, 0, "Current number of netmap " STRINGIFY(name) "s")
 
 DECLARE_SYSCTLS(NETMAP_IF_POOL, if);
 DECLARE_SYSCTLS(NETMAP_RING_POOL, ring);
 DECLARE_SYSCTLS(NETMAP_BUF_POOL, buf);
 
 /*
- * Convert a userspace offset to a phisical address.
- * XXX re-do in a simpler way.
+ * Convert a userspace offset to a physical address.
+ * XXX only called in the FreeBSD's netmap_mmap()
+ * because in linux we map everything at once.
  *
- * The idea here is to hide userspace applications the fact that pre-allocated
- * memory is not contiguous, but fragmented across different clusters and
- * smaller memory allocators. Consequently, first of all we need to find which
- * allocator is owning provided offset, then we need to find out the physical
- * address associated to target page (this is done using the look-up table.
+ * First, find the allocator that contains the requested offset,
+ * then locate the cluster through a lookup table.
  */
 static inline vm_paddr_t
 netmap_ofstophys(vm_offset_t offset)
 {
 	int i;
 	vm_offset_t o = offset;
 	struct netmap_obj_pool *p = nm_mem.pools;
 
 	for (i = 0; i < NETMAP_POOLS_NR; offset -= p[i]._memtotal, i++) {
 		if (offset >= p[i]._memtotal)
 			continue;
-		// XXX now scan the clusters
+		// now lookup the cluster's address
 		return p[i].lut[offset / p[i]._objsize].paddr +
 			offset % p[i]._objsize;
 	}
 	/* this is only in case of errors */
 	D("invalid ofs 0x%x out of 0x%x 0x%x 0x%x", (u_int)o,
 		p[NETMAP_IF_POOL]._memtotal,
 		p[NETMAP_IF_POOL]._memtotal
 			+ p[NETMAP_RING_POOL]._memtotal,
 		p[NETMAP_IF_POOL]._memtotal
 			+ p[NETMAP_RING_POOL]._memtotal
 			+ p[NETMAP_BUF_POOL]._memtotal);
 	return 0;	// XXX bad address
 }
 
 /*
  * we store objects by kernel address, need to find the offset
  * within the pool to export the value to userspace.
  * Algorithm: scan until we find the cluster, then add the
  * actual offset in the cluster
  */
 static ssize_t
 netmap_obj_offset(struct netmap_obj_pool *p, const void *vaddr)
 {
 	int i, k = p->clustentries, n = p->objtotal;
 	ssize_t ofs = 0;
 
 	for (i = 0; i < n; i += k, ofs += p->_clustsize) {
 		const char *base = p->lut[i].vaddr;
 		ssize_t relofs = (const char *) vaddr - base;
 
 		if (relofs < 0 || relofs >= p->_clustsize)
 			continue;
 
 		ofs = ofs + relofs;
 		ND("%s: return offset %d (cluster %d) for pointer %p",
 		    p->name, ofs, i, vaddr);
 		return ofs;
 	}
 	D("address %p is not contained inside any cluster (%s)",
 	    vaddr, p->name);
 	return 0; /* An error occurred */
 }
 
 /* Helper functions which convert virtual addresses to offsets */
 #define netmap_if_offset(v)					\
 	netmap_obj_offset(&nm_mem.pools[NETMAP_IF_POOL], (v))
 
 #define netmap_ring_offset(v)					\
-    (nm_mem.pools[NETMAP_IF_POOL]._memtotal + 				\
+    (nm_mem.pools[NETMAP_IF_POOL]._memtotal + 			\
 	netmap_obj_offset(&nm_mem.pools[NETMAP_RING_POOL], (v)))
 
 #define netmap_buf_offset(v)					\
-    (nm_mem.pools[NETMAP_IF_POOL]._memtotal +				\
-	nm_mem.pools[NETMAP_RING_POOL]._memtotal +			\
+    (nm_mem.pools[NETMAP_IF_POOL]._memtotal +			\
+	nm_mem.pools[NETMAP_RING_POOL]._memtotal +		\
 	netmap_obj_offset(&nm_mem.pools[NETMAP_BUF_POOL], (v)))
 
 
 /*
  * report the index, and use start position as a hint,
  * otherwise buffer allocation becomes terribly expensive.
  */
 static void *
 netmap_obj_malloc(struct netmap_obj_pool *p, int len, uint32_t *start, uint32_t *index)
 {
 	uint32_t i = 0;			/* index in the bitmap */
 	uint32_t mask, j;		/* slot counter */
 	void *vaddr = NULL;
 
 	if (len > p->_objsize) {
 		D("%s request size %d too large", p->name, len);
 		// XXX cannot reduce the size
 		return NULL;
 	}
 
 	if (p->objfree == 0) {
 		D("%s allocator: run out of memory", p->name);
 		return NULL;
 	}
 	if (start)
 		i = *start;
 
 	/* termination is guaranteed by p->free, but better check bounds on i */
 	while (vaddr == NULL && i < p->bitmap_slots)  {
 		uint32_t cur = p->bitmap[i];
 		if (cur == 0) { /* bitmask is fully used */
 			i++;
 			continue;
 		}
 		/* locate a slot */
 		for (j = 0, mask = 1; (cur & mask) == 0; j++, mask <<= 1)
 			;
 
 		p->bitmap[i] &= ~mask; /* mark object as in use */
 		p->objfree--;
 
 		vaddr = p->lut[i * 32 + j].vaddr;
 		if (index)
 			*index = i * 32 + j;
 	}
 	ND("%s allocator: allocated object @ [%d][%d]: vaddr %p", i, j, vaddr);
 
 	if (start)
 		*start = i;
 	return vaddr;
 }
 
 
 /*
- * free by index, not by address
+ * free by index, not by address. This is slow, but is only used
+ * for a small number of objects (rings, nifp)
  */
 static void
 netmap_obj_free(struct netmap_obj_pool *p, uint32_t j)
 {
 	if (j >= p->objtotal) {
 		D("invalid index %u, max %u", j, p->objtotal);
 		return;
 	}
 	p->bitmap[j / 32] |= (1 << (j % 32));
 	p->objfree++;
 	return;
 }
 
 static void
 netmap_obj_free_va(struct netmap_obj_pool *p, void *vaddr)
 {
 	int i, j, n = p->_memtotal / p->_clustsize;
 
 	for (i = 0, j = 0; i < n; i++, j += p->clustentries) {
 		void *base = p->lut[i * p->clustentries].vaddr;
 		ssize_t relofs = (ssize_t) vaddr - (ssize_t) base;
 
 		/* Given address, is out of the scope of the current cluster.*/
 		if (vaddr < base || relofs > p->_clustsize)
 			continue;
 
 		j = j + relofs / p->_objsize;
 		KASSERT(j != 0, ("Cannot free object 0"));
 		netmap_obj_free(p, j);
 		return;
 	}
 	D("address %p is not contained inside any cluster (%s)",
 	    vaddr, p->name);
 }
 
 #define netmap_if_malloc(len)	netmap_obj_malloc(&nm_mem.pools[NETMAP_IF_POOL], len, NULL, NULL)
 #define netmap_if_free(v)	netmap_obj_free_va(&nm_mem.pools[NETMAP_IF_POOL], (v))
 #define netmap_ring_malloc(len)	netmap_obj_malloc(&nm_mem.pools[NETMAP_RING_POOL], len, NULL, NULL)
 #define netmap_ring_free(v)	netmap_obj_free_va(&nm_mem.pools[NETMAP_RING_POOL], (v))
 #define netmap_buf_malloc(_pos, _index)			\
 	netmap_obj_malloc(&nm_mem.pools[NETMAP_BUF_POOL], NETMAP_BUF_SIZE, _pos, _index)
 
 
 /* Return the index associated to the given packet buffer */
 #define netmap_buf_index(v)						\
     (netmap_obj_offset(&nm_mem.pools[NETMAP_BUF_POOL], (v)) / nm_mem.pools[NETMAP_BUF_POOL]._objsize)
 
 
 /* Return nonzero on error */
 static int
 netmap_new_bufs(struct netmap_if *nifp,
                 struct netmap_slot *slot, u_int n)
 {
 	struct netmap_obj_pool *p = &nm_mem.pools[NETMAP_BUF_POOL];
 	int i = 0;	/* slot counter */
 	uint32_t pos = 0;	/* slot in p->bitmap */
 	uint32_t index = 0;	/* buffer index */
 
 	(void)nifp;	/* UNUSED */
 	for (i = 0; i < n; i++) {
 		void *vaddr = netmap_buf_malloc(&pos, &index);
 		if (vaddr == NULL) {
 			D("unable to locate empty packet buffer");
 			goto cleanup;
 		}
 		slot[i].buf_idx = index;
 		slot[i].len = p->_objsize;
 		/* XXX setting flags=NS_BUF_CHANGED forces a pointer reload
 		 * in the NIC ring. This is a hack that hides missing
 		 * initializations in the drivers, and should go away.
 		 */
-		slot[i].flags = NS_BUF_CHANGED;
+		// slot[i].flags = NS_BUF_CHANGED;
 	}
 
 	ND("allocated %d buffers, %d available, first at %d", n, p->objfree, pos);
 	return (0);
 
 cleanup:
 	while (i > 0) {
 		i--;
 		netmap_obj_free(p, slot[i].buf_idx);
 	}
 	bzero(slot, n * sizeof(slot[0]));
 	return (ENOMEM);
 }
 
 
 static void
 netmap_free_buf(struct netmap_if *nifp, uint32_t i)
 {
 	struct netmap_obj_pool *p = &nm_mem.pools[NETMAP_BUF_POOL];
 
 	if (i < 2 || i >= p->objtotal) {
 		D("Cannot free buf#%d: should be in [2, %d[", i, p->objtotal);
 		return;
 	}
 	netmap_obj_free(p, i);
 }
 
 static void
 netmap_reset_obj_allocator(struct netmap_obj_pool *p)
 {
 	if (p == NULL)
 		return;
 	if (p->bitmap)
 		free(p->bitmap, M_NETMAP);
 	p->bitmap = NULL;
 	if (p->lut) {
 		int i;
 		for (i = 0; i < p->objtotal; i += p->clustentries) {
 			if (p->lut[i].vaddr)
 				contigfree(p->lut[i].vaddr, p->_clustsize, M_NETMAP);
 		}
 		bzero(p->lut, sizeof(struct lut_entry) * p->objtotal);
 #ifdef linux
 		vfree(p->lut);
 #else
 		free(p->lut, M_NETMAP);
 #endif
 	}
 	p->lut = NULL;
 }
 
 /*
  * Free all resources related to an allocator.
  */
 static void
 netmap_destroy_obj_allocator(struct netmap_obj_pool *p)
 {
 	if (p == NULL)
 		return;
 	netmap_reset_obj_allocator(p);
 }
 
 /*
  * We receive a request for objtotal objects, of size objsize each.
  * Internally we may round up both numbers, as we allocate objects
  * in small clusters multiple of the page size.
  * In the allocator we don't need to store the objsize,
  * but we do need to keep track of objtotal' and clustentries,
  * as they are needed when freeing memory.
  *
  * XXX note -- userspace needs the buffers to be contiguous,
  *	so we cannot afford gaps at the end of a cluster.
  */
 
 
 /* call with NMA_LOCK held */
 static int
 netmap_config_obj_allocator(struct netmap_obj_pool *p, u_int objtotal, u_int objsize)
 {
 	int i, n;
 	u_int clustsize;	/* the cluster size, multiple of page size */
 	u_int clustentries;	/* how many objects per entry */
 
 #define MAX_CLUSTSIZE	(1<<17)
 #define LINE_ROUND	64
 	if (objsize >= MAX_CLUSTSIZE) {
 		/* we could do it but there is no point */
 		D("unsupported allocation for %d bytes", objsize);
 		goto error;
 	}
 	/* make sure objsize is a multiple of LINE_ROUND */
 	i = (objsize & (LINE_ROUND - 1));
 	if (i) {
 		D("XXX aligning object by %d bytes", LINE_ROUND - i);
 		objsize += LINE_ROUND - i;
 	}
 	if (objsize < p->objminsize || objsize > p->objmaxsize) {
 		D("requested objsize %d out of range [%d, %d]", 
 			objsize, p->objminsize, p->objmaxsize);
 		goto error;
 	}
 	if (objtotal < p->nummin || objtotal > p->nummax) {
 		D("requested objtotal %d out of range [%d, %d]", 
 			objtotal, p->nummin, p->nummax);
 		goto error;
 	}
 	/*
 	 * Compute number of objects using a brute-force approach:
 	 * given a max cluster size,
 	 * we try to fill it with objects keeping track of the
 	 * wasted space to the next page boundary.
 	 */
 	for (clustentries = 0, i = 1;; i++) {
 		u_int delta, used = i * objsize;
 		if (used > MAX_CLUSTSIZE)
 			break;
 		delta = used % PAGE_SIZE;
 		if (delta == 0) { // exact solution
 			clustentries = i;
 			break;
 		}
 		if (delta > ( (clustentries*objsize) % PAGE_SIZE) )
 			clustentries = i;
 	}
 	// D("XXX --- ouch, delta %d (bad for buffers)", delta);
 	/* compute clustsize and round to the next page */
 	clustsize = clustentries * objsize;
 	i =  (clustsize & (PAGE_SIZE - 1));
 	if (i)
 		clustsize += PAGE_SIZE - i;
 	if (netmap_verbose)
 		D("objsize %d clustsize %d objects %d",
 			objsize, clustsize, clustentries);
 
 	/*
 	 * The number of clusters is n = ceil(objtotal/clustentries)
 	 * objtotal' = n * clustentries
 	 */
 	p->clustentries = clustentries;
 	p->_clustsize = clustsize;
 	n = (objtotal + clustentries - 1) / clustentries;
 	p->_numclusters = n;
 	p->objtotal = n * clustentries;
 	p->objfree = p->objtotal - 2; /* obj 0 and 1 are reserved */
 	p->_memtotal = p->_numclusters * p->_clustsize;
 	p->_objsize = objsize;
 
 	return 0;
 
 error:
 	p->_objsize = objsize;
 	p->objtotal = objtotal;
 
 	return EINVAL;
 }
 
 
 /* call with NMA_LOCK held */
 static int
 netmap_finalize_obj_allocator(struct netmap_obj_pool *p)
 {
 	int i, n;
 
 	n = sizeof(struct lut_entry) * p->objtotal;
 #ifdef linux
 	p->lut = vmalloc(n);
 #else
 	p->lut = malloc(n, M_NETMAP, M_NOWAIT | M_ZERO);
 #endif
 	if (p->lut == NULL) {
 		D("Unable to create lookup table (%d bytes) for '%s'", n, p->name);
 		goto clean;
 	}
 
 	/* Allocate the bitmap */
 	n = (p->objtotal + 31) / 32;
 	p->bitmap = malloc(sizeof(uint32_t) * n, M_NETMAP, M_NOWAIT | M_ZERO);
 	if (p->bitmap == NULL) {
 		D("Unable to create bitmap (%d entries) for allocator '%s'", n,
 		    p->name);
 		goto clean;
 	}
 	p->bitmap_slots = n;
 
 	/*
 	 * Allocate clusters, init pointers and bitmap
 	 */
 	for (i = 0; i < p->objtotal;) {
 		int lim = i + p->clustentries;
 		char *clust;
 
 		clust = contigmalloc(p->_clustsize, M_NETMAP, M_NOWAIT | M_ZERO,
 		    0, -1UL, PAGE_SIZE, 0);
 		if (clust == NULL) {
 			/*
 			 * If we get here, there is a severe memory shortage,
 			 * so halve the allocated memory to reclaim some.
 			 * XXX check boundaries
 			 */
 			D("Unable to create cluster at %d for '%s' allocator",
 			    i, p->name);
 			lim = i / 2;
 			for (i--; i >= lim; i--) {
 				p->bitmap[ (i>>5) ] &=  ~( 1 << (i & 31) );
 				if (i % p->clustentries == 0 && p->lut[i].vaddr)
 					contigfree(p->lut[i].vaddr,
 						p->_clustsize, M_NETMAP);
 			}
 			p->objtotal = i;
 			p->objfree = p->objtotal - 2;
 			p->_numclusters = i / p->clustentries;
 			p->_memtotal = p->_numclusters * p->_clustsize;
 			break;
 		}
 		for (; i < lim; i++, clust += p->_objsize) {
 			p->bitmap[ (i>>5) ] |=  ( 1 << (i & 31) );
 			p->lut[i].vaddr = clust;
 			p->lut[i].paddr = vtophys(clust);
 		}
 	}
 	p->bitmap[0] = ~3; /* objs 0 and 1 is always busy */
 	if (netmap_verbose)
 		D("Pre-allocated %d clusters (%d/%dKB) for '%s'",
 		    p->_numclusters, p->_clustsize >> 10,
 		    p->_memtotal >> 10, p->name);
 
 	return 0;
 
 clean:
 	netmap_reset_obj_allocator(p);
 	return ENOMEM;
 }
 
 /* call with lock held */
 static int
 netmap_memory_config_changed(void)
 {
 	int i;
 
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 		if (nm_mem.pools[i]._objsize != netmap_params[i].size ||
 		    nm_mem.pools[i].objtotal != netmap_params[i].num)
 		    return 1;
 	}
 	return 0;
 }
 
 
 /* call with lock held */
 static int
 netmap_memory_config(void)
 {
 	int i;
-
 
 	if (!netmap_memory_config_changed())
 		goto out;
 
 	D("reconfiguring");
 
 	if (nm_mem.finalized) {
 		/* reset previous allocation */
 		for (i = 0; i < NETMAP_POOLS_NR; i++) {
 			netmap_reset_obj_allocator(&nm_mem.pools[i]);
 		}    
 		nm_mem.finalized = 0;
         }
 
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 		nm_mem.lasterr = netmap_config_obj_allocator(&nm_mem.pools[i],
 				netmap_params[i].num, netmap_params[i].size);
 		if (nm_mem.lasterr)
 			goto out;
 	}
 
 	D("Have %d KB for interfaces, %d KB for rings and %d MB for buffers",
 	    nm_mem.pools[NETMAP_IF_POOL]._memtotal >> 10,
 	    nm_mem.pools[NETMAP_RING_POOL]._memtotal >> 10,
 	    nm_mem.pools[NETMAP_BUF_POOL]._memtotal >> 20);
 
 out:
 
 	return nm_mem.lasterr;
 }
 
 /* call with lock held */
 static int
 netmap_memory_finalize(void)
 {
 	int i;
 	u_int totalsize = 0;
 
 	nm_mem.refcount++;
 	if (nm_mem.refcount > 1) {
 		ND("busy (refcount %d)", nm_mem.refcount);
 		goto out;
 	}
 
 	/* update configuration if changed */
 	if (netmap_memory_config())
 		goto out;
 
 	if (nm_mem.finalized) {
 		/* may happen if config is not changed */
 		ND("nothing to do");
 		goto out;
 	}
 
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 		nm_mem.lasterr = netmap_finalize_obj_allocator(&nm_mem.pools[i]);
 		if (nm_mem.lasterr)
 			goto cleanup;
 		totalsize += nm_mem.pools[i]._memtotal;
 	}
 	nm_mem.nm_totalsize = totalsize;
 
 	/* backward compatibility */
 	netmap_buf_size = nm_mem.pools[NETMAP_BUF_POOL]._objsize;
 	netmap_total_buffers = nm_mem.pools[NETMAP_BUF_POOL].objtotal;
 
 	netmap_buffer_lut = nm_mem.pools[NETMAP_BUF_POOL].lut;
 	netmap_buffer_base = nm_mem.pools[NETMAP_BUF_POOL].lut[0].vaddr;
 
 	nm_mem.finalized = 1;
 	nm_mem.lasterr = 0;
 
 	/* make sysctl values match actual values in the pools */
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 		netmap_params[i].size = nm_mem.pools[i]._objsize;
 		netmap_params[i].num  = nm_mem.pools[i].objtotal;
 	}
 
 out:
 	if (nm_mem.lasterr)
 		nm_mem.refcount--;
 
 	return nm_mem.lasterr;
 
 cleanup:
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 		netmap_reset_obj_allocator(&nm_mem.pools[i]);
 	}
 	nm_mem.refcount--;
 
 	return nm_mem.lasterr;
 }
 
 static int
 netmap_memory_init(void)
 {
 	NMA_LOCK_INIT();
 	return (0);
 }
 
 static void
 netmap_memory_fini(void)
 {
 	int i;
 
 	for (i = 0; i < NETMAP_POOLS_NR; i++) {
 	    netmap_destroy_obj_allocator(&nm_mem.pools[i]);
 	}
 	NMA_LOCK_DESTROY();
 }
 
 static void
 netmap_free_rings(struct netmap_adapter *na)
 {
 	int i;
 	if (!na->tx_rings)
 		return;
 	for (i = 0; i < na->num_tx_rings + 1; i++) {
 		netmap_ring_free(na->tx_rings[i].ring);
 		na->tx_rings[i].ring = NULL;
 	}
 	for (i = 0; i < na->num_rx_rings + 1; i++) {
 		netmap_ring_free(na->rx_rings[i].ring);
 		na->rx_rings[i].ring = NULL;
 	}
 	free(na->tx_rings, M_DEVBUF);
 	na->tx_rings = na->rx_rings = NULL;
 }
 
 
 
 /* call with NMA_LOCK held */
 /*
  * Allocate the per-fd structure netmap_if.
  * If this is the first instance, also allocate the krings, rings etc.
  */
 static void *
 netmap_if_new(const char *ifname, struct netmap_adapter *na)
 {
 	struct netmap_if *nifp;
 	struct netmap_ring *ring;
 	ssize_t base; /* handy for relative offsets between rings and nifp */
 	u_int i, len, ndesc, ntx, nrx;
 	struct netmap_kring *kring;
 
 	if (netmap_update_config(na)) {
 		/* configuration mismatch, report and fail */
 		return NULL;
 	}
 	ntx = na->num_tx_rings + 1; /* shorthand, include stack ring */
 	nrx = na->num_rx_rings + 1; /* shorthand, include stack ring */
 	/*
 	 * the descriptor is followed inline by an array of offsets
 	 * to the tx and rx rings in the shared memory region.
 	 */
 	len = sizeof(struct netmap_if) + (nrx + ntx) * sizeof(ssize_t);
 	nifp = netmap_if_malloc(len);
 	if (nifp == NULL) {
 		return NULL;
 	}
 
 	/* initialize base fields -- override const */
 	*(int *)(uintptr_t)&nifp->ni_tx_rings = na->num_tx_rings;
 	*(int *)(uintptr_t)&nifp->ni_rx_rings = na->num_rx_rings;
 	strncpy(nifp->ni_name, ifname, IFNAMSIZ);
 
 	(na->refcount)++;	/* XXX atomic ? we are under lock */
 	if (na->refcount > 1) { /* already setup, we are done */
 		goto final;
 	}
 
 	len = (ntx + nrx) * sizeof(struct netmap_kring);
 	na->tx_rings = malloc(len, M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (na->tx_rings == NULL) {
 		D("Cannot allocate krings for %s", ifname);
 		goto cleanup;
 	}
 	na->rx_rings = na->tx_rings + ntx;
 
 	/*
 	 * First instance, allocate netmap rings and buffers for this card
 	 * The rings are contiguous, but have variable size.
 	 */
 	for (i = 0; i < ntx; i++) { /* Transmit rings */
 		kring = &na->tx_rings[i];
 		ndesc = na->num_tx_desc;
 		bzero(kring, sizeof(*kring));
 		len = sizeof(struct netmap_ring) +
 			  ndesc * sizeof(struct netmap_slot);
 		ring = netmap_ring_malloc(len);
 		if (ring == NULL) {
 			D("Cannot allocate tx_ring[%d] for %s", i, ifname);
 			goto cleanup;
 		}
 		ND("txring[%d] at %p ofs %d", i, ring);
 		kring->na = na;
 		kring->ring = ring;
 		*(int *)(uintptr_t)&ring->num_slots = kring->nkr_num_slots = ndesc;
 		*(ssize_t *)(uintptr_t)&ring->buf_ofs =
 		    (nm_mem.pools[NETMAP_IF_POOL]._memtotal +
 			nm_mem.pools[NETMAP_RING_POOL]._memtotal) -
 			netmap_ring_offset(ring);
 
 		/*
 		 * IMPORTANT:
 		 * Always keep one slot empty, so we can detect new
 		 * transmissions comparing cur and nr_hwcur (they are
 		 * the same only if there are no new transmissions).
 		 */
 		ring->avail = kring->nr_hwavail = ndesc - 1;
 		ring->cur = kring->nr_hwcur = 0;
 		*(int *)(uintptr_t)&ring->nr_buf_size = NETMAP_BUF_SIZE;
 		ND("initializing slots for txring[%d]", i);
 		if (netmap_new_bufs(nifp, ring->slot, ndesc)) {
 			D("Cannot allocate buffers for tx_ring[%d] for %s", i, ifname);
 			goto cleanup;
 		}
 	}
 
 	for (i = 0; i < nrx; i++) { /* Receive rings */
 		kring = &na->rx_rings[i];
 		ndesc = na->num_rx_desc;
 		bzero(kring, sizeof(*kring));
 		len = sizeof(struct netmap_ring) +
 			  ndesc * sizeof(struct netmap_slot);
 		ring = netmap_ring_malloc(len);
 		if (ring == NULL) {
 			D("Cannot allocate rx_ring[%d] for %s", i, ifname);
 			goto cleanup;
 		}
 		ND("rxring[%d] at %p ofs %d", i, ring);
 
 		kring->na = na;
 		kring->ring = ring;
 		*(int *)(uintptr_t)&ring->num_slots = kring->nkr_num_slots = ndesc;
 		*(ssize_t *)(uintptr_t)&ring->buf_ofs =
 		    (nm_mem.pools[NETMAP_IF_POOL]._memtotal +
 		        nm_mem.pools[NETMAP_RING_POOL]._memtotal) -
 			netmap_ring_offset(ring);
 
 		ring->cur = kring->nr_hwcur = 0;
 		ring->avail = kring->nr_hwavail = 0; /* empty */
 		*(int *)(uintptr_t)&ring->nr_buf_size = NETMAP_BUF_SIZE;
 		ND("initializing slots for rxring[%d]", i);
 		if (netmap_new_bufs(nifp, ring->slot, ndesc)) {
 			D("Cannot allocate buffers for rx_ring[%d] for %s", i, ifname);
 			goto cleanup;
 		}
 	}
 #ifdef linux
 	// XXX initialize the selrecord structs.
 	for (i = 0; i < ntx; i++)
 		init_waitqueue_head(&na->tx_rings[i].si);
 	for (i = 0; i < nrx; i++)
 		init_waitqueue_head(&na->rx_rings[i].si);
 	init_waitqueue_head(&na->tx_si);
 	init_waitqueue_head(&na->rx_si);
 #endif
 final:
 	/*
 	 * fill the slots for the rx and tx rings. They contain the offset
 	 * between the ring and nifp, so the information is usable in
 	 * userspace to reach the ring from the nifp.
 	 */
 	base = netmap_if_offset(nifp);
 	for (i = 0; i < ntx; i++) {
 		*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i] =
 			netmap_ring_offset(na->tx_rings[i].ring) - base;
 	}
 	for (i = 0; i < nrx; i++) {
 		*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i+ntx] =
 			netmap_ring_offset(na->rx_rings[i].ring) - base;
 	}
 	return (nifp);
 cleanup:
 	netmap_free_rings(na);
 	netmap_if_free(nifp);
 	(na->refcount)--;
 	return NULL;
 }
 
 /* call with NMA_LOCK held */
 static void
 netmap_memory_deref(void)
 {
 	nm_mem.refcount--;
 	if (netmap_verbose)
 		D("refcount = %d", nm_mem.refcount);
 }
Index: user/attilio/vmcontention/sys/kern/kern_fork.c
===================================================================
--- user/attilio/vmcontention/sys/kern/kern_fork.c	(revision 249698)
+++ user/attilio/vmcontention/sys/kern/kern_fork.c	(revision 249699)
@@ -1,1054 +1,1054 @@
 /*-
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
  * (c) UNIX System Laboratories, Inc.
  * All or some portions of this file are derived from material licensed
  * to the University of California by American Telephone and Telegraph
  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  * the permission of UNIX System Laboratories, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  *	@(#)kern_fork.c	8.6 (Berkeley) 4/8/94
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include "opt_kdtrace.h"
 #include "opt_ktrace.h"
 #include "opt_kstack_pages.h"
 #include "opt_procdesc.h"
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 	
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #ifdef KDTRACE_HOOKS
 #include 
 dtrace_fork_func_t	dtrace_fasttrap_fork;
 #endif
 
 SDT_PROVIDER_DECLARE(proc);
 SDT_PROBE_DEFINE(proc, kernel, , create, create);
 SDT_PROBE_ARGTYPE(proc, kernel, , create, 0, "struct proc *");
 SDT_PROBE_ARGTYPE(proc, kernel, , create, 1, "struct proc *");
 SDT_PROBE_ARGTYPE(proc, kernel, , create, 2, "int");
 
 #ifndef _SYS_SYSPROTO_H_
 struct fork_args {
 	int     dummy;
 };
 #endif
 
 /* ARGSUSED */
 int
 sys_fork(struct thread *td, struct fork_args *uap)
 {
 	int error;
 	struct proc *p2;
 
 	error = fork1(td, RFFDG | RFPROC, 0, &p2, NULL, 0);
 	if (error == 0) {
 		td->td_retval[0] = p2->p_pid;
 		td->td_retval[1] = 0;
 	}
 	return (error);
 }
 
 /* ARGUSED */
 int
 sys_pdfork(td, uap)
 	struct thread *td;
 	struct pdfork_args *uap;
 {
 #ifdef PROCDESC
 	int error, fd;
 	struct proc *p2;
 
 	/*
 	 * It is necessary to return fd by reference because 0 is a valid file
 	 * descriptor number, and the child needs to be able to distinguish
 	 * itself from the parent using the return value.
 	 */
 	error = fork1(td, RFFDG | RFPROC | RFPROCDESC, 0, &p2,
 	    &fd, uap->flags);
 	if (error == 0) {
 		td->td_retval[0] = p2->p_pid;
 		td->td_retval[1] = 0;
 		error = copyout(&fd, uap->fdp, sizeof(fd));
 	}
 	return (error);
 #else
 	return (ENOSYS);
 #endif
 }
 
 /* ARGSUSED */
 int
 sys_vfork(struct thread *td, struct vfork_args *uap)
 {
 	int error, flags;
 	struct proc *p2;
 
 	flags = RFFDG | RFPROC | RFPPWAIT | RFMEM;
 	error = fork1(td, flags, 0, &p2, NULL, 0);
 	if (error == 0) {
 		td->td_retval[0] = p2->p_pid;
 		td->td_retval[1] = 0;
 	}
 	return (error);
 }
 
 int
 sys_rfork(struct thread *td, struct rfork_args *uap)
 {
 	struct proc *p2;
 	int error;
 
 	/* Don't allow kernel-only flags. */
 	if ((uap->flags & RFKERNELONLY) != 0)
 		return (EINVAL);
 
 	AUDIT_ARG_FFLAGS(uap->flags);
 	error = fork1(td, uap->flags, 0, &p2, NULL, 0);
 	if (error == 0) {
 		td->td_retval[0] = p2 ? p2->p_pid : 0;
 		td->td_retval[1] = 0;
 	}
 	return (error);
 }
 
 int	nprocs = 1;		/* process 0 */
 int	lastpid = 0;
 SYSCTL_INT(_kern, OID_AUTO, lastpid, CTLFLAG_RD, &lastpid, 0, 
     "Last used PID");
 
 /*
  * Random component to lastpid generation.  We mix in a random factor to make
  * it a little harder to predict.  We sanity check the modulus value to avoid
  * doing it in critical paths.  Don't let it be too small or we pointlessly
  * waste randomness entropy, and don't let it be impossibly large.  Using a
  * modulus that is too big causes a LOT more process table scans and slows
  * down fork processing as the pidchecked caching is defeated.
  */
 static int randompid = 0;
 
 static int
 sysctl_kern_randompid(SYSCTL_HANDLER_ARGS)
 {
 	int error, pid;
 
 	error = sysctl_wire_old_buffer(req, sizeof(int));
 	if (error != 0)
 		return(error);
 	sx_xlock(&allproc_lock);
 	pid = randompid;
 	error = sysctl_handle_int(oidp, &pid, 0, req);
 	if (error == 0 && req->newptr != NULL) {
 		if (pid < 0 || pid > pid_max - 100)	/* out of range */
 			pid = pid_max - 100;
 		else if (pid < 2)			/* NOP */
 			pid = 0;
 		else if (pid < 100)			/* Make it reasonable */
 			pid = 100;
 		randompid = pid;
 	}
 	sx_xunlock(&allproc_lock);
 	return (error);
 }
 
 SYSCTL_PROC(_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW,
     0, 0, sysctl_kern_randompid, "I", "Random PID modulus");
 
 static int
 fork_findpid(int flags)
 {
 	struct proc *p;
 	int trypid;
 	static int pidchecked = 0;
 
 	/*
 	 * Requires allproc_lock in order to iterate over the list
 	 * of processes, and proctree_lock to access p_pgrp.
 	 */
 	sx_assert(&allproc_lock, SX_LOCKED);
 	sx_assert(&proctree_lock, SX_LOCKED);
 
 	/*
 	 * Find an unused process ID.  We remember a range of unused IDs
 	 * ready to use (from lastpid+1 through pidchecked-1).
 	 *
 	 * If RFHIGHPID is set (used during system boot), do not allocate
 	 * low-numbered pids.
 	 */
 	trypid = lastpid + 1;
 	if (flags & RFHIGHPID) {
 		if (trypid < 10)
 			trypid = 10;
 	} else {
 		if (randompid)
 			trypid += arc4random() % randompid;
 	}
 retry:
 	/*
 	 * If the process ID prototype has wrapped around,
 	 * restart somewhat above 0, as the low-numbered procs
 	 * tend to include daemons that don't exit.
 	 */
 	if (trypid >= pid_max) {
 		trypid = trypid % pid_max;
 		if (trypid < 100)
 			trypid += 100;
 		pidchecked = 0;
 	}
 	if (trypid >= pidchecked) {
 		int doingzomb = 0;
 
 		pidchecked = PID_MAX;
 		/*
 		 * Scan the active and zombie procs to check whether this pid
 		 * is in use.  Remember the lowest pid that's greater
 		 * than trypid, so we can avoid checking for a while.
 		 */
 		p = LIST_FIRST(&allproc);
 again:
 		for (; p != NULL; p = LIST_NEXT(p, p_list)) {
 			while (p->p_pid == trypid ||
 			    (p->p_pgrp != NULL &&
 			    (p->p_pgrp->pg_id == trypid ||
 			    (p->p_session != NULL &&
 			    p->p_session->s_sid == trypid)))) {
 				trypid++;
 				if (trypid >= pidchecked)
 					goto retry;
 			}
 			if (p->p_pid > trypid && pidchecked > p->p_pid)
 				pidchecked = p->p_pid;
 			if (p->p_pgrp != NULL) {
 				if (p->p_pgrp->pg_id > trypid &&
 				    pidchecked > p->p_pgrp->pg_id)
 					pidchecked = p->p_pgrp->pg_id;
 				if (p->p_session != NULL &&
 				    p->p_session->s_sid > trypid &&
 				    pidchecked > p->p_session->s_sid)
 					pidchecked = p->p_session->s_sid;
 			}
 		}
 		if (!doingzomb) {
 			doingzomb = 1;
 			p = LIST_FIRST(&zombproc);
 			goto again;
 		}
 	}
 
 	/*
 	 * RFHIGHPID does not mess with the lastpid counter during boot.
 	 */
 	if (flags & RFHIGHPID)
 		pidchecked = 0;
 	else
 		lastpid = trypid;
 
 	return (trypid);
 }
 
 static int
 fork_norfproc(struct thread *td, int flags)
 {
 	int error;
 	struct proc *p1;
 
 	KASSERT((flags & RFPROC) == 0,
 	    ("fork_norfproc called with RFPROC set"));
 	p1 = td->td_proc;
 
 	if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) &&
 	    (flags & (RFCFDG | RFFDG))) {
 		PROC_LOCK(p1);
 		if (thread_single(SINGLE_BOUNDARY)) {
 			PROC_UNLOCK(p1);
 			return (ERESTART);
 		}
 		PROC_UNLOCK(p1);
 	}
 
 	error = vm_forkproc(td, NULL, NULL, NULL, flags);
 	if (error)
 		goto fail;
 
 	/*
 	 * Close all file descriptors.
 	 */
 	if (flags & RFCFDG) {
 		struct filedesc *fdtmp;
 		fdtmp = fdinit(td->td_proc->p_fd);
 		fdescfree(td);
 		p1->p_fd = fdtmp;
 	}
 
 	/*
 	 * Unshare file descriptors (from parent).
 	 */
 	if (flags & RFFDG) 
 		fdunshare(p1, td);
 
 fail:
 	if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) &&
 	    (flags & (RFCFDG | RFFDG))) {
 		PROC_LOCK(p1);
 		thread_single_end();
 		PROC_UNLOCK(p1);
 	}
 	return (error);
 }
 
 static void
 do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2,
     struct vmspace *vm2, int pdflags)
 {
 	struct proc *p1, *pptr;
 	int p2_held, trypid;
 	struct filedesc *fd;
 	struct filedesc_to_leader *fdtol;
 	struct sigacts *newsigacts;
 
 	sx_assert(&proctree_lock, SX_SLOCKED);
 	sx_assert(&allproc_lock, SX_XLOCKED);
 
 	p2_held = 0;
 	p1 = td->td_proc;
 
 	/*
 	 * Increment the nprocs resource before blocking can occur.  There
 	 * are hard-limits as to the number of processes that can run.
 	 */
 	nprocs++;
 
 	trypid = fork_findpid(flags);
 
 	sx_sunlock(&proctree_lock);
 
 	p2->p_state = PRS_NEW;		/* protect against others */
 	p2->p_pid = trypid;
 	AUDIT_ARG_PID(p2->p_pid);
 	LIST_INSERT_HEAD(&allproc, p2, p_list);
 	LIST_INSERT_HEAD(PIDHASH(p2->p_pid), p2, p_hash);
 	tidhash_add(td2);
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 
 	sx_xunlock(&allproc_lock);
 
 	bcopy(&p1->p_startcopy, &p2->p_startcopy,
 	    __rangeof(struct proc, p_startcopy, p_endcopy));
 	pargs_hold(p2->p_args);
 	PROC_UNLOCK(p1);
 
 	bzero(&p2->p_startzero,
 	    __rangeof(struct proc, p_startzero, p_endzero));
 
 	p2->p_ucred = crhold(td->td_ucred);
 
 	/* Tell the prison that we exist. */
 	prison_proc_hold(p2->p_ucred->cr_prison);
 
 	PROC_UNLOCK(p2);
 
 	/*
 	 * Malloc things while we don't hold any locks.
 	 */
 	if (flags & RFSIGSHARE)
 		newsigacts = NULL;
 	else
 		newsigacts = sigacts_alloc();
 
 	/*
 	 * Copy filedesc.
 	 */
 	if (flags & RFCFDG) {
 		fd = fdinit(p1->p_fd);
 		fdtol = NULL;
 	} else if (flags & RFFDG) {
 		fd = fdcopy(p1->p_fd);
 		fdtol = NULL;
 	} else {
 		fd = fdshare(p1->p_fd);
 		if (p1->p_fdtol == NULL)
 			p1->p_fdtol = filedesc_to_leader_alloc(NULL, NULL,
 			    p1->p_leader);
 		if ((flags & RFTHREAD) != 0) {
 			/*
 			 * Shared file descriptor table, and shared
 			 * process leaders.
 			 */
 			fdtol = p1->p_fdtol;
 			FILEDESC_XLOCK(p1->p_fd);
 			fdtol->fdl_refcount++;
 			FILEDESC_XUNLOCK(p1->p_fd);
 		} else {
 			/* 
 			 * Shared file descriptor table, and different
 			 * process leaders.
 			 */
 			fdtol = filedesc_to_leader_alloc(p1->p_fdtol,
 			    p1->p_fd, p2);
 		}
 	}
 	/*
 	 * Make a proc table entry for the new process.
 	 * Start by zeroing the section of proc that is zero-initialized,
 	 * then copy the section that is copied directly from the parent.
 	 */
 
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 
 	bzero(&td2->td_startzero,
 	    __rangeof(struct thread, td_startzero, td_endzero));
 
 	bcopy(&td->td_startcopy, &td2->td_startcopy,
 	    __rangeof(struct thread, td_startcopy, td_endcopy));
 
 	bcopy(&p2->p_comm, &td2->td_name, sizeof(td2->td_name));
 	td2->td_sigstk = td->td_sigstk;
 	td2->td_flags = TDF_INMEM;
 	td2->td_lend_user_pri = PRI_MAX;
 
 #ifdef VIMAGE
 	td2->td_vnet = NULL;
 	td2->td_vnet_lpush = NULL;
 #endif
 
 	/*
 	 * Allow the scheduler to initialize the child.
 	 */
 	thread_lock(td);
 	sched_fork(td, td2);
 	thread_unlock(td);
 
 	/*
 	 * Duplicate sub-structures as needed.
 	 * Increase reference counts on shared objects.
 	 */
 	p2->p_flag = P_INMEM;
 	p2->p_swtick = ticks;
 	if (p1->p_flag & P_PROFIL)
 		startprofclock(p2);
 	td2->td_ucred = crhold(p2->p_ucred);
 
 	if (flags & RFSIGSHARE) {
 		p2->p_sigacts = sigacts_hold(p1->p_sigacts);
 	} else {
 		sigacts_copy(newsigacts, p1->p_sigacts);
 		p2->p_sigacts = newsigacts;
 	}
 
 	if (flags & RFTSIGZMB)
 	        p2->p_sigparent = RFTSIGNUM(flags);
 	else if (flags & RFLINUXTHPN)
 	        p2->p_sigparent = SIGUSR1;
 	else
 	        p2->p_sigparent = SIGCHLD;
 
 	p2->p_textvp = p1->p_textvp;
 	p2->p_fd = fd;
 	p2->p_fdtol = fdtol;
 
 	/*
 	 * p_limit is copy-on-write.  Bump its refcount.
 	 */
 	lim_fork(p1, p2);
 
 	pstats_fork(p1->p_stats, p2->p_stats);
 
 	PROC_UNLOCK(p1);
 	PROC_UNLOCK(p2);
 
 	/* Bump references to the text vnode (for procfs). */
 	if (p2->p_textvp)
 		vref(p2->p_textvp);
 
 	/*
 	 * Set up linkage for kernel based threading.
 	 */
 	if ((flags & RFTHREAD) != 0) {
 		mtx_lock(&ppeers_lock);
 		p2->p_peers = p1->p_peers;
 		p1->p_peers = p2;
 		p2->p_leader = p1->p_leader;
 		mtx_unlock(&ppeers_lock);
 		PROC_LOCK(p1->p_leader);
 		if ((p1->p_leader->p_flag & P_WEXIT) != 0) {
 			PROC_UNLOCK(p1->p_leader);
 			/*
 			 * The task leader is exiting, so process p1 is
 			 * going to be killed shortly.  Since p1 obviously
 			 * isn't dead yet, we know that the leader is either
 			 * sending SIGKILL's to all the processes in this
 			 * task or is sleeping waiting for all the peers to
 			 * exit.  We let p1 complete the fork, but we need
 			 * to go ahead and kill the new process p2 since
 			 * the task leader may not get a chance to send
 			 * SIGKILL to it.  We leave it on the list so that
 			 * the task leader will wait for this new process
 			 * to commit suicide.
 			 */
 			PROC_LOCK(p2);
 			kern_psignal(p2, SIGKILL);
 			PROC_UNLOCK(p2);
 		} else
 			PROC_UNLOCK(p1->p_leader);
 	} else {
 		p2->p_peers = NULL;
 		p2->p_leader = p2;
 	}
 
 	sx_xlock(&proctree_lock);
 	PGRP_LOCK(p1->p_pgrp);
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 
 	/*
 	 * Preserve some more flags in subprocess.  P_PROFIL has already
 	 * been preserved.
 	 */
 	p2->p_flag |= p1->p_flag & P_SUGID;
 	td2->td_pflags |= td->td_pflags & TDP_ALTSTACK;
 	SESS_LOCK(p1->p_session);
 	if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT)
 		p2->p_flag |= P_CONTROLT;
 	SESS_UNLOCK(p1->p_session);
 	if (flags & RFPPWAIT)
 		p2->p_flag |= P_PPWAIT;
 
 	p2->p_pgrp = p1->p_pgrp;
 	LIST_INSERT_AFTER(p1, p2, p_pglist);
 	PGRP_UNLOCK(p1->p_pgrp);
 	LIST_INIT(&p2->p_children);
 	LIST_INIT(&p2->p_orphans);
 
 	callout_init_mtx(&p2->p_itcallout, &p2->p_mtx, 0);
 
 	/*
 	 * If PF_FORK is set, the child process inherits the
 	 * procfs ioctl flags from its parent.
 	 */
 	if (p1->p_pfsflags & PF_FORK) {
 		p2->p_stops = p1->p_stops;
 		p2->p_pfsflags = p1->p_pfsflags;
 	}
 
 	/*
 	 * This begins the section where we must prevent the parent
 	 * from being swapped.
 	 */
 	_PHOLD(p1);
 	PROC_UNLOCK(p1);
 
 	/*
 	 * Attach the new process to its parent.
 	 *
 	 * If RFNOWAIT is set, the newly created process becomes a child
 	 * of init.  This effectively disassociates the child from the
 	 * parent.
 	 */
 	if (flags & RFNOWAIT)
 		pptr = initproc;
 	else
 		pptr = p1;
 	p2->p_pptr = pptr;
 	LIST_INSERT_HEAD(&pptr->p_children, p2, p_sibling);
 	sx_xunlock(&proctree_lock);
 
 	/* Inform accounting that we have forked. */
 	p2->p_acflag = AFORK;
 	PROC_UNLOCK(p2);
 
 #ifdef KTRACE
 	ktrprocfork(p1, p2);
 #endif
 
 	/*
 	 * Finish creating the child process.  It will return via a different
 	 * execution path later.  (ie: directly into user mode)
 	 */
 	vm_forkproc(td, p2, td2, vm2, flags);
 
 	if (flags == (RFFDG | RFPROC)) {
 		PCPU_INC(cnt.v_forks);
 		PCPU_ADD(cnt.v_forkpages, p2->p_vmspace->vm_dsize +
 		    p2->p_vmspace->vm_ssize);
 	} else if (flags == (RFFDG | RFPROC | RFPPWAIT | RFMEM)) {
 		PCPU_INC(cnt.v_vforks);
 		PCPU_ADD(cnt.v_vforkpages, p2->p_vmspace->vm_dsize +
 		    p2->p_vmspace->vm_ssize);
 	} else if (p1 == &proc0) {
 		PCPU_INC(cnt.v_kthreads);
 		PCPU_ADD(cnt.v_kthreadpages, p2->p_vmspace->vm_dsize +
 		    p2->p_vmspace->vm_ssize);
 	} else {
 		PCPU_INC(cnt.v_rforks);
 		PCPU_ADD(cnt.v_rforkpages, p2->p_vmspace->vm_dsize +
 		    p2->p_vmspace->vm_ssize);
 	}
 
 #ifdef PROCDESC
 	/*
 	 * Associate the process descriptor with the process before anything
 	 * can happen that might cause that process to need the descriptor.
 	 * However, don't do this until after fork(2) can no longer fail.
 	 */
 	if (flags & RFPROCDESC)
 		procdesc_new(p2, pdflags);
 #endif
 
 	/*
 	 * Both processes are set up, now check if any loadable modules want
 	 * to adjust anything.
 	 */
 	EVENTHANDLER_INVOKE(process_fork, p1, p2, flags);
 
 	/*
 	 * Set the child start time and mark the process as being complete.
 	 */
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 	microuptime(&p2->p_stats->p_start);
 	PROC_SLOCK(p2);
 	p2->p_state = PRS_NORMAL;
 	PROC_SUNLOCK(p2);
 
 #ifdef KDTRACE_HOOKS
 	/*
 	 * Tell the DTrace fasttrap provider about the new process
 	 * if it has registered an interest. We have to do this only after
 	 * p_state is PRS_NORMAL since the fasttrap module will use pfind()
 	 * later on.
 	 */
 	if (dtrace_fasttrap_fork)
 		dtrace_fasttrap_fork(p1, p2);
 #endif
 	if ((p1->p_flag & (P_TRACED | P_FOLLOWFORK)) == (P_TRACED |
 	    P_FOLLOWFORK)) {
 		/*
 		 * Arrange for debugger to receive the fork event.
 		 *
 		 * We can report PL_FLAG_FORKED regardless of
 		 * P_FOLLOWFORK settings, but it does not make a sense
 		 * for runaway child.
 		 */
 		td->td_dbgflags |= TDB_FORK;
 		td->td_dbg_forked = p2->p_pid;
 		td2->td_dbgflags |= TDB_STOPATFORK;
 		_PHOLD(p2);
 		p2_held = 1;
 	}
 	if (flags & RFPPWAIT) {
 		td->td_pflags |= TDP_RFPPWAIT;
 		td->td_rfppwait_p = p2;
 	}
 	PROC_UNLOCK(p2);
 	if ((flags & RFSTOPPED) == 0) {
 		/*
 		 * If RFSTOPPED not requested, make child runnable and
 		 * add to run queue.
 		 */
 		thread_lock(td2);
 		TD_SET_CAN_RUN(td2);
 		sched_add(td2, SRQ_BORING);
 		thread_unlock(td2);
 	}
 
 	/*
 	 * Now can be swapped.
 	 */
 	_PRELE(p1);
 	PROC_UNLOCK(p1);
 
 	/*
 	 * Tell any interested parties about the new process.
 	 */
 	knote_fork(&p1->p_klist, p2->p_pid);
 	SDT_PROBE(proc, kernel, , create, p2, p1, flags, 0, 0);
 
 	/*
 	 * Wait until debugger is attached to child.
 	 */
 	PROC_LOCK(p2);
 	while ((td2->td_dbgflags & TDB_STOPATFORK) != 0)
 		cv_wait(&p2->p_dbgwait, &p2->p_mtx);
 	if (p2_held)
 		_PRELE(p2);
 	PROC_UNLOCK(p2);
 }
 
 int
 fork1(struct thread *td, int flags, int pages, struct proc **procp,
     int *procdescp, int pdflags)
 {
 	struct proc *p1;
 	struct proc *newproc;
 	int ok;
 	struct thread *td2;
 	struct vmspace *vm2;
 	vm_ooffset_t mem_charged;
 	int error;
 	static int curfail;
 	static struct timeval lastfail;
 #ifdef PROCDESC
 	struct file *fp_procdesc = NULL;
 #endif
 
 	/* Check for the undefined or unimplemented flags. */
 	if ((flags & ~(RFFLAGS | RFTSIGFLAGS(RFTSIGMASK))) != 0)
 		return (EINVAL);
 
 	/* Signal value requires RFTSIGZMB. */
 	if ((flags & RFTSIGFLAGS(RFTSIGMASK)) != 0 && (flags & RFTSIGZMB) == 0)
 		return (EINVAL);
 
 	/* Can't copy and clear. */
 	if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG))
 		return (EINVAL);
 
 	/* Check the validity of the signal number. */
 	if ((flags & RFTSIGZMB) != 0 && (u_int)RFTSIGNUM(flags) > _SIG_MAXSIG)
 		return (EINVAL);
 
 #ifdef PROCDESC
 	if ((flags & RFPROCDESC) != 0) {
 		/* Can't not create a process yet get a process descriptor. */
 		if ((flags & RFPROC) == 0)
 			return (EINVAL);
 
 		/* Must provide a place to put a procdesc if creating one. */
 		if (procdescp == NULL)
 			return (EINVAL);
 	}
 #endif
 
 	p1 = td->td_proc;
 
 	/*
 	 * Here we don't create a new process, but we divorce
 	 * certain parts of a process from itself.
 	 */
 	if ((flags & RFPROC) == 0) {
 		*procp = NULL;
 		return (fork_norfproc(td, flags));
 	}
 
 #ifdef PROCDESC
 	/*
 	 * If required, create a process descriptor in the parent first; we
 	 * will abandon it if something goes wrong. We don't finit() until
 	 * later.
 	 */
 	if (flags & RFPROCDESC) {
 		error = falloc(td, &fp_procdesc, procdescp, 0);
 		if (error != 0)
 			return (error);
 	}
 #endif
 
 	mem_charged = 0;
 	vm2 = NULL;
 	if (pages == 0)
 		pages = KSTACK_PAGES;
 	/* Allocate new proc. */
 	newproc = uma_zalloc(proc_zone, M_WAITOK);
 	td2 = FIRST_THREAD_IN_PROC(newproc);
 	if (td2 == NULL) {
 		td2 = thread_alloc(pages);
 		if (td2 == NULL) {
 			error = ENOMEM;
 			goto fail1;
 		}
 		proc_linkup(newproc, td2);
 	} else {
 		if (td2->td_kstack == 0 || td2->td_kstack_pages != pages) {
 			if (td2->td_kstack != 0)
 				vm_thread_dispose(td2);
 			if (!thread_alloc_stack(td2, pages)) {
 				error = ENOMEM;
 				goto fail1;
 			}
 		}
 	}
 
 	if ((flags & RFMEM) == 0) {
 		vm2 = vmspace_fork(p1->p_vmspace, &mem_charged);
 		if (vm2 == NULL) {
 			error = ENOMEM;
 			goto fail1;
 		}
 		if (!swap_reserve(mem_charged)) {
 			/*
 			 * The swap reservation failed. The accounting
 			 * from the entries of the copied vm2 will be
 			 * substracted in vmspace_free(), so force the
 			 * reservation there.
 			 */
 			swap_reserve_force(mem_charged);
 			error = ENOMEM;
 			goto fail1;
 		}
 	} else
 		vm2 = NULL;
 
 	/*
 	 * XXX: This is ugly; when we copy resource usage, we need to bump
 	 *      per-cred resource counters.
 	 */
 	newproc->p_ucred = p1->p_ucred;
 
 	/*
 	 * Initialize resource accounting for the child process.
 	 */
 	error = racct_proc_fork(p1, newproc);
 	if (error != 0) {
 		error = EAGAIN;
 		goto fail1;
 	}
 
 #ifdef MAC
 	mac_proc_init(newproc);
 #endif
 	knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx);
 	STAILQ_INIT(&newproc->p_ktr);
 
 	/* We have to lock the process tree while we look for a pid. */
 	sx_slock(&proctree_lock);
 
 	/*
 	 * Although process entries are dynamically created, we still keep
 	 * a global limit on the maximum number we will create.  Don't allow
 	 * a nonprivileged user to use the last ten processes; don't let root
 	 * exceed the limit. The variable nprocs is the current number of
 	 * processes, maxproc is the limit.
 	 */
 	sx_xlock(&allproc_lock);
 	if ((nprocs >= maxproc - 10 && priv_check_cred(td->td_ucred,
 	    PRIV_MAXPROC, 0) != 0) || nprocs >= maxproc) {
 		error = EAGAIN;
 		goto fail;
 	}
 
 	/*
 	 * Increment the count of procs running with this uid. Don't allow
 	 * a nonprivileged user to exceed their current limit.
 	 *
 	 * XXXRW: Can we avoid privilege here if it's not needed?
 	 */
 	error = priv_check_cred(td->td_ucred, PRIV_PROC_LIMIT, 0);
 	if (error == 0)
 		ok = chgproccnt(td->td_ucred->cr_ruidinfo, 1, 0);
 	else {
 		PROC_LOCK(p1);
 		ok = chgproccnt(td->td_ucred->cr_ruidinfo, 1,
 		    lim_cur(p1, RLIMIT_NPROC));
 		PROC_UNLOCK(p1);
 	}
 	if (ok) {
 		do_fork(td, flags, newproc, td2, vm2, pdflags);
 
 		/*
 		 * Return child proc pointer to parent.
 		 */
 		*procp = newproc;
 #ifdef PROCDESC
 		if (flags & RFPROCDESC) {
 			procdesc_finit(newproc->p_procdesc, fp_procdesc);
 			fdrop(fp_procdesc, td);
 		}
 #endif
 		racct_proc_fork_done(newproc);
 		return (0);
 	}
 
 	error = EAGAIN;
 fail:
 	sx_sunlock(&proctree_lock);
 	if (ppsratecheck(&lastfail, &curfail, 1))
-		printf("maxproc limit exceeded by uid %i, please see tuning(7) and login.conf(5).\n",
-		    td->td_ucred->cr_ruid);
+		printf("maxproc limit exceeded by uid %u (pid %d); see tuning(7) and login.conf(5)\n",
+		    td->td_ucred->cr_ruid, p1->p_pid);
 	sx_xunlock(&allproc_lock);
 #ifdef MAC
 	mac_proc_destroy(newproc);
 #endif
 	racct_proc_exit(newproc);
 fail1:
 	if (vm2 != NULL)
 		vmspace_free(vm2);
 	uma_zfree(proc_zone, newproc);
 #ifdef PROCDESC
 	if ((flags & RFPROCDESC) != 0 && fp_procdesc != NULL) {
 		fdclose(td->td_proc->p_fd, fp_procdesc, *procdescp, td);
 		fdrop(fp_procdesc, td);
 	}
 #endif
 	pause("fork", hz / 2);
 	return (error);
 }
 
 /*
  * Handle the return of a child process from fork1().  This function
  * is called from the MD fork_trampoline() entry point.
  */
 void
 fork_exit(void (*callout)(void *, struct trapframe *), void *arg,
     struct trapframe *frame)
 {
 	struct proc *p;
 	struct thread *td;
 	struct thread *dtd;
 
 	td = curthread;
 	p = td->td_proc;
 	KASSERT(p->p_state == PRS_NORMAL, ("executing process is still new"));
 
 	CTR4(KTR_PROC, "fork_exit: new thread %p (td_sched %p, pid %d, %s)",
 		td, td->td_sched, p->p_pid, td->td_name);
 
 	sched_fork_exit(td);
 	/*
 	* Processes normally resume in mi_switch() after being
 	* cpu_switch()'ed to, but when children start up they arrive here
 	* instead, so we must do much the same things as mi_switch() would.
 	*/
 	if ((dtd = PCPU_GET(deadthread))) {
 		PCPU_SET(deadthread, NULL);
 		thread_stash(dtd);
 	}
 	thread_unlock(td);
 
 	/*
 	 * cpu_set_fork_handler intercepts this function call to
 	 * have this call a non-return function to stay in kernel mode.
 	 * initproc has its own fork handler, but it does return.
 	 */
 	KASSERT(callout != NULL, ("NULL callout in fork_exit"));
 	callout(arg, frame);
 
 	/*
 	 * Check if a kernel thread misbehaved and returned from its main
 	 * function.
 	 */
 	if (p->p_flag & P_KTHREAD) {
 		printf("Kernel thread \"%s\" (pid %d) exited prematurely.\n",
 		    td->td_name, p->p_pid);
 		kproc_exit(0);
 	}
 	mtx_assert(&Giant, MA_NOTOWNED);
 
 	if (p->p_sysent->sv_schedtail != NULL)
 		(p->p_sysent->sv_schedtail)(td);
 }
 
 /*
  * Simplified back end of syscall(), used when returning from fork()
  * directly into user mode.  Giant is not held on entry, and must not
  * be held on return.  This function is passed in to fork_exit() as the
  * first parameter and is called when returning to a new userland process.
  */
 void
 fork_return(struct thread *td, struct trapframe *frame)
 {
 	struct proc *p, *dbg;
 
 	if (td->td_dbgflags & TDB_STOPATFORK) {
 		p = td->td_proc;
 		sx_xlock(&proctree_lock);
 		PROC_LOCK(p);
 		if ((p->p_pptr->p_flag & (P_TRACED | P_FOLLOWFORK)) ==
 		    (P_TRACED | P_FOLLOWFORK)) {
 			/*
 			 * If debugger still wants auto-attach for the
 			 * parent's children, do it now.
 			 */
 			dbg = p->p_pptr->p_pptr;
 			p->p_flag |= P_TRACED;
 			p->p_oppid = p->p_pptr->p_pid;
 			proc_reparent(p, dbg);
 			sx_xunlock(&proctree_lock);
 			td->td_dbgflags |= TDB_CHILD;
 			ptracestop(td, SIGSTOP);
 			td->td_dbgflags &= ~TDB_CHILD;
 		} else {
 			/*
 			 * ... otherwise clear the request.
 			 */
 			sx_xunlock(&proctree_lock);
 			td->td_dbgflags &= ~TDB_STOPATFORK;
 			cv_broadcast(&p->p_dbgwait);
 		}
 		PROC_UNLOCK(p);
 	}
 
 	userret(td, frame);
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_SYSRET))
 		ktrsysret(SYS_fork, 0, 0);
 #endif
 }
Index: user/attilio/vmcontention/sys/kern/uipc_syscalls.c
===================================================================
--- user/attilio/vmcontention/sys/kern/uipc_syscalls.c	(revision 249698)
+++ user/attilio/vmcontention/sys/kern/uipc_syscalls.c	(revision 249699)
@@ -1,2875 +1,2866 @@
 /*-
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
  *	The Regents of the University of California.  All rights reserved.
  *
  * sendfile(2) and related extensions:
  * Copyright (c) 1998, David Greenman. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  *	@(#)uipc_syscalls.c	8.4 (Berkeley) 2/21/94
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include "opt_capsicum.h"
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_sctp.h"
 #include "opt_compat.h"
 #include "opt_ktrace.h"
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #ifdef KTRACE
 #include 
 #endif
 #ifdef COMPAT_FREEBSD32
 #include 
 #endif
 
 #include 
 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #if defined(INET) || defined(INET6)
 #ifdef SCTP
 #include 
 #include 
 #endif /* SCTP */
 #endif /* INET || INET6 */
 
 static int sendit(struct thread *td, int s, struct msghdr *mp, int flags);
 static int recvit(struct thread *td, int s, struct msghdr *mp, void *namelenp);
 
 static int accept1(struct thread *td, struct accept_args *uap, int compat);
 static int do_sendfile(struct thread *td, struct sendfile_args *uap, int compat);
 static int getsockname1(struct thread *td, struct getsockname_args *uap,
 			int compat);
 static int getpeername1(struct thread *td, struct getpeername_args *uap,
 			int compat);
 
 /*
  * NSFBUFS-related variables and associated sysctls
  */
 int nsfbufs;
 int nsfbufspeak;
 int nsfbufsused;
 
 SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufs, CTLFLAG_RDTUN, &nsfbufs, 0,
     "Maximum number of sendfile(2) sf_bufs available");
 SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufspeak, CTLFLAG_RD, &nsfbufspeak, 0,
     "Number of sendfile(2) sf_bufs at peak usage");
 SYSCTL_INT(_kern_ipc, OID_AUTO, nsfbufsused, CTLFLAG_RD, &nsfbufsused, 0,
     "Number of sendfile(2) sf_bufs in use");
 
 /*
  * Convert a user file descriptor to a kernel file entry and check if required
  * capability rights are present.
  * A reference on the file entry is held upon returning.
  */
 static int
 getsock_cap(struct filedesc *fdp, int fd, cap_rights_t rights,
     struct file **fpp, u_int *fflagp)
 {
 	struct file *fp;
 	int error;
 
 	error = fget_unlocked(fdp, fd, rights, 0, &fp, NULL);
 	if (error != 0)
 		return (error);
 	if (fp->f_type != DTYPE_SOCKET) {
 		fdrop(fp, curthread);
 		return (ENOTSOCK);
 	}
 	if (fflagp != NULL)
 		*fflagp = fp->f_flag;
 	*fpp = fp;
 	return (0);
 }
 
 /*
  * System call interface to the socket abstraction.
  */
 #if defined(COMPAT_43)
 #define COMPAT_OLDSOCK
 #endif
 
 int
 sys_socket(td, uap)
 	struct thread *td;
 	struct socket_args /* {
 		int	domain;
 		int	type;
 		int	protocol;
 	} */ *uap;
 {
 	struct socket *so;
 	struct file *fp;
 	int fd, error, type, oflag, fflag;
 
 	AUDIT_ARG_SOCKET(uap->domain, uap->type, uap->protocol);
 
 	type = uap->type;
 	oflag = 0;
 	fflag = 0;
 	if ((type & SOCK_CLOEXEC) != 0) {
 		type &= ~SOCK_CLOEXEC;
 		oflag |= O_CLOEXEC;
 	}
 	if ((type & SOCK_NONBLOCK) != 0) {
 		type &= ~SOCK_NONBLOCK;
 		fflag |= FNONBLOCK;
 	}
 
 #ifdef MAC
 	error = mac_socket_check_create(td->td_ucred, uap->domain, type,
 	    uap->protocol);
 	if (error)
 		return (error);
 #endif
 	error = falloc(td, &fp, &fd, oflag);
 	if (error)
 		return (error);
 	/* An extra reference on `fp' has been held for us by falloc(). */
 	error = socreate(uap->domain, &so, type, uap->protocol,
 	    td->td_ucred, td);
 	if (error) {
 		fdclose(td->td_proc->p_fd, fp, fd, td);
 	} else {
 		finit(fp, FREAD | FWRITE | fflag, DTYPE_SOCKET, so, &socketops);
 		if ((fflag & FNONBLOCK) != 0)
 			(void) fo_ioctl(fp, FIONBIO, &fflag, td->td_ucred, td);
 		td->td_retval[0] = fd;
 	}
 	fdrop(fp, td);
 	return (error);
 }
 
 /* ARGSUSED */
 int
 sys_bind(td, uap)
 	struct thread *td;
 	struct bind_args /* {
 		int	s;
 		caddr_t	name;
 		int	namelen;
 	} */ *uap;
 {
 	struct sockaddr *sa;
 	int error;
 
 	error = getsockaddr(&sa, uap->name, uap->namelen);
 	if (error == 0) {
 		error = kern_bind(td, uap->s, sa);
 		free(sa, M_SONAME);
 	}
 	return (error);
 }
 
 static int
 kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
 {
 	struct socket *so;
 	struct file *fp;
 	int error;
 
 	AUDIT_ARG_FD(fd);
 	AUDIT_ARG_SOCKADDR(td, dirfd, sa);
 	error = getsock_cap(td->td_proc->p_fd, fd, CAP_BIND, &fp, NULL);
 	if (error)
 		return (error);
 	so = fp->f_data;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(sa);
 #endif
 #ifdef MAC
 	error = mac_socket_check_bind(td->td_ucred, so, sa);
 	if (error == 0) {
 #endif
 		if (dirfd == AT_FDCWD)
 			error = sobind(so, sa, td);
 		else
 			error = sobindat(dirfd, so, sa, td);
 #ifdef MAC
 	}
 #endif
 	fdrop(fp, td);
 	return (error);
 }
 
 int
 kern_bind(struct thread *td, int fd, struct sockaddr *sa)
 {
 
 	return (kern_bindat(td, AT_FDCWD, fd, sa));
 }
 
 /* ARGSUSED */
 int
 sys_bindat(td, uap)
 	struct thread *td;
 	struct bindat_args /* {
 		int	fd;
 		int	s;
 		caddr_t	name;
 		int	namelen;
 	} */ *uap;
 {
 	struct sockaddr *sa;
 	int error;
 
 	error = getsockaddr(&sa, uap->name, uap->namelen);
 	if (error == 0) {
 		error = kern_bindat(td, uap->fd, uap->s, sa);
 		free(sa, M_SONAME);
 	}
 	return (error);
 }
 
 /* ARGSUSED */
 int
 sys_listen(td, uap)
 	struct thread *td;
 	struct listen_args /* {
 		int	s;
 		int	backlog;
 	} */ *uap;
 {
 	struct socket *so;
 	struct file *fp;
 	int error;
 
 	AUDIT_ARG_FD(uap->s);
 	error = getsock_cap(td->td_proc->p_fd, uap->s, CAP_LISTEN, &fp, NULL);
 	if (error == 0) {
 		so = fp->f_data;
 #ifdef MAC
 		error = mac_socket_check_listen(td->td_ucred, so);
 		if (error == 0)
 #endif
 			error = solisten(so, uap->backlog, td);
 		fdrop(fp, td);
 	}
 	return(error);
 }
 
 /*
  * accept1()
  */
 static int
 accept1(td, uap, compat)
 	struct thread *td;
 	struct accept_args /* {
 		int	s;
 		struct sockaddr	* __restrict name;
 		socklen_t	* __restrict anamelen;
 	} */ *uap;
 	int compat;
 {
 	struct sockaddr *name;
 	socklen_t namelen;
 	struct file *fp;
 	int error;
 
 	if (uap->name == NULL)
 		return (kern_accept(td, uap->s, NULL, NULL, NULL));
 
 	error = copyin(uap->anamelen, &namelen, sizeof (namelen));
 	if (error)
 		return (error);
 
 	error = kern_accept(td, uap->s, &name, &namelen, &fp);
 
 	/*
 	 * return a namelen of zero for older code which might
 	 * ignore the return value from accept.
 	 */
 	if (error) {
 		(void) copyout(&namelen,
 		    uap->anamelen, sizeof(*uap->anamelen));
 		return (error);
 	}
 
 	if (error == 0 && name != NULL) {
 #ifdef COMPAT_OLDSOCK
 		if (compat)
 			((struct osockaddr *)name)->sa_family =
 			    name->sa_family;
 #endif
 		error = copyout(name, uap->name, namelen);
 	}
 	if (error == 0)
 		error = copyout(&namelen, uap->anamelen,
 		    sizeof(namelen));
 	if (error)
 		fdclose(td->td_proc->p_fd, fp, td->td_retval[0], td);
 	fdrop(fp, td);
 	free(name, M_SONAME);
 	return (error);
 }
 
 int
 kern_accept(struct thread *td, int s, struct sockaddr **name,
     socklen_t *namelen, struct file **fp)
 {
 	struct filedesc *fdp;
 	struct file *headfp, *nfp = NULL;
 	struct sockaddr *sa = NULL;
 	int error;
 	struct socket *head, *so;
 	int fd;
 	u_int fflag;
 	pid_t pgid;
 	int tmp;
 
-	if (name) {
+	if (name)
 		*name = NULL;
-		if (*namelen < 0)
-			return (EINVAL);
-	}
 
 	AUDIT_ARG_FD(s);
 	fdp = td->td_proc->p_fd;
 	error = getsock_cap(fdp, s, CAP_ACCEPT, &headfp, &fflag);
 	if (error)
 		return (error);
 	head = headfp->f_data;
 	if ((head->so_options & SO_ACCEPTCONN) == 0) {
 		error = EINVAL;
 		goto done;
 	}
 #ifdef MAC
 	error = mac_socket_check_accept(td->td_ucred, head);
 	if (error != 0)
 		goto done;
 #endif
 	error = falloc(td, &nfp, &fd, 0);
 	if (error)
 		goto done;
 	ACCEPT_LOCK();
 	if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) {
 		ACCEPT_UNLOCK();
 		error = EWOULDBLOCK;
 		goto noconnection;
 	}
 	while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) {
 		if (head->so_rcv.sb_state & SBS_CANTRCVMORE) {
 			head->so_error = ECONNABORTED;
 			break;
 		}
 		error = msleep(&head->so_timeo, &accept_mtx, PSOCK | PCATCH,
 		    "accept", 0);
 		if (error) {
 			ACCEPT_UNLOCK();
 			goto noconnection;
 		}
 	}
 	if (head->so_error) {
 		error = head->so_error;
 		head->so_error = 0;
 		ACCEPT_UNLOCK();
 		goto noconnection;
 	}
 	so = TAILQ_FIRST(&head->so_comp);
 	KASSERT(!(so->so_qstate & SQ_INCOMP), ("accept1: so SQ_INCOMP"));
 	KASSERT(so->so_qstate & SQ_COMP, ("accept1: so not SQ_COMP"));
 
 	/*
 	 * Before changing the flags on the socket, we have to bump the
 	 * reference count.  Otherwise, if the protocol calls sofree(),
 	 * the socket will be released due to a zero refcount.
 	 */
 	SOCK_LOCK(so);			/* soref() and so_state update */
 	soref(so);			/* file descriptor reference */
 
 	TAILQ_REMOVE(&head->so_comp, so, so_list);
 	head->so_qlen--;
 	so->so_state |= (head->so_state & SS_NBIO);
 	so->so_qstate &= ~SQ_COMP;
 	so->so_head = NULL;
 
 	SOCK_UNLOCK(so);
 	ACCEPT_UNLOCK();
 
 	/* An extra reference on `nfp' has been held for us by falloc(). */
 	td->td_retval[0] = fd;
 
 	/* connection has been removed from the listen queue */
 	KNOTE_UNLOCKED(&head->so_rcv.sb_sel.si_note, 0);
 
 	pgid = fgetown(&head->so_sigio);
 	if (pgid != 0)
 		fsetown(pgid, &so->so_sigio);
 
 	finit(nfp, fflag, DTYPE_SOCKET, so, &socketops);
 	/* Sync socket nonblocking/async state with file flags */
 	tmp = fflag & FNONBLOCK;
 	(void) fo_ioctl(nfp, FIONBIO, &tmp, td->td_ucred, td);
 	tmp = fflag & FASYNC;
 	(void) fo_ioctl(nfp, FIOASYNC, &tmp, td->td_ucred, td);
 	sa = 0;
 	error = soaccept(so, &sa);
 	if (error) {
 		/*
 		 * return a namelen of zero for older code which might
 		 * ignore the return value from accept.
 		 */
 		if (name)
 			*namelen = 0;
 		goto noconnection;
 	}
 	if (sa == NULL) {
 		if (name)
 			*namelen = 0;
 		goto done;
 	}
 	AUDIT_ARG_SOCKADDR(td, AT_FDCWD, sa);
 	if (name) {
 		/* check sa_len before it is destroyed */
 		if (*namelen > sa->sa_len)
 			*namelen = sa->sa_len;
 #ifdef KTRACE
 		if (KTRPOINT(td, KTR_STRUCT))
 			ktrsockaddr(sa);
 #endif
 		*name = sa;
 		sa = NULL;
 	}
 noconnection:
 	if (sa)
 		free(sa, M_SONAME);
 
 	/*
 	 * close the new descriptor, assuming someone hasn't ripped it
 	 * out from under us.
 	 */
 	if (error)
 		fdclose(fdp, nfp, fd, td);
 
 	/*
 	 * Release explicitly held references before returning.  We return
 	 * a reference on nfp to the caller on success if they request it.
 	 */
 done:
 	if (fp != NULL) {
 		if (error == 0) {
 			*fp = nfp;
 			nfp = NULL;
 		} else
 			*fp = NULL;
 	}
 	if (nfp != NULL)
 		fdrop(nfp, td);
 	fdrop(headfp, td);
 	return (error);
 }
 
 int
 sys_accept(td, uap)
 	struct thread *td;
 	struct accept_args *uap;
 {
 
 	return (accept1(td, uap, 0));
 }
 
 #ifdef COMPAT_OLDSOCK
 int
 oaccept(td, uap)
 	struct thread *td;
 	struct accept_args *uap;
 {
 
 	return (accept1(td, uap, 1));
 }
 #endif /* COMPAT_OLDSOCK */
 
 /* ARGSUSED */
 int
 sys_connect(td, uap)
 	struct thread *td;
 	struct connect_args /* {
 		int	s;
 		caddr_t	name;
 		int	namelen;
 	} */ *uap;
 {
 	struct sockaddr *sa;
 	int error;
 
 	error = getsockaddr(&sa, uap->name, uap->namelen);
 	if (error == 0) {
 		error = kern_connect(td, uap->s, sa);
 		free(sa, M_SONAME);
 	}
 	return (error);
 }
 
 static int
 kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
 {
 	struct socket *so;
 	struct file *fp;
 	int error;
 	int interrupted = 0;
 
 	AUDIT_ARG_FD(fd);
 	AUDIT_ARG_SOCKADDR(td, dirfd, sa);
 	error = getsock_cap(td->td_proc->p_fd, fd, CAP_CONNECT, &fp, NULL);
 	if (error)
 		return (error);
 	so = fp->f_data;
 	if (so->so_state & SS_ISCONNECTING) {
 		error = EALREADY;
 		goto done1;
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(sa);
 #endif
 #ifdef MAC
 	error = mac_socket_check_connect(td->td_ucred, so, sa);
 	if (error)
 		goto bad;
 #endif
 	if (dirfd == AT_FDCWD)
 		error = soconnect(so, sa, td);
 	else
 		error = soconnectat(dirfd, so, sa, td);
 	if (error)
 		goto bad;
 	if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
 		error = EINPROGRESS;
 		goto done1;
 	}
 	SOCK_LOCK(so);
 	while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
 		error = msleep(&so->so_timeo, SOCK_MTX(so), PSOCK | PCATCH,
 		    "connec", 0);
 		if (error) {
 			if (error == EINTR || error == ERESTART)
 				interrupted = 1;
 			break;
 		}
 	}
 	if (error == 0) {
 		error = so->so_error;
 		so->so_error = 0;
 	}
 	SOCK_UNLOCK(so);
 bad:
 	if (!interrupted)
 		so->so_state &= ~SS_ISCONNECTING;
 	if (error == ERESTART)
 		error = EINTR;
 done1:
 	fdrop(fp, td);
 	return (error);
 }
 
 int
 kern_connect(struct thread *td, int fd, struct sockaddr *sa)
 {
 
 	return (kern_connectat(td, AT_FDCWD, fd, sa));
 }
 
 /* ARGSUSED */
 int
 sys_connectat(td, uap)
 	struct thread *td;
 	struct connectat_args /* {
 		int	fd;
 		int	s;
 		caddr_t	name;
 		int	namelen;
 	} */ *uap;
 {
 	struct sockaddr *sa;
 	int error;
 
 	error = getsockaddr(&sa, uap->name, uap->namelen);
 	if (error == 0) {
 		error = kern_connectat(td, uap->fd, uap->s, sa);
 		free(sa, M_SONAME);
 	}
 	return (error);
 }
 
 int
 kern_socketpair(struct thread *td, int domain, int type, int protocol,
     int *rsv)
 {
 	struct filedesc *fdp = td->td_proc->p_fd;
 	struct file *fp1, *fp2;
 	struct socket *so1, *so2;
 	int fd, error, oflag, fflag;
 
 	AUDIT_ARG_SOCKET(domain, type, protocol);
 
 	oflag = 0;
 	fflag = 0;
 	if ((type & SOCK_CLOEXEC) != 0) {
 		type &= ~SOCK_CLOEXEC;
 		oflag |= O_CLOEXEC;
 	}
 	if ((type & SOCK_NONBLOCK) != 0) {
 		type &= ~SOCK_NONBLOCK;
 		fflag |= FNONBLOCK;
 	}
 #ifdef MAC
 	/* We might want to have a separate check for socket pairs. */
 	error = mac_socket_check_create(td->td_ucred, domain, type,
 	    protocol);
 	if (error)
 		return (error);
 #endif
 	error = socreate(domain, &so1, type, protocol, td->td_ucred, td);
 	if (error)
 		return (error);
 	error = socreate(domain, &so2, type, protocol, td->td_ucred, td);
 	if (error)
 		goto free1;
 	/* On success extra reference to `fp1' and 'fp2' is set by falloc. */
 	error = falloc(td, &fp1, &fd, oflag);
 	if (error)
 		goto free2;
 	rsv[0] = fd;
 	fp1->f_data = so1;	/* so1 already has ref count */
 	error = falloc(td, &fp2, &fd, oflag);
 	if (error)
 		goto free3;
 	fp2->f_data = so2;	/* so2 already has ref count */
 	rsv[1] = fd;
 	error = soconnect2(so1, so2);
 	if (error)
 		goto free4;
 	if (type == SOCK_DGRAM) {
 		/*
 		 * Datagram socket connection is asymmetric.
 		 */
 		 error = soconnect2(so2, so1);
 		 if (error)
 			goto free4;
 	}
 	finit(fp1, FREAD | FWRITE | fflag, DTYPE_SOCKET, fp1->f_data,
 	    &socketops);
 	finit(fp2, FREAD | FWRITE | fflag, DTYPE_SOCKET, fp2->f_data,
 	    &socketops);
 	if ((fflag & FNONBLOCK) != 0) {
 		(void) fo_ioctl(fp1, FIONBIO, &fflag, td->td_ucred, td);
 		(void) fo_ioctl(fp2, FIONBIO, &fflag, td->td_ucred, td);
 	}
 	fdrop(fp1, td);
 	fdrop(fp2, td);
 	return (0);
 free4:
 	fdclose(fdp, fp2, rsv[1], td);
 	fdrop(fp2, td);
 free3:
 	fdclose(fdp, fp1, rsv[0], td);
 	fdrop(fp1, td);
 free2:
 	if (so2 != NULL)
 		(void)soclose(so2);
 free1:
 	if (so1 != NULL)
 		(void)soclose(so1);
 	return (error);
 }
 
 int
 sys_socketpair(struct thread *td, struct socketpair_args *uap)
 {
 	int error, sv[2];
 
 	error = kern_socketpair(td, uap->domain, uap->type,
 	    uap->protocol, sv);
 	if (error)
 		return (error);
 	error = copyout(sv, uap->rsv, 2 * sizeof(int));
 	if (error) {
 		(void)kern_close(td, sv[0]);
 		(void)kern_close(td, sv[1]);
 	}
 	return (error);
 }
 
 static int
 sendit(td, s, mp, flags)
 	struct thread *td;
 	int s;
 	struct msghdr *mp;
 	int flags;
 {
 	struct mbuf *control;
 	struct sockaddr *to;
 	int error;
 
 #ifdef CAPABILITY_MODE
 	if (IN_CAPABILITY_MODE(td) && (mp->msg_name != NULL))
 		return (ECAPMODE);
 #endif
 
 	if (mp->msg_name != NULL) {
 		error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
 		if (error) {
 			to = NULL;
 			goto bad;
 		}
 		mp->msg_name = to;
 	} else {
 		to = NULL;
 	}
 
 	if (mp->msg_control) {
 		if (mp->msg_controllen < sizeof(struct cmsghdr)
 #ifdef COMPAT_OLDSOCK
 		    && mp->msg_flags != MSG_COMPAT
 #endif
 		) {
 			error = EINVAL;
 			goto bad;
 		}
 		error = sockargs(&control, mp->msg_control,
 		    mp->msg_controllen, MT_CONTROL);
 		if (error)
 			goto bad;
 #ifdef COMPAT_OLDSOCK
 		if (mp->msg_flags == MSG_COMPAT) {
 			struct cmsghdr *cm;
 
 			M_PREPEND(control, sizeof(*cm), M_WAITOK);
 			cm = mtod(control, struct cmsghdr *);
 			cm->cmsg_len = control->m_len;
 			cm->cmsg_level = SOL_SOCKET;
 			cm->cmsg_type = SCM_RIGHTS;
 		}
 #endif
 	} else {
 		control = NULL;
 	}
 
 	error = kern_sendit(td, s, mp, flags, control, UIO_USERSPACE);
 
 bad:
 	if (to)
 		free(to, M_SONAME);
 	return (error);
 }
 
 int
 kern_sendit(td, s, mp, flags, control, segflg)
 	struct thread *td;
 	int s;
 	struct msghdr *mp;
 	int flags;
 	struct mbuf *control;
 	enum uio_seg segflg;
 {
 	struct file *fp;
 	struct uio auio;
 	struct iovec *iov;
 	struct socket *so;
 	int i, error;
 	ssize_t len;
 	cap_rights_t rights;
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
 
 	AUDIT_ARG_FD(s);
 	rights = CAP_SEND;
 	if (mp->msg_name != NULL) {
 		AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
 		rights |= CAP_CONNECT;
 	}
 	error = getsock_cap(td->td_proc->p_fd, s, rights, &fp, NULL);
 	if (error)
 		return (error);
 	so = (struct socket *)fp->f_data;
 
 #ifdef KTRACE
 	if (mp->msg_name != NULL && KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(mp->msg_name);
 #endif
 #ifdef MAC
 	if (mp->msg_name != NULL) {
 		error = mac_socket_check_connect(td->td_ucred, so,
 		    mp->msg_name);
 		if (error)
 			goto bad;
 	}
 	error = mac_socket_check_send(td->td_ucred, so);
 	if (error)
 		goto bad;
 #endif
 
 	auio.uio_iov = mp->msg_iov;
 	auio.uio_iovcnt = mp->msg_iovlen;
 	auio.uio_segflg = segflg;
 	auio.uio_rw = UIO_WRITE;
 	auio.uio_td = td;
 	auio.uio_offset = 0;			/* XXX */
 	auio.uio_resid = 0;
 	iov = mp->msg_iov;
 	for (i = 0; i < mp->msg_iovlen; i++, iov++) {
 		if ((auio.uio_resid += iov->iov_len) < 0) {
 			error = EINVAL;
 			goto bad;
 		}
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_GENIO))
 		ktruio = cloneuio(&auio);
 #endif
 	len = auio.uio_resid;
 	error = sosend(so, mp->msg_name, &auio, 0, control, flags, td);
 	if (error) {
 		if (auio.uio_resid != len && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 		/* Generation of SIGPIPE can be controlled per socket */
 		if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) &&
 		    !(flags & MSG_NOSIGNAL)) {
 			PROC_LOCK(td->td_proc);
 			tdsignal(td, SIGPIPE);
 			PROC_UNLOCK(td->td_proc);
 		}
 	}
 	if (error == 0)
 		td->td_retval[0] = len - auio.uio_resid;
 #ifdef KTRACE
 	if (ktruio != NULL) {
 		ktruio->uio_resid = td->td_retval[0];
 		ktrgenio(s, UIO_WRITE, ktruio, error);
 	}
 #endif
 bad:
 	fdrop(fp, td);
 	return (error);
 }
 
 int
 sys_sendto(td, uap)
 	struct thread *td;
 	struct sendto_args /* {
 		int	s;
 		caddr_t	buf;
 		size_t	len;
 		int	flags;
 		caddr_t	to;
 		int	tolen;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec aiov;
 	int error;
 
 	msg.msg_name = uap->to;
 	msg.msg_namelen = uap->tolen;
 	msg.msg_iov = &aiov;
 	msg.msg_iovlen = 1;
 	msg.msg_control = 0;
 #ifdef COMPAT_OLDSOCK
 	msg.msg_flags = 0;
 #endif
 	aiov.iov_base = uap->buf;
 	aiov.iov_len = uap->len;
 	error = sendit(td, uap->s, &msg, uap->flags);
 	return (error);
 }
 
 #ifdef COMPAT_OLDSOCK
 int
 osend(td, uap)
 	struct thread *td;
 	struct osend_args /* {
 		int	s;
 		caddr_t	buf;
 		int	len;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec aiov;
 	int error;
 
 	msg.msg_name = 0;
 	msg.msg_namelen = 0;
 	msg.msg_iov = &aiov;
 	msg.msg_iovlen = 1;
 	aiov.iov_base = uap->buf;
 	aiov.iov_len = uap->len;
 	msg.msg_control = 0;
 	msg.msg_flags = 0;
 	error = sendit(td, uap->s, &msg, uap->flags);
 	return (error);
 }
 
 int
 osendmsg(td, uap)
 	struct thread *td;
 	struct osendmsg_args /* {
 		int	s;
 		caddr_t	msg;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec *iov;
 	int error;
 
 	error = copyin(uap->msg, &msg, sizeof (struct omsghdr));
 	if (error)
 		return (error);
 	error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
 	if (error)
 		return (error);
 	msg.msg_iov = iov;
 	msg.msg_flags = MSG_COMPAT;
 	error = sendit(td, uap->s, &msg, uap->flags);
 	free(iov, M_IOV);
 	return (error);
 }
 #endif
 
 int
 sys_sendmsg(td, uap)
 	struct thread *td;
 	struct sendmsg_args /* {
 		int	s;
 		caddr_t	msg;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec *iov;
 	int error;
 
 	error = copyin(uap->msg, &msg, sizeof (msg));
 	if (error)
 		return (error);
 	error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
 	if (error)
 		return (error);
 	msg.msg_iov = iov;
 #ifdef COMPAT_OLDSOCK
 	msg.msg_flags = 0;
 #endif
 	error = sendit(td, uap->s, &msg, uap->flags);
 	free(iov, M_IOV);
 	return (error);
 }
 
 int
 kern_recvit(td, s, mp, fromseg, controlp)
 	struct thread *td;
 	int s;
 	struct msghdr *mp;
 	enum uio_seg fromseg;
 	struct mbuf **controlp;
 {
 	struct uio auio;
 	struct iovec *iov;
 	int i;
 	ssize_t len;
 	int error;
 	struct mbuf *m, *control = NULL;
 	caddr_t ctlbuf;
 	struct file *fp;
 	struct socket *so;
 	struct sockaddr *fromsa = NULL;
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
 
 	if (controlp != NULL)
 		*controlp = NULL;
 
 	AUDIT_ARG_FD(s);
 	error = getsock_cap(td->td_proc->p_fd, s, CAP_RECV, &fp, NULL);
 	if (error)
 		return (error);
 	so = fp->f_data;
 
 #ifdef MAC
 	error = mac_socket_check_receive(td->td_ucred, so);
 	if (error) {
 		fdrop(fp, td);
 		return (error);
 	}
 #endif
 
 	auio.uio_iov = mp->msg_iov;
 	auio.uio_iovcnt = mp->msg_iovlen;
 	auio.uio_segflg = UIO_USERSPACE;
 	auio.uio_rw = UIO_READ;
 	auio.uio_td = td;
 	auio.uio_offset = 0;			/* XXX */
 	auio.uio_resid = 0;
 	iov = mp->msg_iov;
 	for (i = 0; i < mp->msg_iovlen; i++, iov++) {
 		if ((auio.uio_resid += iov->iov_len) < 0) {
 			fdrop(fp, td);
 			return (EINVAL);
 		}
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_GENIO))
 		ktruio = cloneuio(&auio);
 #endif
 	len = auio.uio_resid;
 	error = soreceive(so, &fromsa, &auio, NULL,
 	    (mp->msg_control || controlp) ? &control : NULL,
 	    &mp->msg_flags);
 	if (error) {
 		if (auio.uio_resid != len && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 	}
 	if (fromsa != NULL)
 		AUDIT_ARG_SOCKADDR(td, AT_FDCWD, fromsa);
 #ifdef KTRACE
 	if (ktruio != NULL) {
 		ktruio->uio_resid = len - auio.uio_resid;
 		ktrgenio(s, UIO_READ, ktruio, error);
 	}
 #endif
 	if (error)
 		goto out;
 	td->td_retval[0] = len - auio.uio_resid;
 	if (mp->msg_name) {
 		len = mp->msg_namelen;
 		if (len <= 0 || fromsa == NULL)
 			len = 0;
 		else {
 			/* save sa_len before it is destroyed by MSG_COMPAT */
 			len = MIN(len, fromsa->sa_len);
 #ifdef COMPAT_OLDSOCK
 			if (mp->msg_flags & MSG_COMPAT)
 				((struct osockaddr *)fromsa)->sa_family =
 				    fromsa->sa_family;
 #endif
 			if (fromseg == UIO_USERSPACE) {
 				error = copyout(fromsa, mp->msg_name,
 				    (unsigned)len);
 				if (error)
 					goto out;
 			} else
 				bcopy(fromsa, mp->msg_name, len);
 		}
 		mp->msg_namelen = len;
 	}
 	if (mp->msg_control && controlp == NULL) {
 #ifdef COMPAT_OLDSOCK
 		/*
 		 * We assume that old recvmsg calls won't receive access
 		 * rights and other control info, esp. as control info
 		 * is always optional and those options didn't exist in 4.3.
 		 * If we receive rights, trim the cmsghdr; anything else
 		 * is tossed.
 		 */
 		if (control && mp->msg_flags & MSG_COMPAT) {
 			if (mtod(control, struct cmsghdr *)->cmsg_level !=
 			    SOL_SOCKET ||
 			    mtod(control, struct cmsghdr *)->cmsg_type !=
 			    SCM_RIGHTS) {
 				mp->msg_controllen = 0;
 				goto out;
 			}
 			control->m_len -= sizeof (struct cmsghdr);
 			control->m_data += sizeof (struct cmsghdr);
 		}
 #endif
 		len = mp->msg_controllen;
 		m = control;
 		mp->msg_controllen = 0;
 		ctlbuf = mp->msg_control;
 
 		while (m && len > 0) {
 			unsigned int tocopy;
 
 			if (len >= m->m_len)
 				tocopy = m->m_len;
 			else {
 				mp->msg_flags |= MSG_CTRUNC;
 				tocopy = len;
 			}
 
 			if ((error = copyout(mtod(m, caddr_t),
 					ctlbuf, tocopy)) != 0)
 				goto out;
 
 			ctlbuf += tocopy;
 			len -= tocopy;
 			m = m->m_next;
 		}
 		mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control;
 	}
 out:
 	fdrop(fp, td);
 #ifdef KTRACE
 	if (fromsa && KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(fromsa);
 #endif
 	if (fromsa)
 		free(fromsa, M_SONAME);
 
 	if (error == 0 && controlp != NULL)
 		*controlp = control;
 	else  if (control)
 		m_freem(control);
 
 	return (error);
 }
 
 static int
 recvit(td, s, mp, namelenp)
 	struct thread *td;
 	int s;
 	struct msghdr *mp;
 	void *namelenp;
 {
 	int error;
 
 	error = kern_recvit(td, s, mp, UIO_USERSPACE, NULL);
 	if (error)
 		return (error);
 	if (namelenp) {
 		error = copyout(&mp->msg_namelen, namelenp, sizeof (socklen_t));
 #ifdef COMPAT_OLDSOCK
 		if (mp->msg_flags & MSG_COMPAT)
 			error = 0;	/* old recvfrom didn't check */
 #endif
 	}
 	return (error);
 }
 
 int
 sys_recvfrom(td, uap)
 	struct thread *td;
 	struct recvfrom_args /* {
 		int	s;
 		caddr_t	buf;
 		size_t	len;
 		int	flags;
 		struct sockaddr * __restrict	from;
 		socklen_t * __restrict fromlenaddr;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec aiov;
 	int error;
 
 	if (uap->fromlenaddr) {
 		error = copyin(uap->fromlenaddr,
 		    &msg.msg_namelen, sizeof (msg.msg_namelen));
 		if (error)
 			goto done2;
 	} else {
 		msg.msg_namelen = 0;
 	}
 	msg.msg_name = uap->from;
 	msg.msg_iov = &aiov;
 	msg.msg_iovlen = 1;
 	aiov.iov_base = uap->buf;
 	aiov.iov_len = uap->len;
 	msg.msg_control = 0;
 	msg.msg_flags = uap->flags;
 	error = recvit(td, uap->s, &msg, uap->fromlenaddr);
 done2:
 	return(error);
 }
 
 #ifdef COMPAT_OLDSOCK
 int
 orecvfrom(td, uap)
 	struct thread *td;
 	struct recvfrom_args *uap;
 {
 
 	uap->flags |= MSG_COMPAT;
 	return (sys_recvfrom(td, uap));
 }
 #endif
 
 #ifdef COMPAT_OLDSOCK
 int
 orecv(td, uap)
 	struct thread *td;
 	struct orecv_args /* {
 		int	s;
 		caddr_t	buf;
 		int	len;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec aiov;
 	int error;
 
 	msg.msg_name = 0;
 	msg.msg_namelen = 0;
 	msg.msg_iov = &aiov;
 	msg.msg_iovlen = 1;
 	aiov.iov_base = uap->buf;
 	aiov.iov_len = uap->len;
 	msg.msg_control = 0;
 	msg.msg_flags = uap->flags;
 	error = recvit(td, uap->s, &msg, NULL);
 	return (error);
 }
 
 /*
  * Old recvmsg.  This code takes advantage of the fact that the old msghdr
  * overlays the new one, missing only the flags, and with the (old) access
  * rights where the control fields are now.
  */
 int
 orecvmsg(td, uap)
 	struct thread *td;
 	struct orecvmsg_args /* {
 		int	s;
 		struct	omsghdr *msg;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec *iov;
 	int error;
 
 	error = copyin(uap->msg, &msg, sizeof (struct omsghdr));
 	if (error)
 		return (error);
 	error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
 	if (error)
 		return (error);
 	msg.msg_flags = uap->flags | MSG_COMPAT;
 	msg.msg_iov = iov;
 	error = recvit(td, uap->s, &msg, &uap->msg->msg_namelen);
 	if (msg.msg_controllen && error == 0)
 		error = copyout(&msg.msg_controllen,
 		    &uap->msg->msg_accrightslen, sizeof (int));
 	free(iov, M_IOV);
 	return (error);
 }
 #endif
 
 int
 sys_recvmsg(td, uap)
 	struct thread *td;
 	struct recvmsg_args /* {
 		int	s;
 		struct	msghdr *msg;
 		int	flags;
 	} */ *uap;
 {
 	struct msghdr msg;
 	struct iovec *uiov, *iov;
 	int error;
 
 	error = copyin(uap->msg, &msg, sizeof (msg));
 	if (error)
 		return (error);
 	error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
 	if (error)
 		return (error);
 	msg.msg_flags = uap->flags;
 #ifdef COMPAT_OLDSOCK
 	msg.msg_flags &= ~MSG_COMPAT;
 #endif
 	uiov = msg.msg_iov;
 	msg.msg_iov = iov;
 	error = recvit(td, uap->s, &msg, NULL);
 	if (error == 0) {
 		msg.msg_iov = uiov;
 		error = copyout(&msg, uap->msg, sizeof(msg));
 	}
 	free(iov, M_IOV);
 	return (error);
 }
 
 /* ARGSUSED */
 int
 sys_shutdown(td, uap)
 	struct thread *td;
 	struct shutdown_args /* {
 		int	s;
 		int	how;
 	} */ *uap;
 {
 	struct socket *so;
 	struct file *fp;
 	int error;
 
 	AUDIT_ARG_FD(uap->s);
 	error = getsock_cap(td->td_proc->p_fd, uap->s, CAP_SHUTDOWN, &fp,
 	    NULL);
 	if (error == 0) {
 		so = fp->f_data;
 		error = soshutdown(so, uap->how);
 		fdrop(fp, td);
 	}
 	return (error);
 }
 
 /* ARGSUSED */
 int
 sys_setsockopt(td, uap)
 	struct thread *td;
 	struct setsockopt_args /* {
 		int	s;
 		int	level;
 		int	name;
 		caddr_t	val;
 		int	valsize;
 	} */ *uap;
 {
 
 	return (kern_setsockopt(td, uap->s, uap->level, uap->name,
 	    uap->val, UIO_USERSPACE, uap->valsize));
 }
 
 int
 kern_setsockopt(td, s, level, name, val, valseg, valsize)
 	struct thread *td;
 	int s;
 	int level;
 	int name;
 	void *val;
 	enum uio_seg valseg;
 	socklen_t valsize;
 {
 	int error;
 	struct socket *so;
 	struct file *fp;
 	struct sockopt sopt;
 
 	if (val == NULL && valsize != 0)
 		return (EFAULT);
 	if ((int)valsize < 0)
 		return (EINVAL);
 
 	sopt.sopt_dir = SOPT_SET;
 	sopt.sopt_level = level;
 	sopt.sopt_name = name;
 	sopt.sopt_val = val;
 	sopt.sopt_valsize = valsize;
 	switch (valseg) {
 	case UIO_USERSPACE:
 		sopt.sopt_td = td;
 		break;
 	case UIO_SYSSPACE:
 		sopt.sopt_td = NULL;
 		break;
 	default:
 		panic("kern_setsockopt called with bad valseg");
 	}
 
 	AUDIT_ARG_FD(s);
 	error = getsock_cap(td->td_proc->p_fd, s, CAP_SETSOCKOPT, &fp, NULL);
 	if (error == 0) {
 		so = fp->f_data;
 		error = sosetopt(so, &sopt);
 		fdrop(fp, td);
 	}
 	return(error);
 }
 
 /* ARGSUSED */
 int
 sys_getsockopt(td, uap)
 	struct thread *td;
 	struct getsockopt_args /* {
 		int	s;
 		int	level;
 		int	name;
 		void * __restrict	val;
 		socklen_t * __restrict avalsize;
 	} */ *uap;
 {
 	socklen_t valsize;
 	int	error;
 
 	if (uap->val) {
 		error = copyin(uap->avalsize, &valsize, sizeof (valsize));
 		if (error)
 			return (error);
 	}
 
 	error = kern_getsockopt(td, uap->s, uap->level, uap->name,
 	    uap->val, UIO_USERSPACE, &valsize);
 
 	if (error == 0)
 		error = copyout(&valsize, uap->avalsize, sizeof (valsize));
 	return (error);
 }
 
 /*
  * Kernel version of getsockopt.
  * optval can be a userland or userspace. optlen is always a kernel pointer.
  */
 int
 kern_getsockopt(td, s, level, name, val, valseg, valsize)
 	struct thread *td;
 	int s;
 	int level;
 	int name;
 	void *val;
 	enum uio_seg valseg;
 	socklen_t *valsize;
 {
 	int error;
 	struct  socket *so;
 	struct file *fp;
 	struct	sockopt sopt;
 
 	if (val == NULL)
 		*valsize = 0;
 	if ((int)*valsize < 0)
 		return (EINVAL);
 
 	sopt.sopt_dir = SOPT_GET;
 	sopt.sopt_level = level;
 	sopt.sopt_name = name;
 	sopt.sopt_val = val;
 	sopt.sopt_valsize = (size_t)*valsize; /* checked non-negative above */
 	switch (valseg) {
 	case UIO_USERSPACE:
 		sopt.sopt_td = td;
 		break;
 	case UIO_SYSSPACE:
 		sopt.sopt_td = NULL;
 		break;
 	default:
 		panic("kern_getsockopt called with bad valseg");
 	}
 
 	AUDIT_ARG_FD(s);
 	error = getsock_cap(td->td_proc->p_fd, s, CAP_GETSOCKOPT, &fp, NULL);
 	if (error == 0) {
 		so = fp->f_data;
 		error = sogetopt(so, &sopt);
 		*valsize = sopt.sopt_valsize;
 		fdrop(fp, td);
 	}
 	return (error);
 }
 
 /*
  * getsockname1() - Get socket name.
  */
 /* ARGSUSED */
 static int
 getsockname1(td, uap, compat)
 	struct thread *td;
 	struct getsockname_args /* {
 		int	fdes;
 		struct sockaddr * __restrict asa;
 		socklen_t * __restrict alen;
 	} */ *uap;
 	int compat;
 {
 	struct sockaddr *sa;
 	socklen_t len;
 	int error;
 
 	error = copyin(uap->alen, &len, sizeof(len));
 	if (error)
 		return (error);
 
 	error = kern_getsockname(td, uap->fdes, &sa, &len);
 	if (error)
 		return (error);
 
 	if (len != 0) {
 #ifdef COMPAT_OLDSOCK
 		if (compat)
 			((struct osockaddr *)sa)->sa_family = sa->sa_family;
 #endif
 		error = copyout(sa, uap->asa, (u_int)len);
 	}
 	free(sa, M_SONAME);
 	if (error == 0)
 		error = copyout(&len, uap->alen, sizeof(len));
 	return (error);
 }
 
 int
 kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
     socklen_t *alen)
 {
 	struct socket *so;
 	struct file *fp;
 	socklen_t len;
 	int error;
 
-	if (*alen < 0)
-		return (EINVAL);
-
 	AUDIT_ARG_FD(fd);
 	error = getsock_cap(td->td_proc->p_fd, fd, CAP_GETSOCKNAME, &fp, NULL);
 	if (error)
 		return (error);
 	so = fp->f_data;
 	*sa = NULL;
 	CURVNET_SET(so->so_vnet);
 	error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, sa);
 	CURVNET_RESTORE();
 	if (error)
 		goto bad;
 	if (*sa == NULL)
 		len = 0;
 	else
 		len = MIN(*alen, (*sa)->sa_len);
 	*alen = len;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(*sa);
 #endif
 bad:
 	fdrop(fp, td);
 	if (error && *sa) {
 		free(*sa, M_SONAME);
 		*sa = NULL;
 	}
 	return (error);
 }
 
 int
 sys_getsockname(td, uap)
 	struct thread *td;
 	struct getsockname_args *uap;
 {
 
 	return (getsockname1(td, uap, 0));
 }
 
 #ifdef COMPAT_OLDSOCK
 int
 ogetsockname(td, uap)
 	struct thread *td;
 	struct getsockname_args *uap;
 {
 
 	return (getsockname1(td, uap, 1));
 }
 #endif /* COMPAT_OLDSOCK */
 
 /*
  * getpeername1() - Get name of peer for connected socket.
  */
 /* ARGSUSED */
 static int
 getpeername1(td, uap, compat)
 	struct thread *td;
 	struct getpeername_args /* {
 		int	fdes;
 		struct sockaddr * __restrict	asa;
 		socklen_t * __restrict	alen;
 	} */ *uap;
 	int compat;
 {
 	struct sockaddr *sa;
 	socklen_t len;
 	int error;
 
 	error = copyin(uap->alen, &len, sizeof (len));
 	if (error)
 		return (error);
 
 	error = kern_getpeername(td, uap->fdes, &sa, &len);
 	if (error)
 		return (error);
 
 	if (len != 0) {
 #ifdef COMPAT_OLDSOCK
 		if (compat)
 			((struct osockaddr *)sa)->sa_family = sa->sa_family;
 #endif
 		error = copyout(sa, uap->asa, (u_int)len);
 	}
 	free(sa, M_SONAME);
 	if (error == 0)
 		error = copyout(&len, uap->alen, sizeof(len));
 	return (error);
 }
 
 int
 kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
     socklen_t *alen)
 {
 	struct socket *so;
 	struct file *fp;
 	socklen_t len;
 	int error;
-
-	if (*alen < 0)
-		return (EINVAL);
 
 	AUDIT_ARG_FD(fd);
 	error = getsock_cap(td->td_proc->p_fd, fd, CAP_GETPEERNAME, &fp, NULL);
 	if (error)
 		return (error);
 	so = fp->f_data;
 	if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
 		error = ENOTCONN;
 		goto done;
 	}
 	*sa = NULL;
 	CURVNET_SET(so->so_vnet);
 	error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, sa);
 	CURVNET_RESTORE();
 	if (error)
 		goto bad;
 	if (*sa == NULL)
 		len = 0;
 	else
 		len = MIN(*alen, (*sa)->sa_len);
 	*alen = len;
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(*sa);
 #endif
 bad:
 	if (error && *sa) {
 		free(*sa, M_SONAME);
 		*sa = NULL;
 	}
 done:
 	fdrop(fp, td);
 	return (error);
 }
 
 int
 sys_getpeername(td, uap)
 	struct thread *td;
 	struct getpeername_args *uap;
 {
 
 	return (getpeername1(td, uap, 0));
 }
 
 #ifdef COMPAT_OLDSOCK
 int
 ogetpeername(td, uap)
 	struct thread *td;
 	struct ogetpeername_args *uap;
 {
 
 	/* XXX uap should have type `getpeername_args *' to begin with. */
 	return (getpeername1(td, (struct getpeername_args *)uap, 1));
 }
 #endif /* COMPAT_OLDSOCK */
 
 int
 sockargs(mp, buf, buflen, type)
 	struct mbuf **mp;
 	caddr_t buf;
 	int buflen, type;
 {
 	struct sockaddr *sa;
 	struct mbuf *m;
 	int error;
 
 	if (buflen > MLEN) {
 #ifdef COMPAT_OLDSOCK
 		if (type == MT_SONAME && buflen <= 112)
 			buflen = MLEN;		/* unix domain compat. hack */
 		else
 #endif
 			if (buflen > MCLBYTES)
 				return (EINVAL);
 	}
 	m = m_get2(buflen, M_WAITOK, type, 0);
 	m->m_len = buflen;
 	error = copyin(buf, mtod(m, caddr_t), (u_int)buflen);
 	if (error)
 		(void) m_free(m);
 	else {
 		*mp = m;
 		if (type == MT_SONAME) {
 			sa = mtod(m, struct sockaddr *);
 
 #if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
 			if (sa->sa_family == 0 && sa->sa_len < AF_MAX)
 				sa->sa_family = sa->sa_len;
 #endif
 			sa->sa_len = buflen;
 		}
 	}
 	return (error);
 }
 
 int
 getsockaddr(namp, uaddr, len)
 	struct sockaddr **namp;
 	caddr_t uaddr;
 	size_t len;
 {
 	struct sockaddr *sa;
 	int error;
 
 	if (len > SOCK_MAXADDRLEN)
 		return (ENAMETOOLONG);
 	if (len < offsetof(struct sockaddr, sa_data[0]))
 		return (EINVAL);
 	sa = malloc(len, M_SONAME, M_WAITOK);
 	error = copyin(uaddr, sa, len);
 	if (error) {
 		free(sa, M_SONAME);
 	} else {
 #if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
 		if (sa->sa_family == 0 && sa->sa_len < AF_MAX)
 			sa->sa_family = sa->sa_len;
 #endif
 		sa->sa_len = len;
 		*namp = sa;
 	}
 	return (error);
 }
 
 #include 
 
 struct sendfile_sync {
 	struct mtx	mtx;
 	struct cv	cv;
 	unsigned	count;
 };
 
 /*
  * Detach mapped page and release resources back to the system.
  */
 void
 sf_buf_mext(void *addr, void *args)
 {
 	vm_page_t m;
 	struct sendfile_sync *sfs;
 
 	m = sf_buf_page(args);
 	sf_buf_free(args);
 	vm_page_lock(m);
 	vm_page_unwire(m, 0);
 	/*
 	 * Check for the object going away on us. This can
 	 * happen since we don't hold a reference to it.
 	 * If so, we're responsible for freeing the page.
 	 */
 	if (m->wire_count == 0 && m->object == NULL)
 		vm_page_free(m);
 	vm_page_unlock(m);
 	if (addr == NULL)
 		return;
 	sfs = addr;
 	mtx_lock(&sfs->mtx);
 	KASSERT(sfs->count> 0, ("Sendfile sync botchup count == 0"));
 	if (--sfs->count == 0)
 		cv_signal(&sfs->cv);
 	mtx_unlock(&sfs->mtx);
 }
 
 /*
  * sendfile(2)
  *
  * int sendfile(int fd, int s, off_t offset, size_t nbytes,
  *	 struct sf_hdtr *hdtr, off_t *sbytes, int flags)
  *
  * Send a file specified by 'fd' and starting at 'offset' to a socket
  * specified by 's'. Send only 'nbytes' of the file or until EOF if nbytes ==
  * 0.  Optionally add a header and/or trailer to the socket output.  If
  * specified, write the total number of bytes sent into *sbytes.
  */
 int
 sys_sendfile(struct thread *td, struct sendfile_args *uap)
 {
 
 	return (do_sendfile(td, uap, 0));
 }
 
 static int
 do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
 {
 	struct sf_hdtr hdtr;
 	struct uio *hdr_uio, *trl_uio;
 	int error;
 
 	hdr_uio = trl_uio = NULL;
 
 	if (uap->hdtr != NULL) {
 		error = copyin(uap->hdtr, &hdtr, sizeof(hdtr));
 		if (error)
 			goto out;
 		if (hdtr.headers != NULL) {
 			error = copyinuio(hdtr.headers, hdtr.hdr_cnt, &hdr_uio);
 			if (error)
 				goto out;
 		}
 		if (hdtr.trailers != NULL) {
 			error = copyinuio(hdtr.trailers, hdtr.trl_cnt, &trl_uio);
 			if (error)
 				goto out;
 
 		}
 	}
 
 	error = kern_sendfile(td, uap, hdr_uio, trl_uio, compat);
 out:
 	if (hdr_uio)
 		free(hdr_uio, M_IOV);
 	if (trl_uio)
 		free(trl_uio, M_IOV);
 	return (error);
 }
 
 #ifdef COMPAT_FREEBSD4
 int
 freebsd4_sendfile(struct thread *td, struct freebsd4_sendfile_args *uap)
 {
 	struct sendfile_args args;
 
 	args.fd = uap->fd;
 	args.s = uap->s;
 	args.offset = uap->offset;
 	args.nbytes = uap->nbytes;
 	args.hdtr = uap->hdtr;
 	args.sbytes = uap->sbytes;
 	args.flags = uap->flags;
 
 	return (do_sendfile(td, &args, 1));
 }
 #endif /* COMPAT_FREEBSD4 */
 
 int
 kern_sendfile(struct thread *td, struct sendfile_args *uap,
     struct uio *hdr_uio, struct uio *trl_uio, int compat)
 {
 	struct file *sock_fp;
 	struct vnode *vp;
 	struct vm_object *obj = NULL;
 	struct socket *so = NULL;
 	struct mbuf *m = NULL;
 	struct sf_buf *sf;
 	struct vm_page *pg;
 	off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0;
 	int error, hdrlen = 0, mnw = 0;
 	struct sendfile_sync *sfs = NULL;
 
 	/*
 	 * The file descriptor must be a regular file and have a
 	 * backing VM object.
 	 * File offset must be positive.  If it goes beyond EOF
 	 * we send only the header/trailer and no payload data.
 	 */
 	AUDIT_ARG_FD(uap->fd);
 	/*
 	 * sendfile(2) can start at any offset within a file so we require
 	 * CAP_READ+CAP_SEEK = CAP_PREAD.
 	 */
 	if ((error = fgetvp_read(td, uap->fd, CAP_PREAD, &vp)) != 0)
 		goto out;
 	vn_lock(vp, LK_SHARED | LK_RETRY);
 	if (vp->v_type == VREG) {
 		obj = vp->v_object;
 		if (obj != NULL) {
 			/*
 			 * Temporarily increase the backing VM
 			 * object's reference count so that a forced
 			 * reclamation of its vnode does not
 			 * immediately destroy it.
 			 */
 			VM_OBJECT_WLOCK(obj);
 			if ((obj->flags & OBJ_DEAD) == 0) {
 				vm_object_reference_locked(obj);
 				VM_OBJECT_WUNLOCK(obj);
 			} else {
 				VM_OBJECT_WUNLOCK(obj);
 				obj = NULL;
 			}
 		}
 	}
 	VOP_UNLOCK(vp, 0);
 	if (obj == NULL) {
 		error = EINVAL;
 		goto out;
 	}
 	if (uap->offset < 0) {
 		error = EINVAL;
 		goto out;
 	}
 
 	/*
 	 * The socket must be a stream socket and connected.
 	 * Remember if it a blocking or non-blocking socket.
 	 */
 	if ((error = getsock_cap(td->td_proc->p_fd, uap->s, CAP_SEND,
 	    &sock_fp, NULL)) != 0)
 		goto out;
 	so = sock_fp->f_data;
 	if (so->so_type != SOCK_STREAM) {
 		error = EINVAL;
 		goto out;
 	}
 	if ((so->so_state & SS_ISCONNECTED) == 0) {
 		error = ENOTCONN;
 		goto out;
 	}
 	/*
 	 * Do not wait on memory allocations but return ENOMEM for
 	 * caller to retry later.
 	 * XXX: Experimental.
 	 */
 	if (uap->flags & SF_MNOWAIT)
 		mnw = 1;
 
 	if (uap->flags & SF_SYNC) {
 		sfs = malloc(sizeof *sfs, M_TEMP, M_WAITOK | M_ZERO);
 		mtx_init(&sfs->mtx, "sendfile", NULL, MTX_DEF);
 		cv_init(&sfs->cv, "sendfile");
 	}
 
 #ifdef MAC
 	error = mac_socket_check_send(td->td_ucred, so);
 	if (error)
 		goto out;
 #endif
 
 	/* If headers are specified copy them into mbufs. */
 	if (hdr_uio != NULL) {
 		hdr_uio->uio_td = td;
 		hdr_uio->uio_rw = UIO_WRITE;
 		if (hdr_uio->uio_resid > 0) {
 			/*
 			 * In FBSD < 5.0 the nbytes to send also included
 			 * the header.  If compat is specified subtract the
 			 * header size from nbytes.
 			 */
 			if (compat) {
 				if (uap->nbytes > hdr_uio->uio_resid)
 					uap->nbytes -= hdr_uio->uio_resid;
 				else
 					uap->nbytes = 0;
 			}
 			m = m_uiotombuf(hdr_uio, (mnw ? M_NOWAIT : M_WAITOK),
 			    0, 0, 0);
 			if (m == NULL) {
 				error = mnw ? EAGAIN : ENOBUFS;
 				goto out;
 			}
 			hdrlen = m_length(m, NULL);
 		}
 	}
 
 	/*
 	 * Protect against multiple writers to the socket.
 	 *
 	 * XXXRW: Historically this has assumed non-interruptibility, so now
 	 * we implement that, but possibly shouldn't.
 	 */
 	(void)sblock(&so->so_snd, SBL_WAIT | SBL_NOINTR);
 
 	/*
 	 * Loop through the pages of the file, starting with the requested
 	 * offset. Get a file page (do I/O if necessary), map the file page
 	 * into an sf_buf, attach an mbuf header to the sf_buf, and queue
 	 * it on the socket.
 	 * This is done in two loops.  The inner loop turns as many pages
 	 * as it can, up to available socket buffer space, without blocking
 	 * into mbufs to have it bulk delivered into the socket send buffer.
 	 * The outer loop checks the state and available space of the socket
 	 * and takes care of the overall progress.
 	 */
 	for (off = uap->offset, rem = uap->nbytes; ; ) {
 		struct mbuf *mtail = NULL;
 		int loopbytes = 0;
 		int space = 0;
 		int done = 0;
 
 		/*
 		 * Check the socket state for ongoing connection,
 		 * no errors and space in socket buffer.
 		 * If space is low allow for the remainder of the
 		 * file to be processed if it fits the socket buffer.
 		 * Otherwise block in waiting for sufficient space
 		 * to proceed, or if the socket is nonblocking, return
 		 * to userland with EAGAIN while reporting how far
 		 * we've come.
 		 * We wait until the socket buffer has significant free
 		 * space to do bulk sends.  This makes good use of file
 		 * system read ahead and allows packet segmentation
 		 * offloading hardware to take over lots of work.  If
 		 * we were not careful here we would send off only one
 		 * sfbuf at a time.
 		 */
 		SOCKBUF_LOCK(&so->so_snd);
 		if (so->so_snd.sb_lowat < so->so_snd.sb_hiwat / 2)
 			so->so_snd.sb_lowat = so->so_snd.sb_hiwat / 2;
 retry_space:
 		if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
 			error = EPIPE;
 			SOCKBUF_UNLOCK(&so->so_snd);
 			goto done;
 		} else if (so->so_error) {
 			error = so->so_error;
 			so->so_error = 0;
 			SOCKBUF_UNLOCK(&so->so_snd);
 			goto done;
 		}
 		space = sbspace(&so->so_snd);
 		if (space < rem &&
 		    (space <= 0 ||
 		     space < so->so_snd.sb_lowat)) {
 			if (so->so_state & SS_NBIO) {
 				SOCKBUF_UNLOCK(&so->so_snd);
 				error = EAGAIN;
 				goto done;
 			}
 			/*
 			 * sbwait drops the lock while sleeping.
 			 * When we loop back to retry_space the
 			 * state may have changed and we retest
 			 * for it.
 			 */
 			error = sbwait(&so->so_snd);
 			/*
 			 * An error from sbwait usually indicates that we've
 			 * been interrupted by a signal. If we've sent anything
 			 * then return bytes sent, otherwise return the error.
 			 */
 			if (error) {
 				SOCKBUF_UNLOCK(&so->so_snd);
 				goto done;
 			}
 			goto retry_space;
 		}
 		SOCKBUF_UNLOCK(&so->so_snd);
 
 		/*
 		 * Reduce space in the socket buffer by the size of
 		 * the header mbuf chain.
 		 * hdrlen is set to 0 after the first loop.
 		 */
 		space -= hdrlen;
 
 		/*
 		 * Loop and construct maximum sized mbuf chain to be bulk
 		 * dumped into socket buffer.
 		 */
 		while (1) {
 			vm_pindex_t pindex;
 			vm_offset_t pgoff;
 			struct mbuf *m0;
 
 			VM_OBJECT_WLOCK(obj);
 			/*
 			 * Calculate the amount to transfer.
 			 * Not to exceed a page, the EOF,
 			 * or the passed in nbytes.
 			 */
 			pgoff = (vm_offset_t)(off & PAGE_MASK);
 			if (uap->nbytes)
 				rem = (uap->nbytes - fsbytes - loopbytes);
 			else
 				rem = obj->un_pager.vnp.vnp_size -
 				    uap->offset - fsbytes - loopbytes;
 			xfsize = omin(PAGE_SIZE - pgoff, rem);
 			xfsize = omin(space - loopbytes, xfsize);
 			if (xfsize <= 0) {
 				VM_OBJECT_WUNLOCK(obj);
 				done = 1;		/* all data sent */
 				break;
 			}
 
 			/*
 			 * We've already overfilled the socket.
 			 * Let the outer loop figure out how to handle it.
 			 */
 			if (space <= loopbytes) {
 				VM_OBJECT_WUNLOCK(obj);
 				done = 0;
 				break;
 			}
 
 			/*
 			 * Attempt to look up the page.  Allocate
 			 * if not found or wait and loop if busy.
 			 */
 			pindex = OFF_TO_IDX(off);
 			pg = vm_page_grab(obj, pindex, VM_ALLOC_NOBUSY |
 			    VM_ALLOC_NORMAL | VM_ALLOC_WIRED | VM_ALLOC_RETRY);
 
 			/*
 			 * Check if page is valid for what we need,
 			 * otherwise initiate I/O.
 			 * If we already turned some pages into mbufs,
 			 * send them off before we come here again and
 			 * block.
 			 */
 			if (pg->valid && vm_page_is_valid(pg, pgoff, xfsize))
 				VM_OBJECT_WUNLOCK(obj);
 			else if (m != NULL)
 				error = EAGAIN;	/* send what we already got */
 			else if (uap->flags & SF_NODISKIO)
 				error = EBUSY;
 			else {
 				int bsize;
 				ssize_t resid;
 
 				/*
 				 * Ensure that our page is still around
 				 * when the I/O completes.
 				 */
 				vm_page_io_start(pg);
 				VM_OBJECT_WUNLOCK(obj);
 
 				/*
 				 * Get the page from backing store.
 				 */
 				error = vn_lock(vp, LK_SHARED);
 				if (error != 0)
 					goto after_read;
 				bsize = vp->v_mount->mnt_stat.f_iosize;
 
 				/*
 				 * XXXMAC: Because we don't have fp->f_cred
 				 * here, we pass in NOCRED.  This is probably
 				 * wrong, but is consistent with our original
 				 * implementation.
 				 */
 				error = vn_rdwr(UIO_READ, vp, NULL, MAXBSIZE,
 				    trunc_page(off), UIO_NOCOPY, IO_NODELOCKED |
 				    IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT),
 				    td->td_ucred, NOCRED, &resid, td);
 				VOP_UNLOCK(vp, 0);
 			after_read:
 				VM_OBJECT_WLOCK(obj);
 				vm_page_io_finish(pg);
 				if (!error)
 					VM_OBJECT_WUNLOCK(obj);
 				mbstat.sf_iocnt++;
 			}
 			if (error) {
 				vm_page_lock(pg);
 				vm_page_unwire(pg, 0);
 				/*
 				 * See if anyone else might know about
 				 * this page.  If not and it is not valid,
 				 * then free it.
 				 */
 				if (pg->wire_count == 0 && pg->valid == 0 &&
 				    pg->busy == 0 && !(pg->oflags & VPO_BUSY))
 					vm_page_free(pg);
 				vm_page_unlock(pg);
 				VM_OBJECT_WUNLOCK(obj);
 				if (error == EAGAIN)
 					error = 0;	/* not a real error */
 				break;
 			}
 
 			/*
 			 * Get a sendfile buf.  When allocating the
 			 * first buffer for mbuf chain, we usually
 			 * wait as long as necessary, but this wait
 			 * can be interrupted.  For consequent
 			 * buffers, do not sleep, since several
 			 * threads might exhaust the buffers and then
 			 * deadlock.
 			 */
 			sf = sf_buf_alloc(pg, (mnw || m != NULL) ? SFB_NOWAIT :
 			    SFB_CATCH);
 			if (sf == NULL) {
 				mbstat.sf_allocfail++;
 				vm_page_lock(pg);
 				vm_page_unwire(pg, 0);
 				KASSERT(pg->object != NULL,
 				    ("kern_sendfile: object disappeared"));
 				vm_page_unlock(pg);
 				if (m == NULL)
 					error = (mnw ? EAGAIN : EINTR);
 				break;
 			}
 
 			/*
 			 * Get an mbuf and set it up as having
 			 * external storage.
 			 */
 			m0 = m_get((mnw ? M_NOWAIT : M_WAITOK), MT_DATA);
 			if (m0 == NULL) {
 				error = (mnw ? EAGAIN : ENOBUFS);
 				sf_buf_mext(NULL, sf);
 				break;
 			}
 			if (m_extadd(m0, (caddr_t )sf_buf_kva(sf), PAGE_SIZE,
 			    sf_buf_mext, sfs, sf, M_RDONLY, EXT_SFBUF,
 			    (mnw ? M_NOWAIT : M_WAITOK)) != 0) {
 				error = (mnw ? EAGAIN : ENOBUFS);
 				sf_buf_mext(NULL, sf);
 				m_freem(m0);
 				break;
 			}
 			m0->m_data = (char *)sf_buf_kva(sf) + pgoff;
 			m0->m_len = xfsize;
 
 			/* Append to mbuf chain. */
 			if (mtail != NULL)
 				mtail->m_next = m0;
 			else if (m != NULL)
 				m_last(m)->m_next = m0;
 			else
 				m = m0;
 			mtail = m0;
 
 			/* Keep track of bits processed. */
 			loopbytes += xfsize;
 			off += xfsize;
 
 			if (sfs != NULL) {
 				mtx_lock(&sfs->mtx);
 				sfs->count++;
 				mtx_unlock(&sfs->mtx);
 			}
 		}
 
 		/* Add the buffer chain to the socket buffer. */
 		if (m != NULL) {
 			int mlen, err;
 
 			mlen = m_length(m, NULL);
 			SOCKBUF_LOCK(&so->so_snd);
 			if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
 				error = EPIPE;
 				SOCKBUF_UNLOCK(&so->so_snd);
 				goto done;
 			}
 			SOCKBUF_UNLOCK(&so->so_snd);
 			CURVNET_SET(so->so_vnet);
 			/* Avoid error aliasing. */
 			err = (*so->so_proto->pr_usrreqs->pru_send)
 				    (so, 0, m, NULL, NULL, td);
 			CURVNET_RESTORE();
 			if (err == 0) {
 				/*
 				 * We need two counters to get the
 				 * file offset and nbytes to send
 				 * right:
 				 * - sbytes contains the total amount
 				 *   of bytes sent, including headers.
 				 * - fsbytes contains the total amount
 				 *   of bytes sent from the file.
 				 */
 				sbytes += mlen;
 				fsbytes += mlen;
 				if (hdrlen) {
 					fsbytes -= hdrlen;
 					hdrlen = 0;
 				}
 			} else if (error == 0)
 				error = err;
 			m = NULL;	/* pru_send always consumes */
 		}
 
 		/* Quit outer loop on error or when we're done. */
 		if (done)
 			break;
 		if (error)
 			goto done;
 	}
 
 	/*
 	 * Send trailers. Wimp out and use writev(2).
 	 */
 	if (trl_uio != NULL) {
 		sbunlock(&so->so_snd);
 		error = kern_writev(td, uap->s, trl_uio);
 		if (error == 0)
 			sbytes += td->td_retval[0];
 		goto out;
 	}
 
 done:
 	sbunlock(&so->so_snd);
 out:
 	/*
 	 * If there was no error we have to clear td->td_retval[0]
 	 * because it may have been set by writev.
 	 */
 	if (error == 0) {
 		td->td_retval[0] = 0;
 	}
 	if (uap->sbytes != NULL) {
 		copyout(&sbytes, uap->sbytes, sizeof(off_t));
 	}
 	if (obj != NULL)
 		vm_object_deallocate(obj);
 	if (vp != NULL)
 		vrele(vp);
 	if (so)
 		fdrop(sock_fp, td);
 	if (m)
 		m_freem(m);
 
 	if (sfs != NULL) {
 		mtx_lock(&sfs->mtx);
 		if (sfs->count != 0)
 			cv_wait(&sfs->cv, &sfs->mtx);
 		KASSERT(sfs->count == 0, ("sendfile sync still busy"));
 		cv_destroy(&sfs->cv);
 		mtx_destroy(&sfs->mtx);
 		free(sfs, M_TEMP);
 	}
 
 	if (error == ERESTART)
 		error = EINTR;
 
 	return (error);
 }
 
 /*
  * SCTP syscalls.
  * Functionality only compiled in if SCTP is defined in the kernel Makefile,
  * otherwise all return EOPNOTSUPP.
  * XXX: We should make this loadable one day.
  */
 int
 sys_sctp_peeloff(td, uap)
 	struct thread *td;
 	struct sctp_peeloff_args /* {
 		int	sd;
 		caddr_t	name;
 	} */ *uap;
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
 	struct file *nfp = NULL;
 	int error;
 	struct socket *head, *so;
 	int fd;
 	u_int fflag;
 
 	AUDIT_ARG_FD(uap->sd);
 	error = fgetsock(td, uap->sd, CAP_PEELOFF, &head, &fflag);
 	if (error)
 		goto done2;
 	if (head->so_proto->pr_protocol != IPPROTO_SCTP) {
 		error = EOPNOTSUPP;
 		goto done;
 	}
 	error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name);
 	if (error)
 		goto done;
 	/*
 	 * At this point we know we do have a assoc to pull
 	 * we proceed to get the fd setup. This may block
 	 * but that is ok.
 	 */
 
 	error = falloc(td, &nfp, &fd, 0);
 	if (error)
 		goto done;
 	td->td_retval[0] = fd;
 
 	CURVNET_SET(head->so_vnet);
 	so = sonewconn(head, SS_ISCONNECTED);
 	if (so == NULL) {
 		error = ENOMEM;
 		goto noconnection;
 	}
 	/*
 	 * Before changing the flags on the socket, we have to bump the
 	 * reference count.  Otherwise, if the protocol calls sofree(),
 	 * the socket will be released due to a zero refcount.
 	 */
         SOCK_LOCK(so);
         soref(so);                      /* file descriptor reference */
         SOCK_UNLOCK(so);
 
 	ACCEPT_LOCK();
 
 	TAILQ_REMOVE(&head->so_comp, so, so_list);
 	head->so_qlen--;
 	so->so_state |= (head->so_state & SS_NBIO);
 	so->so_state &= ~SS_NOFDREF;
 	so->so_qstate &= ~SQ_COMP;
 	so->so_head = NULL;
 	ACCEPT_UNLOCK();
 	finit(nfp, fflag, DTYPE_SOCKET, so, &socketops);
 	error = sctp_do_peeloff(head, so, (sctp_assoc_t)uap->name);
 	if (error)
 		goto noconnection;
 	if (head->so_sigio != NULL)
 		fsetown(fgetown(&head->so_sigio), &so->so_sigio);
 
 noconnection:
 	/*
 	 * close the new descriptor, assuming someone hasn't ripped it
 	 * out from under us.
 	 */
 	if (error)
 		fdclose(td->td_proc->p_fd, nfp, fd, td);
 
 	/*
 	 * Release explicitly held references before returning.
 	 */
 	CURVNET_RESTORE();
 done:
 	if (nfp != NULL)
 		fdrop(nfp, td);
 	fputsock(head);
 done2:
 	return (error);
 #else  /* SCTP */
 	return (EOPNOTSUPP);
 #endif /* SCTP */
 }
 
 int
 sys_sctp_generic_sendmsg (td, uap)
 	struct thread *td;
 	struct sctp_generic_sendmsg_args /* {
 		int sd,
 		caddr_t msg,
 		int mlen,
 		caddr_t to,
 		__socklen_t tolen,
 		struct sctp_sndrcvinfo *sinfo,
 		int flags
 	} */ *uap;
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
 	struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
 	struct socket *so;
 	struct file *fp = NULL;
 	int error = 0, len;
 	struct sockaddr *to = NULL;
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
 	struct uio auio;
 	struct iovec iov[1];
 	cap_rights_t rights;
 
 	if (uap->sinfo) {
 		error = copyin(uap->sinfo, &sinfo, sizeof (sinfo));
 		if (error)
 			return (error);
 		u_sinfo = &sinfo;
 	}
 
 	rights = CAP_SEND;
 	if (uap->tolen) {
 		error = getsockaddr(&to, uap->to, uap->tolen);
 		if (error) {
 			to = NULL;
 			goto sctp_bad2;
 		}
 		rights |= CAP_CONNECT;
 	}
 
 	AUDIT_ARG_FD(uap->sd);
 	error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL);
 	if (error)
 		goto sctp_bad;
 #ifdef KTRACE
 	if (to && (KTRPOINT(td, KTR_STRUCT)))
 		ktrsockaddr(to);
 #endif
 
 	iov[0].iov_base = uap->msg;
 	iov[0].iov_len = uap->mlen;
 
 	so = (struct socket *)fp->f_data;
 	if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
 		error = EOPNOTSUPP;
 		goto sctp_bad;
 	}
 #ifdef MAC
 	error = mac_socket_check_send(td->td_ucred, so);
 	if (error)
 		goto sctp_bad;
 #endif /* MAC */
 
 	auio.uio_iov =  iov;
 	auio.uio_iovcnt = 1;
 	auio.uio_segflg = UIO_USERSPACE;
 	auio.uio_rw = UIO_WRITE;
 	auio.uio_td = td;
 	auio.uio_offset = 0;			/* XXX */
 	auio.uio_resid = 0;
 	len = auio.uio_resid = uap->mlen;
 	CURVNET_SET(so->so_vnet);
 	error = sctp_lower_sosend(so, to, &auio,
 		    (struct mbuf *)NULL, (struct mbuf *)NULL,
 		    uap->flags, u_sinfo, td);
 	CURVNET_RESTORE();
 	if (error) {
 		if (auio.uio_resid != len && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 		/* Generation of SIGPIPE can be controlled per socket. */
 		if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) &&
 		    !(uap->flags & MSG_NOSIGNAL)) {
 			PROC_LOCK(td->td_proc);
 			tdsignal(td, SIGPIPE);
 			PROC_UNLOCK(td->td_proc);
 		}
 	}
 	if (error == 0)
 		td->td_retval[0] = len - auio.uio_resid;
 #ifdef KTRACE
 	if (ktruio != NULL) {
 		ktruio->uio_resid = td->td_retval[0];
 		ktrgenio(uap->sd, UIO_WRITE, ktruio, error);
 	}
 #endif /* KTRACE */
 sctp_bad:
 	if (fp)
 		fdrop(fp, td);
 sctp_bad2:
 	if (to)
 		free(to, M_SONAME);
 	return (error);
 #else  /* SCTP */
 	return (EOPNOTSUPP);
 #endif /* SCTP */
 }
 
 int
 sys_sctp_generic_sendmsg_iov(td, uap)
 	struct thread *td;
 	struct sctp_generic_sendmsg_iov_args /* {
 		int sd,
 		struct iovec *iov,
 		int iovlen,
 		caddr_t to,
 		__socklen_t tolen,
 		struct sctp_sndrcvinfo *sinfo,
 		int flags
 	} */ *uap;
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
 	struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
 	struct socket *so;
 	struct file *fp = NULL;
 	int error=0, i;
 	ssize_t len;
 	struct sockaddr *to = NULL;
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
 	struct uio auio;
 	struct iovec *iov, *tiov;
 	cap_rights_t rights;
 
 	if (uap->sinfo) {
 		error = copyin(uap->sinfo, &sinfo, sizeof (sinfo));
 		if (error)
 			return (error);
 		u_sinfo = &sinfo;
 	}
 	rights = CAP_SEND;
 	if (uap->tolen) {
 		error = getsockaddr(&to, uap->to, uap->tolen);
 		if (error) {
 			to = NULL;
 			goto sctp_bad2;
 		}
 		rights |= CAP_CONNECT;
 	}
 
 	AUDIT_ARG_FD(uap->sd);
 	error = getsock_cap(td->td_proc->p_fd, uap->sd, rights, &fp, NULL);
 	if (error)
 		goto sctp_bad1;
 
 #ifdef COMPAT_FREEBSD32
 	if (SV_CURPROC_FLAG(SV_ILP32))
 		error = freebsd32_copyiniov((struct iovec32 *)uap->iov,
 		    uap->iovlen, &iov, EMSGSIZE);
 	else
 #endif
 		error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE);
 	if (error)
 		goto sctp_bad1;
 #ifdef KTRACE
 	if (to && (KTRPOINT(td, KTR_STRUCT)))
 		ktrsockaddr(to);
 #endif
 
 	so = (struct socket *)fp->f_data;
 	if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
 		error = EOPNOTSUPP;
 		goto sctp_bad;
 	}
 #ifdef MAC
 	error = mac_socket_check_send(td->td_ucred, so);
 	if (error)
 		goto sctp_bad;
 #endif /* MAC */
 
 	auio.uio_iov = iov;
 	auio.uio_iovcnt = uap->iovlen;
 	auio.uio_segflg = UIO_USERSPACE;
 	auio.uio_rw = UIO_WRITE;
 	auio.uio_td = td;
 	auio.uio_offset = 0;			/* XXX */
 	auio.uio_resid = 0;
 	tiov = iov;
 	for (i = 0; i iovlen; i++, tiov++) {
 		if ((auio.uio_resid += tiov->iov_len) < 0) {
 			error = EINVAL;
 			goto sctp_bad;
 		}
 	}
 	len = auio.uio_resid;
 	CURVNET_SET(so->so_vnet);
 	error = sctp_lower_sosend(so, to, &auio,
 		    (struct mbuf *)NULL, (struct mbuf *)NULL,
 		    uap->flags, u_sinfo, td);
 	CURVNET_RESTORE();
 	if (error) {
 		if (auio.uio_resid != len && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 		/* Generation of SIGPIPE can be controlled per socket */
 		if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) &&
 		    !(uap->flags & MSG_NOSIGNAL)) {
 			PROC_LOCK(td->td_proc);
 			tdsignal(td, SIGPIPE);
 			PROC_UNLOCK(td->td_proc);
 		}
 	}
 	if (error == 0)
 		td->td_retval[0] = len - auio.uio_resid;
 #ifdef KTRACE
 	if (ktruio != NULL) {
 		ktruio->uio_resid = td->td_retval[0];
 		ktrgenio(uap->sd, UIO_WRITE, ktruio, error);
 	}
 #endif /* KTRACE */
 sctp_bad:
 	free(iov, M_IOV);
 sctp_bad1:
 	if (fp)
 		fdrop(fp, td);
 sctp_bad2:
 	if (to)
 		free(to, M_SONAME);
 	return (error);
 #else  /* SCTP */
 	return (EOPNOTSUPP);
 #endif /* SCTP */
 }
 
 int
 sys_sctp_generic_recvmsg(td, uap)
 	struct thread *td;
 	struct sctp_generic_recvmsg_args /* {
 		int sd,
 		struct iovec *iov,
 		int iovlen,
 		struct sockaddr *from,
 		__socklen_t *fromlenaddr,
 		struct sctp_sndrcvinfo *sinfo,
 		int *msg_flags
 	} */ *uap;
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
 	uint8_t sockbufstore[256];
 	struct uio auio;
 	struct iovec *iov, *tiov;
 	struct sctp_sndrcvinfo sinfo;
 	struct socket *so;
 	struct file *fp = NULL;
 	struct sockaddr *fromsa;
 	int fromlen;
 	ssize_t len;
 	int i, msg_flags;
 	int error = 0;
 #ifdef KTRACE
 	struct uio *ktruio = NULL;
 #endif
 
 	AUDIT_ARG_FD(uap->sd);
 	error = getsock_cap(td->td_proc->p_fd, uap->sd, CAP_RECV, &fp, NULL);
 	if (error) {
 		return (error);
 	}
 #ifdef COMPAT_FREEBSD32
 	if (SV_CURPROC_FLAG(SV_ILP32))
 		error = freebsd32_copyiniov((struct iovec32 *)uap->iov,
 		    uap->iovlen, &iov, EMSGSIZE);
 	else
 #endif
 		error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE);
 	if (error)
 		goto out1;
 
 	so = fp->f_data;
 	if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
 		error = EOPNOTSUPP;
 		goto out;
 	}
 #ifdef MAC
 	error = mac_socket_check_receive(td->td_ucred, so);
 	if (error) {
 		goto out;
 	}
 #endif /* MAC */
 
 	if (uap->fromlenaddr) {
 		error = copyin(uap->fromlenaddr,
 		    &fromlen, sizeof (fromlen));
 		if (error) {
 			goto out;
 		}
 	} else {
 		fromlen = 0;
 	}
 	if (uap->msg_flags) {
 		error = copyin(uap->msg_flags, &msg_flags, sizeof (int));
 		if (error) {
 			goto out;
 		}
 	} else {
 		msg_flags = 0;
 	}
 	auio.uio_iov = iov;
 	auio.uio_iovcnt = uap->iovlen;
 	auio.uio_segflg = UIO_USERSPACE;
 	auio.uio_rw = UIO_READ;
 	auio.uio_td = td;
 	auio.uio_offset = 0;			/* XXX */
 	auio.uio_resid = 0;
 	tiov = iov;
 	for (i = 0; i iovlen; i++, tiov++) {
 		if ((auio.uio_resid += tiov->iov_len) < 0) {
 			error = EINVAL;
 			goto out;
 		}
 	}
 	len = auio.uio_resid;
 	fromsa = (struct sockaddr *)sockbufstore;
 
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_GENIO))
 		ktruio = cloneuio(&auio);
 #endif /* KTRACE */
 	memset(&sinfo, 0, sizeof(struct sctp_sndrcvinfo));
 	CURVNET_SET(so->so_vnet);
 	error = sctp_sorecvmsg(so, &auio, (struct mbuf **)NULL,
 		    fromsa, fromlen, &msg_flags,
 		    (struct sctp_sndrcvinfo *)&sinfo, 1);
 	CURVNET_RESTORE();
 	if (error) {
 		if (auio.uio_resid != len && (error == ERESTART ||
 		    error == EINTR || error == EWOULDBLOCK))
 			error = 0;
 	} else {
 		if (uap->sinfo)
 			error = copyout(&sinfo, uap->sinfo, sizeof (sinfo));
 	}
 #ifdef KTRACE
 	if (ktruio != NULL) {
 		ktruio->uio_resid = len - auio.uio_resid;
 		ktrgenio(uap->sd, UIO_READ, ktruio, error);
 	}
 #endif /* KTRACE */
 	if (error)
 		goto out;
 	td->td_retval[0] = len - auio.uio_resid;
 
 	if (fromlen && uap->from) {
 		len = fromlen;
 		if (len <= 0 || fromsa == 0)
 			len = 0;
 		else {
 			len = MIN(len, fromsa->sa_len);
 			error = copyout(fromsa, uap->from, (size_t)len);
 			if (error)
 				goto out;
 		}
 		error = copyout(&len, uap->fromlenaddr, sizeof (socklen_t));
 		if (error) {
 			goto out;
 		}
 	}
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_STRUCT))
 		ktrsockaddr(fromsa);
 #endif
 	if (uap->msg_flags) {
 		error = copyout(&msg_flags, uap->msg_flags, sizeof (int));
 		if (error) {
 			goto out;
 		}
 	}
 out:
 	free(iov, M_IOV);
 out1:
 	if (fp)
 		fdrop(fp, td);
 
 	return (error);
 #else  /* SCTP */
 	return (EOPNOTSUPP);
 #endif /* SCTP */
 }
Index: user/attilio/vmcontention/sys/modules/acpi/acpi/Makefile
===================================================================
--- user/attilio/vmcontention/sys/modules/acpi/acpi/Makefile	(revision 249698)
+++ user/attilio/vmcontention/sys/modules/acpi/acpi/Makefile	(revision 249699)
@@ -1,131 +1,131 @@
 # $FreeBSD$
 
 .if !defined(FORCE_BUILD)
 .error "The ACPI module is deprecated, set FORCE_BUILD to force it"
 .endif
 
 .if ${MACHINE_CPUARCH} == "ia64"
 .error "ACPI can only be compiled into the kernel on the ia64 platform"
 .endif
 
 .if ${MACHINE} != "amd64" && ${MACHINE} != "i386"
 .error "The ACPI module is only for amd64 and i386"
 .endif
 
 .PATH:	${.CURDIR}/../../../contrib/dev/acpica/components/debugger \
 	${.CURDIR}/../../../contrib/dev/acpica/components/disassembler \
 	${.CURDIR}/../../../contrib/dev/acpica/components/dispatcher \
 	${.CURDIR}/../../../contrib/dev/acpica/components/events \
 	${.CURDIR}/../../../contrib/dev/acpica/components/executer \
 	${.CURDIR}/../../../contrib/dev/acpica/components/hardware \
 	${.CURDIR}/../../../contrib/dev/acpica/components/namespace \
 	${.CURDIR}/../../../contrib/dev/acpica/components/parser \
 	${.CURDIR}/../../../contrib/dev/acpica/components/resources \
 	${.CURDIR}/../../../contrib/dev/acpica/components/tables \
 	${.CURDIR}/../../../contrib/dev/acpica/components/utilities \
 	${.CURDIR}/../../../pci \
 	${.CURDIR}/../../../dev/acpica \
 	${.CURDIR}/../../../dev/acpica/Osd \
 	${.CURDIR}/../../../${MACHINE_CPUARCH}/acpica \
 	${.CURDIR}/../../../x86/acpica
 
 KMOD=	acpi
 
 # ACPI CA sources
 SRCS+=	dbcmds.c dbconvert.c dbdisply.c dbexec.c dbfileio.c dbhistry.c
 SRCS+=	dbinput.c dbmethod.c dbnames.c dbstats.c dbutils.c dbxface.c
 SRCS+=	dmbuffer.c dmdeferred.c dmnames.c dmopcode.c dmobject.c dmresrc.c
 SRCS+=	dmresrcl.c dmresrcl2.c dmresrcs.c dmutils.c dmwalk.c
 SRCS+=	dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c dsmthdat.c
 SRCS+=	dsobject.c dsopcode.c dsutils.c dswexec.c dswload.c dswload2.c
 SRCS+=	dswscope.c dswstate.c
 SRCS+=	evevent.c evglock.c evgpe.c evgpeblk.c evgpeinit.c evgpeutil.c
 SRCS+=	evhandler.c evmisc.c evregion.c evrgnini.c evsci.c evxface.c
 SRCS+=	evxfevnt.c evxfgpe.c evxfregn.c
 SRCS+=	exconfig.c exconvrt.c excreate.c exdebug.c exdump.c exfield.c
 SRCS+=	exfldio.c exmisc.c exmutex.c exnames.c exoparg1.c exoparg2.c
 SRCS+=	exoparg3.c exoparg6.c exprep.c exregion.c exresnte.c exresolv.c
 SRCS+=	exresop.c exstore.c exstoren.c exstorob.c exsystem.c exutils.c
 SRCS+=	hwacpi.c hwesleep.c hwgpe.c hwpci.c hwregs.c hwsleep.c hwtimer.c
 SRCS+=	hwvalid.c hwxface.c hwxfsleep.c
-SRCS+=	nsaccess.c nsalloc.c nsconvert.c nsdump.c nseval.c nsinit.c nsload.c
-SRCS+=	nsnames.c nsobject.c nsparse.c nspredef.c nsprepkg.c nsrepair.c
-SRCS+=	nsrepair2.c nssearch.c nsutils.c nswalk.c nsxfeval.c nsxfname.c
-SRCS+=	nsxfobj.c
+SRCS+=	nsaccess.c nsalloc.c nsarguments.c nsconvert.c nsdump.c nseval.c
+SRCS+=	nsinit.c nsload.c nsnames.c nsobject.c nsparse.c nspredef.c nsprepkg.c
+SRCS+=	nsrepair.c nsrepair2.c nssearch.c nsutils.c nswalk.c nsxfeval.c
+SRCS+=	nsxfname.c nsxfobj.c
 SRCS+=	psargs.c psloop.c psobject.c psopcode.c psopinfo.c psparse.c
 SRCS+=	psscope.c pstree.c psutils.c pswalk.c psxface.c
 SRCS+=	rsaddr.c rscalc.c rscreate.c rsdump.c rsdumpinfo.c rsinfo.c rsio.c
 SRCS+=	rsirq.c rslist.c rsmemory.c rsmisc.c rsserial.c rsutils.c rsxface.c
 SRCS+=	tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c tbxfload.c tbxfroot.c
 SRCS+=	utaddress.c utalloc.c utcache.c utcopy.c utdebug.c utdecode.c
 SRCS+=	utdelete.c uteval.c utexcep.c utglobal.c utids.c utinit.c utlock.c
-SRCS+=	utmath.c utmisc.c utmutex.c utobject.c utosi.c utownerid.c utresrc.c
-SRCS+=	utstate.c utstring.c utxface.c utxferror.c utxfinit.c
+SRCS+=	utmath.c utmisc.c utmutex.c utobject.c utosi.c utownerid.c utpredef.c
+SRCS+=	utresrc.c utstate.c utstring.c utxface.c utxferror.c utxfinit.c
 #SRCS+=	utxfmutex.c
 
 # OSPM layer and core hardware drivers
 SRCS+=	acpi.c acpi_button.c acpi_isab.c acpi_package.c acpi_pci.c acpi_pcib.c
 SRCS+=	acpi_pcib_acpi.c acpi_pcib_pci.c acpi_powerres.c acpi_quirk.c
 SRCS+=	acpi_resource.c acpi_timer.c acpi_pci_link.c acpi_thermal.c
 
 # ACPI hardware drivers, mostly used for mobile systems.
 SRCS+=	acpi_acad.c acpi_battery.c acpi_cmbat.c acpi_cpu.c acpi_ec.c
 SRCS+=	acpi_hpet.c acpi_lid.c acpi_perf.c acpi_smbat.c acpi_throttle.c
 
 # OSD layer
 SRCS+=	OsdDebug.c
 SRCS+=	OsdHardware.c OsdInterrupt.c OsdMemory.c OsdSchedule.c OsdStream.c
 SRCS+=	OsdSynch.c OsdTable.c OsdEnvironment.c
 SRCS+=	opt_acpi.h opt_bus.h opt_ddb.h acpi_if.h acpi_quirks.h bus_if.h
 SRCS+=	cpufreq_if.h device_if.h isa_if.h pci_if.h pcib_if.h
 
 # XXX ACPI should not depend on the following headers but this is currently
 # needed for the build of assym.s.
 # This obviously needs a better and more structural fix.
 SRCS+=	opt_kstack_pages.h opt_nfs.h opt_apic.h opt_compat.h opt_hwpmc_hooks.h
 
 .if !defined(KERNBUILDDIR)
 .if KTR
 CFLAGS+=-DKTR
 .endif
 .if SMP
 CFLAGS+=-DSMP
 .endif
 .if ACPI_MAX_TASKS
 CFLAGS+=-DACPI_MAX_TASKS=${ACPI_MAX_TASKS}
 .endif
 .if ACPI_MAX_THREADS
 CFLAGS+=-DACPI_MAX_THREADS=${ACPI_MAX_THREADS}
 .endif
 .if ACPI_DEBUG
 CFLAGS+=-DACPI_DEBUG
 opt_ddb.h: Makefile
 	echo "#define DDB 1" > ${.TARGET}
 .else
 opt_ddb.h: Makefile
 	echo -n > ${.TARGET}
 .endif
 .endif
 
 # Machine-specific code such as sleep/wakeup
 SRCS+=	acpi_apm.c acpi_machdep.c acpi_wakecode.h acpi_wakedata.h acpi_wakeup.c
 SRCS+=	assym.s madt.c
 CLEANFILES+=acpi_wakecode.bin acpi_wakecode.h acpi_wakecode.o acpi_wakedata.h
 
 SRCS+=	opt_global.h
 
 .include 
 
 acpi_wakecode.o: acpi_wakecode.S assym.s
 	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} ${CLANG_NO_IAS} \
 	    ${WERROR} ${.IMPSRC}
 acpi_wakecode.bin: acpi_wakecode.o
 	objcopy -S -O binary acpi_wakecode.o ${.TARGET}
 acpi_wakecode.h: acpi_wakecode.bin
 	file2c -sx 'static char wakecode[] = {' '};' < acpi_wakecode.bin > \
 	    ${.TARGET}
 acpi_wakedata.h: acpi_wakecode.o
 	${NM} -n --defined-only acpi_wakecode.o | \
 	    while read offset dummy what; do \
 	    echo "#define	$${what}	0x$${offset}"; \
 	    done > ${.TARGET}
Index: user/attilio/vmcontention/sys/sys/chio.h
===================================================================
--- user/attilio/vmcontention/sys/sys/chio.h	(revision 249698)
+++ user/attilio/vmcontention/sys/sys/chio.h	(revision 249699)
@@ -1,227 +1,278 @@
 /*-
  * Copyright (c) 1996 Jason R. Thorpe 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgements:
  *	This product includes software developed by Jason R. Thorpe
  *	for And Communications, http://www.and.com/
  * 4. The name of the author may not be used to endorse or promote products
  *    derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #ifndef	_SYS_CHIO_H_
 #define	_SYS_CHIO_H_
 
 #ifndef _KERNEL
 #include 
 #endif
 #include 
 
 /*
  * Element types.  Used as "to" and "from" type indicators in move
  * and exchange operations.
  *
  * Note that code in sys/scsi/ch.c relies on these values (uses them
  * as offsets in an array, and other evil), so don't muck with them
  * unless you know what you're doing.
  */
 #define CHET_MT		0	/* medium transport (picker) */
 #define CHET_ST		1	/* storage transport (slot) */
 #define CHET_IE		2	/* import/export (portal) */
 #define CHET_DT		3	/* data transfer (drive) */
 #define CHET_MAX	CHET_DT
 
 /*
  * Maximum length of a volume identification string
  */
 #define CH_VOLTAG_MAXLEN	32
 
 /*
  * Structure used to execute a MOVE MEDIUM command.
  */
 struct changer_move {
 	u_int16_t	cm_fromtype;	/* element type to move from */
 	u_int16_t	cm_fromunit;	/* logical unit of from element */
 	u_int16_t	cm_totype;	/* element type to move to */
 	u_int16_t	cm_tounit;	/* logical unit of to element */
 	u_int16_t	cm_flags;	/* misc. flags */
 };
 
 /* cm_flags */
 #define CM_INVERT	0x01	/* invert media */
 
 /*
  * Structure used to execute an EXCHANGE MEDIUM command.  In an
  * exchange operation, the following steps occur:
  *
  *	- media from source is moved to first destination.
  *
  *	- media previously occupying first destination is moved
  *	  to the second destination.
  *
  * The second destination may or may not be the same as the source.
  * In the case of a simple exchange, the source and second destination
  * are the same.
  */
 struct changer_exchange {
 	u_int16_t	ce_srctype;	/* element type of source */
 	u_int16_t	ce_srcunit;	/* logical unit of source */
 	u_int16_t	ce_fdsttype;	/* element type of first destination */
 	u_int16_t	ce_fdstunit;	/* logical unit of first destination */
 	u_int16_t	ce_sdsttype;	/* element type of second destination */
 	u_int16_t	ce_sdstunit;	/* logical unit of second destination */
 	u_int16_t	ce_flags;	/* misc. flags */
 };
 
 /* ce_flags */
 #define CE_INVERT1	0x01	/* invert media 1 */
 #define CE_INVERT2	0x02	/* invert media 2 */
 
 /*
  * Structure used to execute a POSITION TO ELEMENT command.  This
  * moves the current picker in front of the specified element.
  */
 struct changer_position {
 	u_int16_t	cp_type;	/* element type */
 	u_int16_t	cp_unit;	/* logical unit of element */
 	u_int16_t	cp_flags;	/* misc. flags */
 };
 
 /* cp_flags */
 #define CP_INVERT	0x01	/* invert picker */
 
 /*
  * Data returned by CHIOGPARAMS.
  */
 struct changer_params {
 	u_int16_t	cp_npickers;	/* number of pickers */
 	u_int16_t	cp_nslots;	/* number of slots */
 	u_int16_t	cp_nportals;	/* number of import/export portals */
 	u_int16_t	cp_ndrives;	/* number of drives */
 };
 
 /*
  * Command used to get element status.
  */
 
 struct changer_voltag {
 	u_char		cv_volid[CH_VOLTAG_MAXLEN+1];
 	u_int16_t	cv_serial;
 };
 
 typedef struct changer_voltag changer_voltag_t;
 
 /*
  * Flags definitions for ces_status
  * Not all flags have meaning for all element types.
  */
 typedef enum {
 	CES_STATUS_FULL	  = 0x001,	/* element is full */
 	CES_STATUS_IMPEXP = 0x002,	/* media deposited by operator */
 	CES_STATUS_EXCEPT = 0x004,	/* element in abnormal state */
 	CES_PICKER_MASK	  = 0x005,	/* flags valid for pickers */
 	CES_STATUS_ACCESS = 0x008,	/* media accessible by picker */
 	CES_SLOT_MASK	  = 0x00c,	/* flags valid for slots */
 	CES_DRIVE_MASK	  = 0x00c,	/* flags valid for drives */
 	CES_STATUS_EXENAB = 0x010,	/* element supports exporting */
 	CES_STATUS_INENAB = 0x020,	/* element supports importing */
 	CES_PORTAL_MASK	  = 0x03f,	/* flags valid for portals */
 	CES_INVERT	  = 0x040,	/* invert bit */
 	CES_SOURCE_VALID  = 0x080,	/* source address (ces_source) valid */
 	CES_SCSIID_VALID  = 0x100,	/* ces_scsi_id is valid */
-	CES_LUN_VALID	  = 0x200	/* ces_scsi_lun is valid */
+	CES_LUN_VALID	  = 0x200,	/* ces_scsi_lun is valid */
+	CES_PIV		  = 0x400	/* ces_protocol_id is valid */
 } ces_status_flags;
 
 struct changer_element_status {
 	u_int8_t		ces_type;	  /* element type */
 	u_int16_t		ces_addr;	  /* logical element address */
 	u_int16_t		ces_int_addr;	  /* changer element address */
 	ces_status_flags	ces_flags;	  /* 
 						   * see CESTATUS definitions
 						   * below 
 						   */ 
 	u_int8_t		ces_sensecode;	  /* 
 						   * additional sense
 						   * code for element */
 	u_int8_t		ces_sensequal;	  /*
 						   * additional sense
 						   * code qualifier 
 						   */
 	u_int8_t		ces_source_type;  /* 
 						   * element type of
 						   * source address 
 						   */
 	u_int16_t		ces_source_addr;  /* 
 						   * source address of medium
 						   */
 	changer_voltag_t     	ces_pvoltag;	  /* primary volume tag */
 	changer_voltag_t	ces_avoltag;	  /* alternate volume tag */
 	u_int8_t		ces_scsi_id;	  /* SCSI id of element */
 	u_int8_t		ces_scsi_lun;	  /* SCSI lun of element */
+
+	/*
+	 * Data members for SMC3 and later versions
+	 */
+	u_int8_t		ces_medium_type;
+#define	CES_MEDIUM_TYPE_UNKNOWN		0	/* Medium type unspecified */
+#define	CES_MEDIUM_TYPE_DATA		1	/* Data medium */
+#define	CES_MEDIUM_TYPE_CLEANING	2	/* Cleaning medium */
+#define	CES_MEDIUM_TYPE_DIAGNOSTIC	3	/* Diagnostic medium */
+#define	CES_MEDIUM_TYPE_WORM		4	/* WORM medium */
+#define	CES_MEDIUM_TYPE_MICROCODE	5	/* Microcode image medium */
+
+	u_int8_t		ces_protocol_id;
+#define	CES_PROTOCOL_ID_FCP_4	0	/* Fiber channel */
+#define	CES_PROTOCOL_ID_SPI_5	1	/* Parallel SCSI */
+#define	CES_PROTOCOL_ID_SSA_S3P	2	/* SSA */
+#define	CES_PROTOCOL_ID_SBP_3	3	/* IEEE 1394 */
+#define	CES_PROTOCOL_ID_SRP	4	/* SCSI Remote DMA */
+#define	CES_PROTOCOL_ID_ISCSI	5	/* iSCSI */
+#define	CES_PROTOCOL_ID_SPL	6	/* SAS */
+#define	CES_PROTOCOL_ID_ADT_2	7	/* Automation/Drive Interface */
+#define	CES_PROTOCOL_ID_ACS_2	8	/* ATA */
+
+	u_int8_t		ces_assoc;
+#define	CES_ASSOC_LOGICAL_UNIT	0
+#define	CES_ASSOC_TARGET_PORT	1
+#define	CES_ASSOC_TARGET_DEVICE	2
+
+	u_int8_t		ces_designator_type;
+#define	CES_DESIGNATOR_TYPE_VENDOR_SPECIFIC	0
+#define	CES_DESIGNATOR_TYPE_T10_VENDOR_ID	1
+#define	CES_DESIGNATOR_TYPE_EUI_64		2
+#define	CES_DESIGNATOR_TYPE_NAA			3
+#define	CES_DESIGNATOR_TYPE_TARGET_PORT_ID	4
+#define	CES_DESIGNATOR_TYPE_TARGET_PORT_GRP	5
+#define	CES_DESIGNATOR_TYPE_LOGICAL_UNIT_GRP	6
+#define	CES_DESIGNATOR_TYPE_MD5_LOGICAL_UNIT_ID	7
+#define	CES_DESIGNATOR_TYPE_SCSI_NAME_STRING	8
+
+	u_int8_t		ces_code_set;
+#define	CES_CODE_SET_RESERVED	0
+#define	CES_CODE_SET_BINARY	1
+#define	CES_CODE_SET_ASCII	2
+#define	CES_CODE_SET_UTF_8	3
+
+	u_int8_t		ces_designator_length;
+
+#define	CES_MAX_DESIGNATOR_LENGTH (1 << 8)
+	u_int8_t		ces_designator[CES_MAX_DESIGNATOR_LENGTH + 1];
 };
 
 struct changer_element_status_request {
 	u_int16_t			cesr_element_type;
 	u_int16_t			cesr_element_base;
 	u_int16_t			cesr_element_count;
 
 	u_int16_t			cesr_flags;
-#define CESR_VOLTAGS	0x01
+#define	CESR_VOLTAGS	0x01
 
 	struct changer_element_status	*cesr_element_status;
 };
 
 
 struct changer_set_voltag_request {
 	u_int16_t		csvr_type;
 	u_int16_t		csvr_addr;
 
 	u_int16_t		csvr_flags;
-#define CSVR_MODE_MASK		0x0f	/* mode mask, acceptable modes below: */
+#define	CSVR_MODE_MASK		0x0f	/* mode mask, acceptable modes below: */
 #define	CSVR_MODE_SET		0x00	/* set volume tag if not set */
-#define CSVR_MODE_REPLACE	0x01	/* unconditionally replace volume tag */
-#define CSVR_MODE_CLEAR		0x02	/* clear volume tag */
+#define	CSVR_MODE_REPLACE	0x01	/* unconditionally replace volume tag */
+#define	CSVR_MODE_CLEAR		0x02	/* clear volume tag */
 
-#define CSVR_ALTERNATE		0x10	/* set to work with alternate voltag */
+#define	CSVR_ALTERNATE		0x10	/* set to work with alternate voltag */
 
 	changer_voltag_t     	csvr_voltag;
 };
 
 
-#define CESTATUS_BITS	\
+#define	CESTATUS_BITS	\
 	"\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
 
-#define CHIOMOVE	_IOW('c', 0x01, struct changer_move)
-#define CHIOEXCHANGE	_IOW('c', 0x02, struct changer_exchange)
-#define CHIOPOSITION	_IOW('c', 0x03, struct changer_position)
-#define CHIOGPICKER	_IOR('c', 0x04, int)
-#define CHIOSPICKER	_IOW('c', 0x05, int)
-#define CHIOGPARAMS	_IOR('c', 0x06, struct changer_params)
-#define CHIOIELEM	_IOW('c', 0x07, u_int32_t)
-#define CHIOGSTATUS	_IOW('c', 0x08, struct changer_element_status_request)
-#define CHIOSETVOLTAG	_IOW('c', 0x09, struct changer_set_voltag_request)
+#define	CHIOMOVE	_IOW('c', 0x01, struct changer_move)
+#define	CHIOEXCHANGE	_IOW('c', 0x02, struct changer_exchange)
+#define	CHIOPOSITION	_IOW('c', 0x03, struct changer_position)
+#define	CHIOGPICKER	_IOR('c', 0x04, int)
+#define	CHIOSPICKER	_IOW('c', 0x05, int)
+#define	CHIOGPARAMS	_IOR('c', 0x06, struct changer_params)
+#define	CHIOIELEM	_IOW('c', 0x07, u_int32_t)
+#define	OCHIOGSTATUS	_IOW('c', 0x08, struct changer_element_status_request)
+#define	CHIOSETVOLTAG	_IOW('c', 0x09, struct changer_set_voltag_request)
+#define	CHIOGSTATUS	_IOW('c', 0x0A, struct changer_element_status_request)
 
 #endif /* !_SYS_CHIO_H_ */
Index: user/attilio/vmcontention/sys
===================================================================
--- user/attilio/vmcontention/sys	(revision 249698)
+++ user/attilio/vmcontention/sys	(revision 249699)

Property changes on: user/attilio/vmcontention/sys
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head/sys:r249647-249698
Index: user/attilio/vmcontention/usr.bin/ar/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/ar/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/ar/Makefile	(revision 249699)
@@ -1,19 +1,21 @@
 # $FreeBSD$
 
 .include 
 
 PROG=	ar
 SRCS=	ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h
 
 DPADD=	${LIBARCHIVE} ${LIBELF} ${LIBZ}
 LDADD=	-larchive -lelf -lz
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 CFLAGS+=-I. -I${.CURDIR}
 
 .if ${MK_SHARED_TOOLCHAIN} == "no"
 NO_SHARED?=	yes
 .endif
 LINKS=	${BINDIR}/ar ${BINDIR}/ranlib
 MLINKS= ar.1 ranlib.1
 
 .include 
Index: user/attilio/vmcontention/usr.bin/bc/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/bc/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/bc/Makefile	(revision 249699)
@@ -1,14 +1,16 @@
 #	$FreeBSD$
 #	$OpenBSD: Makefile,v 1.4 2006/06/30 19:02:28 otto Exp $
 
 PROG=	bc
 SRCS=	bc.y scan.l
 CFLAGS+= -I. -I${.CURDIR}
 
 DPADD=	${LIBEDIT} ${LIBTERMCAP}
 LDADD=	-ledit -ltermcap
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 FILES+=	bc.library
 FILESDIR=${SHAREDIR}/misc
 
 .include 
Index: user/attilio/vmcontention/usr.bin/bzip2recover/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/bzip2recover/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/bzip2recover/Makefile	(revision 249699)
@@ -1,9 +1,11 @@
 # $FreeBSD$
 
 BZ2DIR=	${.CURDIR}/../../contrib/bzip2
 .PATH: ${BZ2DIR}
 
 PROG=	bzip2recover
 NO_MAN=
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
Index: user/attilio/vmcontention/usr.bin/find/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/find/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/find/Makefile	(revision 249699)
@@ -1,9 +1,11 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
 PROG=	find
 SRCS=	find.c function.c ls.c main.c misc.c operator.c option.c \
 	getdate.y
 YFLAGS=
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
Index: user/attilio/vmcontention/usr.bin/gcore/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/gcore/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/gcore/Makefile	(revision 249699)
@@ -1,11 +1,11 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
 PROG=	gcore
 SRCS=	elfcore.c gcore.c
 DPADD=	${LIBUTIL}
-LDADD=	-lutil
+LDADD=	-lsbuf -lutil
 
 WARNS?=	1
 
 .include 
Index: user/attilio/vmcontention/usr.bin/gcore/elfcore.c
===================================================================
--- user/attilio/vmcontention/usr.bin/gcore/elfcore.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/gcore/elfcore.c	(revision 249699)
@@ -1,534 +1,705 @@
 /*-
  * Copyright (c) 2007 Sandvine Incorporated
  * Copyright (c) 1998 John D. Polstra
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "extern.h"
 
 /*
  * Code for generating ELF core dumps.
  */
 
 typedef void (*segment_callback)(vm_map_entry_t, void *);
 
 /* Closure for cb_put_phdr(). */
 struct phdr_closure {
 	Elf_Phdr *phdr;		/* Program header to fill in */
 	Elf_Off offset;		/* Offset of segment in core file */
 };
 
 /* Closure for cb_size_segment(). */
 struct sseg_closure {
 	int count;		/* Count of writable segments. */
 	size_t size;		/* Total size of all writable segments. */
 };
 
+typedef void* (*notefunc_t)(void *, size_t *);
+
 static void cb_put_phdr(vm_map_entry_t, void *);
 static void cb_size_segment(vm_map_entry_t, void *);
 static void each_writable_segment(vm_map_entry_t, segment_callback,
     void *closure);
 static void elf_detach(void);	/* atexit() handler. */
-static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t *, int numsegs);
-static void elf_putnote(void *dst, size_t *off, const char *name, int type,
-    const void *desc, size_t descsz);
+static void *elf_note_fpregset(void *, size_t *);
+static void *elf_note_prpsinfo(void *, size_t *);
+static void *elf_note_prstatus(void *, size_t *);
+static void *elf_note_thrmisc(void *, size_t *);
+static void *elf_note_procstat_auxv(void *, size_t *);
+static void *elf_note_procstat_files(void *, size_t *);
+static void *elf_note_procstat_groups(void *, size_t *);
+static void *elf_note_procstat_osrel(void *, size_t *);
+static void *elf_note_procstat_proc(void *, size_t *);
+static void *elf_note_procstat_psstrings(void *, size_t *);
+static void *elf_note_procstat_rlimit(void *, size_t *);
+static void *elf_note_procstat_umask(void *, size_t *);
+static void *elf_note_procstat_vmmap(void *, size_t *);
+static void elf_puthdr(pid_t, vm_map_entry_t, void *, size_t, size_t, size_t,
+    int);
+static void elf_putnote(int, notefunc_t, void *, struct sbuf *);
+static void elf_putnotes(pid_t, struct sbuf *, size_t *);
 static void freemap(vm_map_entry_t);
 static vm_map_entry_t readmap(pid_t);
+static void *procstat_sysctl(void *, int, size_t, size_t *sizep);
 
 static pid_t g_pid;		/* Pid being dumped, global for elf_detach */
 
 static int
 elf_ident(int efd, pid_t pid __unused, char *binfile __unused)
 {
 	Elf_Ehdr hdr;
 	int cnt;
 
 	cnt = read(efd, &hdr, sizeof(hdr));
 	if (cnt != sizeof(hdr))
 		return (0);
 	if (IS_ELF(hdr))
 		return (1);
 	return (0);
 }
 
 static void
 elf_detach(void)
 {
 
 	if (g_pid != 0)
 		ptrace(PT_DETACH, g_pid, (caddr_t)1, 0);
 }
 
 /*
  * Write an ELF coredump for the given pid to the given fd.
  */
 static void
 elf_coredump(int efd __unused, int fd, pid_t pid)
 {
 	vm_map_entry_t map;
 	struct sseg_closure seginfo;
+	struct sbuf *sb;
 	void *hdr;
-	size_t hdrsize;
+	size_t hdrsize, notesz, segoff;
+	ssize_t n, old_len;
 	Elf_Phdr *php;
 	int i;
 
 	/* Attach to process to dump. */
 	g_pid = pid;
 	if (atexit(elf_detach) != 0)
 		err(1, "atexit");
 	errno = 0;
 	ptrace(PT_ATTACH, pid, NULL, 0);
 	if (errno)
 		err(1, "PT_ATTACH");
 	if (waitpid(pid, NULL, 0) == -1)
 		err(1, "waitpid");
 
 	/* Get the program's memory map. */
 	map = readmap(pid);
 
 	/* Size the program segments. */
 	seginfo.count = 0;
 	seginfo.size = 0;
 	each_writable_segment(map, cb_size_segment, &seginfo);
 
 	/*
-	 * Calculate the size of the core file header area by making
-	 * a dry run of generating it.  Nothing is written, but the
-	 * size is calculated.
+	 * Build the header and the notes using sbuf and write to the file.
 	 */
-	hdrsize = 0;
-	elf_puthdr(pid, map, NULL, &hdrsize, seginfo.count);
-
-	/*
-	 * Allocate memory for building the header, fill it up,
-	 * and write it out.
-	 */
-	if ((hdr = calloc(1, hdrsize)) == NULL)
-		errx(1, "out of memory");
-
+	sb = sbuf_new_auto();
+	hdrsize = sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * (1 + seginfo.count);
+	/* Start header + notes section. */
+	sbuf_start_section(sb, NULL);
+	/* Make empty header subsection. */
+	sbuf_start_section(sb, &old_len);
+	sbuf_putc(sb, 0);
+	sbuf_end_section(sb, old_len, hdrsize, 0);
+	/* Put notes. */
+	elf_putnotes(pid, sb, ¬esz);
+	/* Align up to a page boundary for the program segments. */
+	sbuf_end_section(sb, -1, PAGE_SIZE, 0);
+	if (sbuf_finish(sb) != 0)
+		err(1, "sbuf_finish");
+	hdr = sbuf_data(sb);
+	segoff = sbuf_len(sb);
 	/* Fill in the header. */
-	hdrsize = 0;
-	elf_puthdr(pid, map, hdr, &hdrsize, seginfo.count);
+	elf_puthdr(pid, map, hdr, hdrsize, notesz, segoff, seginfo.count);
 
-	/* Write it to the core file. */
-	if (write(fd, hdr, hdrsize) == -1)
+	n = write(fd, hdr, segoff);
+	if (n == -1)
 		err(1, "write");
+	if (n < segoff)
+              errx(1, "short write");
 
 	/* Write the contents of all of the writable segments. */
 	php = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr)) + 1;
 	for (i = 0;  i < seginfo.count;  i++) {
 		struct ptrace_io_desc iorequest;
 		uintmax_t nleft = php->p_filesz;
 
 		iorequest.piod_op = PIOD_READ_D;
 		iorequest.piod_offs = (caddr_t)php->p_vaddr;
 		while (nleft > 0) {
 			char buf[8*1024];
 			size_t nwant;
 			ssize_t ngot;
 
 			if (nleft > sizeof(buf))
 				nwant = sizeof buf;
 			else
 				nwant = nleft;
 			iorequest.piod_addr = buf;
 			iorequest.piod_len = nwant;
 			ptrace(PT_IO, pid, (caddr_t)&iorequest, 0);
 			ngot = iorequest.piod_len;
 			if ((size_t)ngot < nwant)
 				errx(1, "short read wanted %zu, got %zd",
 				    nwant, ngot);
 			ngot = write(fd, buf, nwant);
 			if (ngot == -1)
 				err(1, "write of segment %d failed", i);
 			if ((size_t)ngot != nwant)
 				errx(1, "short write");
 			nleft -= nwant;
 			iorequest.piod_offs += ngot;
 		}
 		php++;
 	}
-	free(hdr);
+	sbuf_delete(sb);
 	freemap(map);
 }
 
 /*
  * A callback for each_writable_segment() to write out the segment's
  * program header entry.
  */
 static void
 cb_put_phdr(vm_map_entry_t entry, void *closure)
 {
 	struct phdr_closure *phc = (struct phdr_closure *)closure;
 	Elf_Phdr *phdr = phc->phdr;
 
 	phc->offset = round_page(phc->offset);
 
 	phdr->p_type = PT_LOAD;
 	phdr->p_offset = phc->offset;
 	phdr->p_vaddr = entry->start;
 	phdr->p_paddr = 0;
 	phdr->p_filesz = phdr->p_memsz = entry->end - entry->start;
 	phdr->p_align = PAGE_SIZE;
 	phdr->p_flags = 0;
 	if (entry->protection & VM_PROT_READ)
 		phdr->p_flags |= PF_R;
 	if (entry->protection & VM_PROT_WRITE)
 		phdr->p_flags |= PF_W;
 	if (entry->protection & VM_PROT_EXECUTE)
 		phdr->p_flags |= PF_X;
 
 	phc->offset += phdr->p_filesz;
 	phc->phdr++;
 }
 
 /*
  * A callback for each_writable_segment() to gather information about
  * the number of segments and their total size.
  */
 static void
 cb_size_segment(vm_map_entry_t entry, void *closure)
 {
 	struct sseg_closure *ssc = (struct sseg_closure *)closure;
 
 	ssc->count++;
 	ssc->size += entry->end - entry->start;
 }
 
 /*
  * For each segment in the given memory map, call the given function
  * with a pointer to the map entry and some arbitrary caller-supplied
  * data.
  */
 static void
 each_writable_segment(vm_map_entry_t map, segment_callback func, void *closure)
 {
 	vm_map_entry_t entry;
 
 	for (entry = map;  entry != NULL;  entry = entry->next)
 		(*func)(entry, closure);
 }
 
 static void
-elf_getstatus(pid_t pid, prpsinfo_t *psinfo)
+elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep)
 {
-	struct kinfo_proc kobj;
-	int name[4];
-	size_t len;
-
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_PID;
-	name[3] = pid;
-
-	len = sizeof(kobj);
-	if (sysctl(name, 4, &kobj, &len, NULL, 0) == -1)
-		err(1, "error accessing kern.proc.pid.%u sysctl", pid);
-	if (kobj.ki_pid != pid)
-		err(1, "error accessing kern.proc.pid.%u sysctl datas", pid);
-	strncpy(psinfo->pr_fname, kobj.ki_comm, MAXCOMLEN);
-	strncpy(psinfo->pr_psargs, psinfo->pr_fname, PRARGSZ);
-}
-
-/*
- * Generate the ELF coredump header into the buffer at "dst".  "dst" may
- * be NULL, in which case the header is sized but not actually generated.
- */
-static void
-elf_puthdr(pid_t pid, vm_map_entry_t map, void *dst, size_t *off, int numsegs)
-{
-	struct ptrace_lwpinfo lwpinfo;
-	struct {
-		prstatus_t status;
-		prfpregset_t fpregset;
-		prpsinfo_t psinfo;
-		thrmisc_t thrmisc;
-	} *tempdata;
-	size_t ehoff;
-	size_t phoff;
-	size_t noteoff;
-	size_t notesz;
-	size_t threads;
 	lwpid_t *tids;
+	size_t threads, old_len;
+	ssize_t size;
 	int i;
 
-	prstatus_t *status;
-	prfpregset_t *fpregset;
-	prpsinfo_t *psinfo;
-	thrmisc_t *thrmisc;
-
-	ehoff = *off;
-	*off += sizeof(Elf_Ehdr);
-
-	phoff = *off;
-	*off += (numsegs + 1) * sizeof(Elf_Phdr);
-
-	noteoff = *off;
-
-	if (dst != NULL) {
-		if ((tempdata = calloc(1, sizeof(*tempdata))) == NULL)
-			errx(1, "out of memory");
-		status = &tempdata->status;
-		fpregset = &tempdata->fpregset;
-		psinfo = &tempdata->psinfo;
-		thrmisc = &tempdata->thrmisc;
-	} else {
-		tempdata = NULL;
-		status = NULL;
-		fpregset = NULL;
-		psinfo = NULL;
-		thrmisc = NULL;
-	}
-
 	errno = 0;
 	threads = ptrace(PT_GETNUMLWPS, pid, NULL, 0);
 	if (errno)
 		err(1, "PT_GETNUMLWPS");
+	tids = malloc(threads * sizeof(*tids));
+	if (tids == NULL)
+		errx(1, "out of memory");
+	errno = 0;
+	ptrace(PT_GETLWPLIST, pid, (void *)tids, threads);
+	if (errno)
+		err(1, "PT_GETLWPLIST");
 
-	if (dst != NULL) {
-		psinfo->pr_version = PRPSINFO_VERSION;
-		psinfo->pr_psinfosz = sizeof(prpsinfo_t);
-		elf_getstatus(pid, psinfo);
+	sbuf_start_section(sb, &old_len);
+	elf_putnote(NT_PRPSINFO, elf_note_prpsinfo, &pid, sb);
 
-	}
-	elf_putnote(dst, off, "FreeBSD", NT_PRPSINFO, psinfo,
-	    sizeof *psinfo);
-
-	if (dst != NULL) {
-		tids = malloc(threads * sizeof(*tids));
-		if (tids == NULL)
-			errx(1, "out of memory");
-		errno = 0;
-		ptrace(PT_GETLWPLIST, pid, (void *)tids, threads);
-		if (errno)
-			err(1, "PT_GETLWPLIST");
-	}
 	for (i = 0; i < threads; ++i) {
-		if (dst != NULL) {
-			status->pr_version = PRSTATUS_VERSION;
-			status->pr_statussz = sizeof(prstatus_t);
-			status->pr_gregsetsz = sizeof(gregset_t);
-			status->pr_fpregsetsz = sizeof(fpregset_t);
-			status->pr_osreldate = __FreeBSD_version;
-			status->pr_pid = tids[i];
-
-			ptrace(PT_GETREGS, tids[i], (void *)&status->pr_reg, 0);
-			ptrace(PT_GETFPREGS, tids[i], (void *)fpregset, 0);
-			ptrace(PT_LWPINFO, tids[i], (void *)&lwpinfo,
-			    sizeof(lwpinfo));
-			memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad));
-			strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname);
-		}
-		elf_putnote(dst, off, "FreeBSD", NT_PRSTATUS, status,
-		    sizeof *status);
-		elf_putnote(dst, off, "FreeBSD", NT_FPREGSET, fpregset,
-		    sizeof *fpregset);
-		elf_putnote(dst, off, "FreeBSD", NT_THRMISC, thrmisc,
-		    sizeof *thrmisc);
+		elf_putnote(NT_PRSTATUS, elf_note_prstatus, tids + i, sb);
+		elf_putnote(NT_FPREGSET, elf_note_fpregset, tids + i, sb);
+		elf_putnote(NT_THRMISC, elf_note_thrmisc, tids + i, sb);
 	}
 
-	notesz = *off - noteoff;
+	elf_putnote(NT_PROCSTAT_PROC, elf_note_procstat_proc, &pid, sb);
+	elf_putnote(NT_PROCSTAT_FILES, elf_note_procstat_files, &pid, sb);
+	elf_putnote(NT_PROCSTAT_VMMAP, elf_note_procstat_vmmap, &pid, sb);
+	elf_putnote(NT_PROCSTAT_GROUPS, elf_note_procstat_groups, &pid, sb);
+	elf_putnote(NT_PROCSTAT_UMASK, elf_note_procstat_umask, &pid, sb);
+	elf_putnote(NT_PROCSTAT_RLIMIT, elf_note_procstat_rlimit, &pid, sb);
+	elf_putnote(NT_PROCSTAT_OSREL, elf_note_procstat_osrel, &pid, sb);
+	elf_putnote(NT_PROCSTAT_PSSTRINGS, elf_note_procstat_psstrings, &pid,
+	    sb);
+	elf_putnote(NT_PROCSTAT_AUXV, elf_note_procstat_auxv, &pid, sb);
 
-	if (dst != NULL) {
-		free(tids);
-		free(tempdata);
-	}
-
-	/* Align up to a page boundary for the program segments. */
-	*off = round_page(*off);
-
-	if (dst != NULL) {
-		Elf_Ehdr *ehdr;
-		Elf_Phdr *phdr;
-		struct phdr_closure phc;
-
-		/*
-		 * Fill in the ELF header.
-		 */
-		ehdr = (Elf_Ehdr *)((char *)dst + ehoff);
-		ehdr->e_ident[EI_MAG0] = ELFMAG0;
-		ehdr->e_ident[EI_MAG1] = ELFMAG1;
-		ehdr->e_ident[EI_MAG2] = ELFMAG2;
-		ehdr->e_ident[EI_MAG3] = ELFMAG3;
-		ehdr->e_ident[EI_CLASS] = ELF_CLASS;
-		ehdr->e_ident[EI_DATA] = ELF_DATA;
-		ehdr->e_ident[EI_VERSION] = EV_CURRENT;
-		ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
-		ehdr->e_ident[EI_ABIVERSION] = 0;
-		ehdr->e_ident[EI_PAD] = 0;
-		ehdr->e_type = ET_CORE;
-		ehdr->e_machine = ELF_ARCH;
-		ehdr->e_version = EV_CURRENT;
-		ehdr->e_entry = 0;
-		ehdr->e_phoff = phoff;
-		ehdr->e_flags = 0;
-		ehdr->e_ehsize = sizeof(Elf_Ehdr);
-		ehdr->e_phentsize = sizeof(Elf_Phdr);
-		ehdr->e_phnum = numsegs + 1;
-		ehdr->e_shentsize = sizeof(Elf_Shdr);
-		ehdr->e_shnum = 0;
-		ehdr->e_shstrndx = SHN_UNDEF;
-
-		/*
-		 * Fill in the program header entries.
-		 */
-		phdr = (Elf_Phdr *)((char *)dst + phoff);
-
-		/* The note segment. */
-		phdr->p_type = PT_NOTE;
-		phdr->p_offset = noteoff;
-		phdr->p_vaddr = 0;
-		phdr->p_paddr = 0;
-		phdr->p_filesz = notesz;
-		phdr->p_memsz = 0;
-		phdr->p_flags = 0;
-		phdr->p_align = 0;
-		phdr++;
-
-		/* All the writable segments from the program. */
-		phc.phdr = phdr;
-		phc.offset = *off;
-		each_writable_segment(map, cb_put_phdr, &phc);
-	}
+	size = sbuf_end_section(sb, old_len, 1, 0);
+	if (size == -1)
+		err(1, "sbuf_end_section");
+	free(tids);
+	*sizep = size;
 }
 
 /*
- * Emit one note section to "dst", or just size it if "dst" is NULL.
+ * Emit one note section to sbuf.
  */
 static void
-elf_putnote(void *dst, size_t *off, const char *name, int type,
-    const void *desc, size_t descsz)
+elf_putnote(int type, notefunc_t notefunc, void *arg, struct sbuf *sb)
 {
 	Elf_Note note;
+	size_t descsz;
+	ssize_t old_len;
+	void *desc;
 
-	note.n_namesz = strlen(name) + 1;
+	desc = notefunc(arg, &descsz);
+	note.n_namesz = 8; /* strlen("FreeBSD") + 1 */
 	note.n_descsz = descsz;
 	note.n_type = type;
-	if (dst != NULL)
-		bcopy(¬e, (char *)dst + *off, sizeof note);
-	*off += sizeof note;
-	if (dst != NULL)
-		bcopy(name, (char *)dst + *off, note.n_namesz);
-	*off += roundup2(note.n_namesz, sizeof(Elf_Size));
-	if (dst != NULL)
-		bcopy(desc, (char *)dst + *off, note.n_descsz);
-	*off += roundup2(note.n_descsz, sizeof(Elf_Size));
+
+	sbuf_bcat(sb, ¬e, sizeof(note));
+	sbuf_start_section(sb, &old_len);
+	sbuf_bcat(sb, "FreeBSD", note.n_namesz);
+	sbuf_end_section(sb, old_len, sizeof(Elf32_Size), 0);
+	if (descsz == 0)
+		return;
+	sbuf_start_section(sb, &old_len);
+	sbuf_bcat(sb, desc, descsz);
+	sbuf_end_section(sb, old_len, sizeof(Elf32_Size), 0);
+	free(desc);
 }
 
 /*
+ * Generate the ELF coredump header.
+ */
+static void
+elf_puthdr(pid_t pid, vm_map_entry_t map, void *hdr, size_t hdrsize,
+    size_t notesz, size_t segoff, int numsegs)
+{
+	Elf_Ehdr *ehdr;
+	Elf_Phdr *phdr;
+	struct phdr_closure phc;
+
+	ehdr = (Elf_Ehdr *)hdr;
+	phdr = (Elf_Phdr *)((char *)hdr + sizeof(Elf_Ehdr));
+
+	ehdr->e_ident[EI_MAG0] = ELFMAG0;
+	ehdr->e_ident[EI_MAG1] = ELFMAG1;
+	ehdr->e_ident[EI_MAG2] = ELFMAG2;
+	ehdr->e_ident[EI_MAG3] = ELFMAG3;
+	ehdr->e_ident[EI_CLASS] = ELF_CLASS;
+	ehdr->e_ident[EI_DATA] = ELF_DATA;
+	ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+	ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+	ehdr->e_ident[EI_ABIVERSION] = 0;
+	ehdr->e_ident[EI_PAD] = 0;
+	ehdr->e_type = ET_CORE;
+	ehdr->e_machine = ELF_ARCH;
+	ehdr->e_version = EV_CURRENT;
+	ehdr->e_entry = 0;
+	ehdr->e_phoff = sizeof(Elf_Ehdr);
+	ehdr->e_flags = 0;
+	ehdr->e_ehsize = sizeof(Elf_Ehdr);
+	ehdr->e_phentsize = sizeof(Elf_Phdr);
+	ehdr->e_phnum = numsegs + 1;
+	ehdr->e_shentsize = sizeof(Elf_Shdr);
+	ehdr->e_shnum = 0;
+	ehdr->e_shstrndx = SHN_UNDEF;
+
+	/*
+	 * Fill in the program header entries.
+	 */
+
+	/* The note segement. */
+	phdr->p_type = PT_NOTE;
+	phdr->p_offset = hdrsize;
+	phdr->p_vaddr = 0;
+	phdr->p_paddr = 0;
+	phdr->p_filesz = notesz;
+	phdr->p_memsz = 0;
+	phdr->p_flags = PF_R;
+	phdr->p_align = sizeof(Elf32_Size);
+	phdr++;
+
+	/* All the writable segments from the program. */
+	phc.phdr = phdr;
+	phc.offset = segoff;
+	each_writable_segment(map, cb_put_phdr, &phc);
+}
+
+/*
  * Free the memory map.
  */
 static void
 freemap(vm_map_entry_t map)
 {
 
 	while (map != NULL) {
 		vm_map_entry_t next = map->next;
 		free(map);
 		map = next;
 	}
 }
 
 /*
  * Read the process's memory map using kinfo_getvmmap(), and return a list of
  * VM map entries.  Only the non-device read/writable segments are
  * returned.  The map entries in the list aren't fully filled in; only
  * the items we need are present.
  */
 static vm_map_entry_t
 readmap(pid_t pid)
 {
 	vm_map_entry_t ent, *linkp, map;
 	struct kinfo_vmentry *vmentl, *kve;
 	int i, nitems;
 
 	vmentl = kinfo_getvmmap(pid, &nitems);
 	if (vmentl == NULL)
 		err(1, "cannot retrieve mappings for %u process", pid);
 
 	map = NULL;
 	linkp = ↦
 	for (i = 0; i < nitems; i++) {
 		kve = &vmentl[i];
 
 		/*
 		 * Ignore 'malformed' segments or ones representing memory
 		 * mapping with MAP_NOCORE on.
 		 * If the 'full' support is disabled, just dump the most
 		 * meaningful data segments.
 		 */
 		if ((kve->kve_protection & KVME_PROT_READ) == 0 ||
 		    (kve->kve_flags & KVME_FLAG_NOCOREDUMP) != 0 ||
 		    kve->kve_type == KVME_TYPE_DEAD ||
 		    kve->kve_type == KVME_TYPE_UNKNOWN ||
 		    ((pflags & PFLAGS_FULL) == 0 &&
 		    kve->kve_type != KVME_TYPE_DEFAULT &&
 		    kve->kve_type != KVME_TYPE_VNODE &&
 		    kve->kve_type != KVME_TYPE_SWAP))
 			continue;
 
 		ent = calloc(1, sizeof(*ent));
 		if (ent == NULL)
 			errx(1, "out of memory");
 		ent->start = (vm_offset_t)kve->kve_start;
 		ent->end = (vm_offset_t)kve->kve_end;
 		ent->protection = VM_PROT_READ | VM_PROT_WRITE;
 		if ((kve->kve_protection & KVME_PROT_EXEC) != 0)
 			ent->protection |= VM_PROT_EXECUTE;
 
 		*linkp = ent;
 		linkp = &ent->next;
 	}
 	free(vmentl);
 	return (map);
+}
+
+/*
+ * Miscellaneous note out functions.
+ */
+
+static void *
+elf_note_prpsinfo(void *arg, size_t *sizep)
+{
+	pid_t pid;
+	prpsinfo_t *psinfo;
+	struct kinfo_proc kip;
+	size_t len;
+	int name[4];
+
+	pid = *(pid_t *)arg;
+	psinfo = calloc(1, sizeof(*psinfo));
+	if (psinfo == NULL)
+		errx(1, "out of memory");
+	psinfo->pr_version = PRPSINFO_VERSION;
+	psinfo->pr_psinfosz = sizeof(prpsinfo_t);
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_PID;
+	name[3] = pid;
+	len = sizeof(kip);
+	if (sysctl(name, 4, &kip, &len, NULL, 0) == -1)
+		err(1, "kern.proc.pid.%u", pid);
+	if (kip.ki_pid != pid)
+		err(1, "kern.proc.pid.%u", pid);
+	strncpy(psinfo->pr_fname, kip.ki_comm, MAXCOMLEN);
+	strncpy(psinfo->pr_psargs, psinfo->pr_fname, PRARGSZ);
+
+	*sizep = sizeof(*psinfo);
+	return (psinfo);
+}
+
+static void *
+elf_note_prstatus(void *arg, size_t *sizep)
+{
+	lwpid_t tid;
+	prstatus_t *status;
+
+	tid = *(lwpid_t *)arg;
+	status = calloc(1, sizeof(*status));
+	if (status == NULL)
+		errx(1, "out of memory");
+	status->pr_version = PRSTATUS_VERSION;
+	status->pr_statussz = sizeof(prstatus_t);
+	status->pr_gregsetsz = sizeof(gregset_t);
+	status->pr_fpregsetsz = sizeof(fpregset_t);
+	status->pr_osreldate = __FreeBSD_version;
+	status->pr_pid = tid;
+	ptrace(PT_GETREGS, tid, (void *)&status->pr_reg, 0);
+
+	*sizep = sizeof(*status);
+	return (status);
+}
+
+static void *
+elf_note_fpregset(void *arg, size_t *sizep)
+{
+	lwpid_t tid;
+	prfpregset_t *fpregset;
+
+	tid = *(lwpid_t *)arg;
+	fpregset = calloc(1, sizeof(*fpregset));
+	if (fpregset == NULL)
+		errx(1, "out of memory");
+	ptrace(PT_GETFPREGS, tid, (void *)fpregset, 0);
+
+	*sizep = sizeof(*fpregset);
+	return (fpregset);
+}
+
+static void *
+elf_note_thrmisc(void *arg, size_t *sizep)
+{
+	lwpid_t tid;
+	struct ptrace_lwpinfo lwpinfo;
+	thrmisc_t *thrmisc;
+
+	tid = *(lwpid_t *)arg;
+	thrmisc = calloc(1, sizeof(*thrmisc));
+	if (thrmisc == NULL)
+		errx(1, "out of memory");
+	ptrace(PT_LWPINFO, tid, (void *)&lwpinfo,
+	    sizeof(lwpinfo));
+	memset(&thrmisc->_pad, 0, sizeof(thrmisc->_pad));
+	strcpy(thrmisc->pr_tname, lwpinfo.pl_tdname);
+
+	*sizep = sizeof(*thrmisc);
+	return (thrmisc);
+}
+
+static void *
+procstat_sysctl(void *arg, int what, size_t structsz, size_t *sizep)
+{
+	size_t len, oldlen;
+	pid_t pid;
+	int name[4], structsize;
+	void *buf, *p;
+
+	pid = *(pid_t *)arg;
+	structsize = structsz;
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = what;
+	name[3] = pid;
+	len = 0;
+	if (sysctl(name, 4, NULL, &len, NULL, 0) == -1)
+		err(1, "kern.proc.%d.%u", what, pid);
+	buf = calloc(1, sizeof(structsize) + len * 4 / 3);
+	if (buf == NULL)
+		errx(1, "out of memory");
+	bcopy(&structsize, buf, sizeof(structsize));
+	p = (char *)buf + sizeof(structsize);
+	if (sysctl(name, 4, p, &len, NULL, 0) == -1)
+		err(1, "kern.proc.%d.%u", what, pid);
+
+	*sizep = sizeof(structsize) + len;
+	return (buf);
+}
+
+static void *
+elf_note_procstat_proc(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+	    sizeof(struct kinfo_proc), sizep));
+}
+
+static void *
+elf_note_procstat_files(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_FILEDESC,
+	    sizeof(struct kinfo_file), sizep));
+}
+
+static void *
+elf_note_procstat_vmmap(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_VMMAP,
+	    sizeof(struct kinfo_vmentry), sizep));
+}
+
+static void *
+elf_note_procstat_groups(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_GROUPS,
+	    (int)sizeof(gid_t), sizep));
+}
+
+static void *
+elf_note_procstat_umask(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_UMASK, sizeof(u_short), sizep));
+}
+
+static void *
+elf_note_procstat_osrel(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_OSREL, sizeof(int), sizep));
+}
+
+static void *
+elf_note_procstat_psstrings(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_PS_STRINGS,
+	    sizeof(vm_offset_t), sizep));
+}
+
+static void *
+elf_note_procstat_auxv(void *arg, size_t *sizep)
+{
+
+	return (procstat_sysctl(arg, KERN_PROC_AUXV,
+	    sizeof(Elf_Auxinfo), sizep));
+}
+
+static void *
+elf_note_procstat_rlimit(void *arg, size_t *sizep)
+{
+	pid_t pid;
+	size_t len;
+	int i, name[5], structsize;
+	void *buf, *p;
+
+	pid = *(pid_t *)arg;
+	structsize = sizeof(struct rlimit) * RLIM_NLIMITS;
+	buf = calloc(1, sizeof(structsize) + structsize);
+	if (buf == NULL)
+		errx(1, "out of memory");
+	bcopy(&structsize, buf, sizeof(structsize));
+	p = (char *)buf + sizeof(structsize);
+	name[0] = CTL_KERN;
+	name[1] = KERN_PROC;
+	name[2] = KERN_PROC_RLIMIT;
+	name[3] = pid;
+	len = sizeof(struct rlimit);
+	for (i = 0; i < RLIM_NLIMITS; i++) {
+		name[4] = i;
+		if (sysctl(name, 5, p, &len, NULL, 0) == -1)
+			err(1, "kern.proc.rlimit.%u", pid);
+		if (len != sizeof(struct rlimit))
+			errx(1, "kern.proc.rlimit.%u: short read", pid);
+		p += len;
+	}
+
+	*sizep = sizeof(structsize) + structsize;
+	return (buf);
 }
 
 struct dumpers elfdump = { elf_ident, elf_coredump };
 TEXT_SET(dumpset, elfdump);
Index: user/attilio/vmcontention/usr.bin/indent/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/indent/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/indent/Makefile	(revision 249699)
@@ -1,6 +1,9 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
+# $FreeBSD$
 
 PROG=	indent
 SRCS=	indent.c io.c lexi.c parse.c pr_comment.c args.c
+
+NO_WMISSING_VARIABLE_DECLARATIONS=
 
 .include 
Index: user/attilio/vmcontention/usr.bin/m4/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/m4/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/m4/Makefile	(revision 249699)
@@ -1,25 +1,25 @@
 #	$OpenBSD: Makefile,v 1.10 2002/04/26 13:13:41 espie Exp $
 # $FreeBSD$
 
 # -DEXTENDED 
 # 	if you want the paste & spaste macros.
 
 PROG=	m4
 CFLAGS+=-DEXTENDED -I${.CURDIR} -I${.CURDIR}/lib
 DPADD=	${LIBY} ${LIBL} ${LIBM}
 LDADD=	-ly -ll -lm
-# clang needs 1 while with gcc we can use 2
-#WARNS=	1
+
+NO_WMISSING_VARIABLE_DECLARATIONS=
 
 SRCS=	eval.c expr.c look.c main.c misc.c gnum4.c trace.c parser.y tokenizer.l
 .PATH: ${.CURDIR}/lib
 SRCS+=	ohash_create_entry.c ohash_delete.c ohash_do.c ohash_entries.c \
 	ohash_enum.c ohash_init.c ohash_int.h ohash_interval.c \
 	ohash_lookup_interval.c ohash_lookup_memory.c ohash_qlookup.c \
 	ohash_qlookupi.c
 
 tokenizer.o: parser.h
 
 CLEANFILES+=	parser.c parser.h tokenizer.o
 
 .include 
Index: user/attilio/vmcontention/usr.bin/mklocale/Makefile
===================================================================
--- user/attilio/vmcontention/usr.bin/mklocale/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/mklocale/Makefile	(revision 249699)
@@ -1,8 +1,10 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/7/93
 # $FreeBSD$
 
 PROG=	mklocale
 SRCS=	yacc.y lex.l y.tab.h
 CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/locale
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
Index: user/attilio/vmcontention/usr.bin/procstat/procstat.1
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat.1	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat.1	(revision 249699)
@@ -1,468 +1,470 @@
 .\"-
 .\" Copyright (c) 2007-2009 Robert N. M. Watson
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
 .\" 1. Redistributions of source code must retain the above copyright
 .\"    notice, this list of conditions and the following disclaimer.
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\"
 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 11, 2012
+.Dd April 20, 2013
 .Dt PROCSTAT 1
 .Os
 .Sh NAME
 .Nm procstat
 .Nd get detailed process information
 .Sh SYNOPSIS
 .Nm
 .Op Fl h
 .Op Fl n
 .Op Fl C
 .Op Fl w Ar interval
 .Op Fl b | c | e | f | i | j | k | l | s | t | v | x
-.Op Fl a | Ar pid ...
+.Op Fl a | Ar pid | Ar core ...
 .Sh DESCRIPTION
 The
 .Nm
 utility displays detailed information about the processes identified by the
 .Ar pid
 arguments, or if the
 .Fl a
 flag is used, all processes.
+It can also display information extracted from a process core file, if
+the core file is specified as the argument.
 .Pp
 By default, basic process statistics are printed; one of the following
 options may be specified in order to select more detailed process information
 for printing:
 .Bl -tag -width indent
 .It Fl b
 Display binary information for the process.
 .It Fl c
 Display command line arguments for the process.
 .It Fl e
 Display environment variables for the process.
 .It Fl f
 Display file descriptor information for the process.
 .It Fl i
 Display signal pending and disposition information for the process.
 .It Fl j
 Display signal pending and blocked information for the process threads.
 .It Fl k
 Display the stacks of kernel threads in the process, excluding stacks of
 threads currently running on a CPU and threads with stacks swapped to disk.
 If the flag is repeated, function offsets as well as function names are
 printed.
 .It Fl l
 Display resource limits for the process.
 .It Fl s
 Display security credential information for the process.
 .It Fl t
 Display thread information for the process.
 .It Fl v
 Display virtual memory mappings for the process.
 .It Fl x
 Display ELF auxiliary vector for the process.
 .El
 .Pp
 All options generate output in the format of a table, the first field of
 which is the process ID to which the row of information corresponds.
 The
 .Fl h
 flag may be used to suppress table headers.
 .Pp
 The
 .Fl w
 flag may be used to specify a wait interval at which to repeat the printing
 of the requested process information.
 If the
 .Fl w
 flag is not specified, the output will not repeat.
 .Pp
 The
 .Fl C
 flag requests the printing of additional capability information in the file
 descriptor view.
 .Pp
 Some information, such as VM and file descriptor information, is available
 only to the owner of a process or the superuser.
 .Ss Binary Information
 Display the process ID, command, and path to the process binary:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It COMM
 command
 .It OSREL
 osreldate for process binary
 .It PATH
 path to process binary (if available)
 .El
 .Ss Command Line Arguments
 Display the process ID, command, and command line arguments:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It COMM
 command
 .It ARGS
 command line arguments (if available)
 .El
 .Ss File Descriptors
 Display detailed information about each file descriptor referenced by a
 process, including the process ID, command, file descriptor number, and
 per-file descriptor object information, such as object type and file system
 path.
 By default, the following information will be printed:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It COMM
 command
 .It FD
 file descriptor number or cwd/root/jail
 .It T
 file descriptor type
 .It V
 vnode type
 .It FLAGS
 file descriptor flags
 .It REF
 file descriptor reference count
 .It OFFSET
 file descriptor offset
 .It PRO
 network protocol
 .It NAME
 file path or socket addresses (if available)
 .El
 .Pp
 The following file descriptor types may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It c
 crypto
 .It e
 POSIX semaphore
 .It f
 fifo
 .It h
 shared memory
 .It k
 kqueue
 .It m
 message queue
 .It p
 pipe
 .It s
 socket
 .It t
 pseudo-terminal master
 .It v
 vnode
 .El
 .Pp
 The following vnode types may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It -
 not a vnode
 .It b
 block device
 .It c
 character device
 .It d
 directory
 .It f
 fifo
 .It l
 symbolic link
 .It r
 regular file
 .It s
 socket
 .It x
 revoked device
 .El
 .Pp
 The following file descriptor flags may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It r
 read
 .It w
 write
 .It a
 append
 .It s
 async
 .It f
 fsync
 .It n
 non-blocking
 .It d
 direct I/O
 .It l
 lock held
 .It c
 descriptor is a capability
 .El
 .Pp
 If the
 .Fl C
 flag is specified, the vnode type, reference count, and offset fields will be
 omitted, and a new capabilities field will be included listing capabilities,
 as described in
 .Xr cap_new 2 ,
 present for each capability descriptor.
 .Ss Signal Disposition Information
 Display signal pending and disposition for a process:
 .Pp
 .Bl -tag -width ident -compact
 .It PID
 process ID
 .It COMM
 command
 .It SIG
 signal name
 .It FLAGS
 process signal disposition details, three symbols
 .Bl -tag -width X -compact
 .It P
 if signal is pending in the global process queue, - otherwise
 .It I
 if signal delivery disposition is SIGIGN, - otherwise
 .It C
 if signal delivery is to catch it, - otherwise
 .El
 .El
 .Pp
 If
 .Fl n
 switch is given, the signal numbers are shown instead of signal names.
 .Ss Thread Signal Information
 Display signal pending and blocked for a process threads:
 .Pp
 .Bl -tag -width ident -compact
 .It PID
 process ID
 .It COMM
 command
 .It TID
 thread ID
 .It SIG
 signal name
 .It FLAGS
 thread signal delivery status, two symbols
 .Bl -tag -width X -compact
 .It P
 if signal is pending for the thread, - otherwise
 .It B
 if signal is blocked in the thread signal mask, - if not blocked
 .El
 .El
 .Pp
 The
 .Fl n
 switch has the same effect as for the
 .Fl i
 switch, the signals numbers are shown instead of signal names.
 .Ss Kernel Thread Stacks
 Display kernel thread stacks for a process, allowing further interpretation
 of thread wait channels.
 If the
 .Fl k
 flag is repeated, function offsets, not just function names, are printed.
 .Pp
 This feature requires
 .Cd "options STACK"
 or
 .Cd "options DDB"
 to be compiled into the kernel.
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It TID
 thread ID
 .It COMM
 command
 .It TDNAME
 thread name
 .It KSTACK
 kernel thread call stack
 .El
 .Ss Security Credentials
 Display process credential information:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It COMM
 command
 .It EUID
 effective user ID
 .It RUID
 real user ID
 .It SVUID
 saved user ID
 .It EGID
 effective group ID
 .It RGID
 real group ID
 .It SVGID
 saved group ID
 .It UMASK
 file creation mode mask
 .It FLAGS
 credential flags
 .It GROUPS
 group set
 .El
 .Pp
 The following credential flags may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It C
 capability mode
 .El
 .Ss Thread Information
 Display per-thread information, including process ID, per-thread ID, name,
 CPU, and execution state:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It TID
 thread ID
 .It COMM
 command
 .It TDNAME
 thread name
 .It CPU
 current or most recent CPU run on
 .It PRI
 thread priority
 .It STATE
 thread state
 .It WCHAN
 thread wait channel
 .El
 .Ss Virtual Memory Mappings
 Display process virtual memory mappings, including addresses, mapping
 meta-data, and mapped object information:
 .Pp
 .Bl -tag -width indent -compact
 .It PID
 process ID
 .It START
 starting address of mapping
 .It END
 ending address of mapping
 .It PRT
 protection flags
 .It RES
 resident pages
 .It PRES
 private resident pages
 .It REF
 reference count
 .It SHD
 shadow page count
 .It FL
 mapping flags
 .It TP
 VM object type
 .El
 .Pp
 The following protection flags may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It r
 read
 .It w
 write
 .It x
 execute
 .El
 .Pp
 The following VM object types may be displayed:
 .Pp
 .Bl -tag -width XX -compact
 .It --
 none
 .It dd
 dead
 .It df
 default
 .It dv
 device
 .It ph
 physical
 .It sg
 scatter/gather
 .It sw
 swap
 .It vn
 vnode
 .El
 .Pp
 The following mapping flags may be displayed:
 .Pp
 .Bl -tag -width X -compact
 .It C
 copy-on-write
 .It N
 needs copy
 .It S
 one or more superpage mappings are used
 .It D
 grows down (top-down stack)
 .It U
 grows up (bottom-up stack)
 .El
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO
 .Xr fstat 1 ,
 .Xr ps 1 ,
 .Xr sockstat 1 ,
 .Xr cap_enter 2 ,
 .Xr cap_new 2 ,
 .Xr ddb 4 ,
 .Xr stack 9
 .Sh AUTHORS
 .An Robert N M Watson
 .Sh BUGS
 Some field values may include spaces, which limits the extent to which the
 output of
 .Nm
 may be mechanically parsed.
 .Pp
 The display of open file or memory mapping pathnames is implemented using the
 kernel's name cache.
 If a file system does not use the name cache, or the path to a file is not in
 the cache, a path will not be displayed.
 .Pp
 .Nm
 currently supports extracting data only from a live kernel, and not from
 kernel crash dumps.
Index: user/attilio/vmcontention/usr.bin/procstat/procstat.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat.c	(revision 249699)
@@ -1,279 +1,292 @@
 /*-
  * Copyright (c) 2007, 2011 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 static int aflag, bflag, cflag, eflag, fflag, iflag, jflag, kflag, lflag, sflag;
 static int tflag, vflag, xflag;
 int	hflag, nflag, Cflag;
 
 static void
 usage(void)
 {
 
 	fprintf(stderr, "usage: procstat [-h] [-C] [-M core] [-N system] "
 	    "[-w interval] \n");
 	fprintf(stderr, "                [-b | -c | -e | -f | -i | -j | -k | "
-	    "-l | -s | -t | -v | -x] [-a | pid ...]\n");
+	    "-l | -s | -t | -v | -x] [-a | pid | core ...]\n");
 	exit(EX_USAGE);
 }
 
 static void
 procstat(struct procstat *prstat, struct kinfo_proc *kipp)
 {
 
 	if (bflag)
-		procstat_bin(kipp);
+		procstat_bin(prstat, kipp);
 	else if (cflag)
-		procstat_args(kipp);
+		procstat_args(prstat, kipp);
 	else if (eflag)
-		procstat_env(kipp);
+		procstat_env(prstat, kipp);
 	else if (fflag)
 		procstat_files(prstat, kipp);
 	else if (iflag)
 		procstat_sigs(prstat, kipp);
 	else if (jflag)
 		procstat_threads_sigs(prstat, kipp);
 	else if (kflag)
-		procstat_kstack(kipp, kflag);
+		procstat_kstack(prstat, kipp, kflag);
 	else if (lflag)
-		procstat_rlimit(kipp);
+		procstat_rlimit(prstat, kipp);
 	else if (sflag)
-		procstat_cred(kipp);
+		procstat_cred(prstat, kipp);
 	else if (tflag)
-		procstat_threads(kipp);
+		procstat_threads(prstat, kipp);
 	else if (vflag)
-		procstat_vm(kipp);
+		procstat_vm(prstat, kipp);
 	else if (xflag)
-		procstat_auxv(kipp);
+		procstat_auxv(prstat, kipp);
 	else
 		procstat_basic(kipp);
 }
 
 /*
  * Sort processes first by pid and then tid.
  */
 static int
 kinfo_proc_compare(const void *a, const void *b)
 {
 	int i;
 
 	i = ((const struct kinfo_proc *)a)->ki_pid -
 	    ((const struct kinfo_proc *)b)->ki_pid;
 	if (i != 0)
 		return (i);
 	i = ((const struct kinfo_proc *)a)->ki_tid -
 	    ((const struct kinfo_proc *)b)->ki_tid;
 	return (i);
 }
 
 void
 kinfo_proc_sort(struct kinfo_proc *kipp, int count)
 {
 
 	qsort(kipp, count, sizeof(*kipp), kinfo_proc_compare);
 }
 
 int
 main(int argc, char *argv[])
 {
 	int ch, interval, tmp;
 	int i;
 	struct kinfo_proc *p;
-	struct procstat *prstat;
+	struct procstat *prstat, *cprstat;
 	long l;
 	pid_t pid;
 	char *dummy;
 	char *nlistf, *memf;
 	int cnt;
 
 	interval = 0;
 	memf = nlistf = NULL;
 	while ((ch = getopt(argc, argv, "CN:M:abcefijklhstvw:x")) != -1) {
 		switch (ch) {
 		case 'C':
 			Cflag++;
 			break;
 
 		case 'M':
 			memf = optarg;
 			break;
 		case 'N':
 			nlistf = optarg;
 			break;
 		case 'a':
 			aflag++;
 			break;
 
 		case 'b':
 			bflag++;
 			break;
 
 		case 'c':
 			cflag++;
 			break;
 
 		case 'e':
 			eflag++;
 			break;
 
 		case 'f':
 			fflag++;
 			break;
 
 		case 'i':
 			iflag++;
 			break;
 
 		case 'j':
 			jflag++;
 			break;
 
 		case 'k':
 			kflag++;
 			break;
 
 		case 'l':
 			lflag++;
 			break;
 
 		case 'n':
 			nflag++;
 			break;
 
 		case 'h':
 			hflag++;
 			break;
 
 		case 's':
 			sflag++;
 			break;
 
 		case 't':
 			tflag++;
 			break;
 
 		case 'v':
 			vflag++;
 			break;
 
 		case 'w':
 			l = strtol(optarg, &dummy, 10);
 			if (*dummy != '\0')
 				usage();
 			if (l < 1 || l > INT_MAX)
 				usage();
 			interval = l;
 			break;
 
 		case 'x':
 			xflag++;
 			break;
 
 		case '?':
 		default:
 			usage();
 		}
 
 	}
 	argc -= optind;
 	argv += optind;
 
 	/* We require that either 0 or 1 mode flags be set. */
 	tmp = bflag + cflag + eflag + fflag + iflag + jflag + (kflag ? 1 : 0) +
 	    lflag + sflag + tflag + vflag + xflag;
 	if (!(tmp == 0 || tmp == 1))
 		usage();
 
 	/* We allow -k to be specified up to twice, but not more. */
 	if (kflag > 2)
 		usage();
 
 	/* Must specify either the -a flag or a list of pids. */
 	if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0))
 		usage();
 
 	/* Only allow -C with -f. */
 	if (Cflag && !fflag)
 		usage();
 
 	if (memf != NULL)
 		prstat = procstat_open_kvm(nlistf, memf);
 	else
 		prstat = procstat_open_sysctl();
 	if (prstat == NULL)
 		errx(1, "procstat_open()");
 	do {
 		if (aflag) {
 			p = procstat_getprocs(prstat, KERN_PROC_PROC, 0, &cnt);
 			if (p == NULL)
 				errx(1, "procstat_getprocs()");
 			kinfo_proc_sort(p, cnt);
 			for (i = 0; i < cnt; i++) {
 				procstat(prstat, &p[i]);
 
 				/* Suppress header after first process. */
 				hflag = 1;
 			}
 			procstat_freeprocs(prstat, p);
 		}
 		for (i = 0; i < argc; i++) {
 			l = strtol(argv[i], &dummy, 10);
-			if (*dummy != '\0')
-				usage();
-			if (l < 0)
-				usage();
-			pid = l;
+			if (*dummy == '\0') {
+				if (l < 0)
+					usage();
+				pid = l;
 
-			p = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt);
-			if (p == NULL)
-				errx(1, "procstat_getprocs()");
-			if (cnt != 0)
-				procstat(prstat, p);
-			procstat_freeprocs(prstat, p);
-
+				p = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt);
+				if (p == NULL)
+					errx(1, "procstat_getprocs()");
+				if (cnt != 0)
+					procstat(prstat, p);
+				procstat_freeprocs(prstat, p);
+			} else {
+				cprstat = procstat_open_core(argv[i]);
+				if (cprstat == NULL) {
+					warnx("procstat_open()");
+					continue;
+				}
+				p = procstat_getprocs(cprstat, KERN_PROC_PID,
+				    -1, &cnt);
+				if (p == NULL)
+					errx(1, "procstat_getprocs()");
+				if (cnt != 0)
+					procstat(cprstat, p);
+				procstat_freeprocs(cprstat, p);
+				procstat_close(cprstat);
+			}
 			/* Suppress header after first process. */
 			hflag = 1;
 		}
 		if (interval)
 			sleep(interval);
 	} while (interval);
 	procstat_close(prstat);
 	exit(0);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat.h
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat.h	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat.h	(revision 249699)
@@ -1,51 +1,52 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #ifndef PROCSTAT_H
 #define	PROCSTAT_H
 
 extern int	hflag, nflag, Cflag;
 
 struct kinfo_proc;
 void	kinfo_proc_sort(struct kinfo_proc *kipp, int count);
 
-void	procstat_args(struct kinfo_proc *kipp);
-void	procstat_auxv(struct kinfo_proc *kipp);
+void	procstat_args(struct procstat *prstat, struct kinfo_proc *kipp);
+void	procstat_auxv(struct procstat *prstat, struct kinfo_proc *kipp);
 void	procstat_basic(struct kinfo_proc *kipp);
-void	procstat_bin(struct kinfo_proc *kipp);
-void	procstat_cred(struct kinfo_proc *kipp);
-void	procstat_env(struct kinfo_proc *kipp);
+void	procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp);
+void	procstat_cred(struct procstat *prstat, struct kinfo_proc *kipp);
+void	procstat_env(struct procstat *prstat, struct kinfo_proc *kipp);
 void	procstat_files(struct procstat *prstat, struct kinfo_proc *kipp);
-void	procstat_kstack(struct kinfo_proc *kipp, int kflag);
-void	procstat_rlimit(struct kinfo_proc *kipp);
+void	procstat_kstack(struct procstat *prstat, struct kinfo_proc *kipp,
+    int kflag);
+void	procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp);
 void	procstat_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
-void	procstat_threads(struct kinfo_proc *kipp);
+void	procstat_threads(struct procstat *prstat, struct kinfo_proc *kipp);
 void	procstat_threads_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
-void	procstat_vm(struct kinfo_proc *kipp);
+void	procstat_vm(struct procstat *prstat, struct kinfo_proc *kipp);
 
 #endif /* !PROCSTAT_H */
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_args.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_args.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_args.c	(revision 249699)
@@ -1,91 +1,79 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
-static char args[ARG_MAX];
-
 static void
-do_args(struct kinfo_proc *kipp, int env)
+do_args(struct procstat *procstat, struct kinfo_proc *kipp, int env)
 {
-	int error, name[4];
-	size_t len;
-	char *cp;
+	int i;
+	char **args;
 
-	if (!hflag)
+	if (!hflag) {
 		printf("%5s %-16s %-53s\n", "PID", "COMM",
 		    env ? "ENVIRONMENT" : "ARGS");
+	}
 
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
-	name[3] = kipp->ki_pid;
-	len = sizeof(args);
-	error = sysctl(name, 4, args, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH && errno != EPERM) {
-		warn("sysctl: kern.proc.%s: %d: %d", env ? "env" : "args",
-		    kipp->ki_pid, errno);
+	args = env ? procstat_getenvv(procstat, kipp, 0) :
+	    procstat_getargv(procstat, kipp, 0);
+
+	printf("%5d %-16s", kipp->ki_pid, kipp->ki_comm);
+
+	if (args == NULL) {
+		printf(" -\n");
 		return;
 	}
-	if (error < 0)
-		return;
-	if (len == 0 || strlen(args) == 0) {
-		strcpy(args, "-");
-		len = strlen(args) + 1;
-	}
 
-	printf("%5d ", kipp->ki_pid);
-	printf("%-16s ", kipp->ki_comm);
-	for (cp = args; cp < args + len; cp += strlen(cp) + 1)
-		printf("%s%s", cp != args ? " " : "", cp);
+	for (i = 0; args[i] != NULL; i++)
+		printf(" %s", args[i]);
 	printf("\n");
 }
 
 void
-procstat_args(struct kinfo_proc *kipp)
+procstat_args(struct procstat *procstat, struct kinfo_proc *kipp)
 {
-	do_args(kipp, 0);
+	do_args(procstat, kipp, 0);
 }
 
 void
-procstat_env(struct kinfo_proc *kipp)
+procstat_env(struct procstat *procstat, struct kinfo_proc *kipp)
 {
-	do_args(kipp, 1);
+	do_args(procstat, kipp, 1);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_auxv.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_auxv.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_auxv.c	(revision 249699)
@@ -1,246 +1,160 @@
 /*-
  * Copyright (c) 2011 Mikolaj Golub
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
-#define PROC_AUXV_MAX	256
-
-static Elf_Auxinfo auxv[PROC_AUXV_MAX];
-static char prefix[256];
-
-#if __ELF_WORD_SIZE == 64
-static Elf32_Auxinfo auxv32[PROC_AUXV_MAX];
-
-static const char *elf32_sv_names[] = {
-	"Linux ELF32",
-	"FreeBSD ELF32",
-};
-
-static int
-is_elf32(pid_t pid)
-{
-	int error, name[4];
-	size_t len, i;
-	static char sv_name[256];
-
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_SV_NAME;
-	name[3] = pid;
-	len = sizeof(sv_name);
-	error = sysctl(name, 4, sv_name, &len, NULL, 0);
-	if (error != 0 || len == 0)
-		return (0);
-	for (i = 0; i < sizeof(elf32_sv_names) / sizeof(*elf32_sv_names); i++) {
-		if (strncmp(sv_name, elf32_sv_names[i], sizeof(sv_name)) == 0)
-			return (1);
-	}
-	return (0);
-}
-
-static size_t
-retrieve_auxv32(pid_t pid)
-{
-	int name[4];
-	size_t len, i;
-	void *ptr;
-
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_AUXV;
-	name[3] = pid;
-	len = sizeof(auxv32);
-	if (sysctl(name, 4, auxv32, &len, NULL, 0) == -1) {
-		if (errno != ESRCH && errno != EPERM)
-			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
-		return (0);
-	}
-	for (i = 0; i < len; i++) {
-		/*
-		 * XXX: We expect that values for a_type on a 32-bit platform
-		 * are directly mapped to those on 64-bit one, which is not
-		 * necessarily true.
-		 */
-		auxv[i].a_type = auxv32[i].a_type;
-		ptr = &auxv32[i].a_un;
-		auxv[i].a_un.a_val = *((uint32_t *)ptr);
-	}
-	return (len);
-}
-#endif /* __ELF_WORD_SIZE == 64 */
-
 #define	PRINT(name, spec, val)		\
 	printf("%s %-16s " #spec "\n", prefix, #name, (val))
 #define	PRINT_UNKNOWN(type, val)	\
 	printf("%s %16ld %#lx\n", prefix, (long)type, (u_long)(val))
 
-static size_t
-retrieve_auxv(pid_t pid)
-{
-	int name[4];
-	size_t len;
-
-#if __ELF_WORD_SIZE == 64
-	if (is_elf32(pid))
-		return (retrieve_auxv32(pid));
-#endif
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_AUXV;
-	name[3] = pid;
-	len = sizeof(auxv);
-	if (sysctl(name, 4, auxv, &len, NULL, 0) == -1) {
-		if (errno != ESRCH && errno != EPERM)
-			warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
-		return (0);
-	}
-	return (len);
-}
-
 void
-procstat_auxv(struct kinfo_proc *kipp)
+procstat_auxv(struct procstat *procstat, struct kinfo_proc *kipp)
 {
-	size_t len, i;
+	Elf_Auxinfo *auxv;
+	u_int count, i;
+	static char prefix[256];
 
 	if (!hflag)
 		printf("%5s %-16s %-16s %-16s\n", "PID", "COMM", "AUXV", "VALUE");
-	len = retrieve_auxv(kipp->ki_pid);
-	if (len == 0)
+	auxv = procstat_getauxv(procstat, kipp, &count);
+	if (auxv == NULL)
 		return;
 	snprintf(prefix, sizeof(prefix), "%5d %-16s", kipp->ki_pid,
 	    kipp->ki_comm);
-	for (i = 0; i < len; i++) {
+	for (i = 0; i < count; i++) {
 		switch(auxv[i].a_type) {
 		case AT_NULL:
 			return;
 		case AT_IGNORE:
 			break;
 		case AT_EXECFD:
 			PRINT(AT_EXECFD, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_PHDR:
 			PRINT(AT_PHDR, %p, auxv[i].a_un.a_ptr);
 			break;
 		case AT_PHENT:
 			PRINT(AT_PHENT, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_PHNUM:
 			PRINT(AT_PHNUM, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_PAGESZ:
 			PRINT(AT_PAGESZ, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_BASE:
 			PRINT(AT_BASE, %p, auxv[i].a_un.a_ptr);
 			break;
 		case AT_FLAGS:
 			PRINT(AT_FLAGS, %#lx, (u_long)auxv[i].a_un.a_val);
 			break;
 		case AT_ENTRY:
 			PRINT(AT_ENTRY, %p, auxv[i].a_un.a_ptr);
 			break;
 #ifdef AT_NOTELF
 		case AT_NOTELF:
 			PRINT(AT_NOTELF, %ld, (long)auxv[i].a_un.a_val);
 			break;
 #endif
 #ifdef AT_UID
 		case AT_UID:
 			PRINT(AT_UID, %ld, (long)auxv[i].a_un.a_val);
 			break;
 #endif
 #ifdef AT_EUID
 		case AT_EUID:
 			PRINT(AT_EUID, %ld, (long)auxv[i].a_un.a_val);
 			break;
 #endif
 #ifdef AT_GID
 		case AT_GID:
 			PRINT(AT_GID, %ld, (long)auxv[i].a_un.a_val);
 			break;
 #endif
 #ifdef AT_EGID
 		case AT_EGID:
 			PRINT(AT_EGID, %ld, (long)auxv[i].a_un.a_val);
 			break;
 #endif
 		case AT_EXECPATH:
 			PRINT(AT_EXECPATH, %p, auxv[i].a_un.a_ptr);
 			break;
 		case AT_CANARY:
 			PRINT(AT_CANARY, %p, auxv[i].a_un.a_ptr);
 			break;
 		case AT_CANARYLEN:
 			PRINT(AT_CANARYLEN, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_OSRELDATE:
 			PRINT(AT_OSRELDATE, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_NCPUS:
 			PRINT(AT_NCPUS, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_PAGESIZES:
 			PRINT(AT_PAGESIZES, %p, auxv[i].a_un.a_ptr);
 			break;
 		case AT_PAGESIZESLEN:
 			PRINT(AT_PAGESIZESLEN, %ld, (long)auxv[i].a_un.a_val);
 			break;
 		case AT_STACKPROT:
 			if ((auxv[i].a_un.a_val & VM_PROT_EXECUTE) != 0)
 				PRINT(AT_STACKPROT, %s, "NONEXECUTABLE");
 			else
 				PRINT(AT_STACKPROT, %s, "EXECUTABLE");
 			break;
 #ifdef AT_TIMEKEEP
 		case AT_TIMEKEEP:
 			PRINT(AT_TIMEKEEP, %p, auxv[i].a_un.a_ptr);
 			break;
 #endif
 		default:
 			PRINT_UNKNOWN(auxv[i].a_type, auxv[i].a_un.a_val);
 			break;
 		}
 	}
 	printf("\n");
+	procstat_freeauxv(procstat, auxv);
 }
 
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_bin.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_bin.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_bin.c	(revision 249699)
@@ -1,83 +1,62 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 void
-procstat_bin(struct kinfo_proc *kipp)
+procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp)
 {
-	char pathname[PATH_MAX];
-	int error, osrel, name[4];
-	size_t len;
+	int osrel;
+	static char pathname[PATH_MAX];
 
 	if (!hflag)
 		printf("%5s %-16s %8s %s\n", "PID", "COMM", "OSREL", "PATH");
 
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_PATHNAME;
-	name[3] = kipp->ki_pid;
-
-	len = sizeof(pathname);
-	error = sysctl(name, 4, pathname, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.pathname: %d", kipp->ki_pid);
+	if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0)
 		return;
-	}
-	if (error < 0)
-		return;
-	if (len == 0 || strlen(pathname) == 0)
+	if (strlen(pathname) == 0)
 		strcpy(pathname, "-");
-
-	name[2] = KERN_PROC_OSREL;
-
-	len = sizeof(osrel);
-	error = sysctl(name, 4, &osrel, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.osrel: %d", kipp->ki_pid);
-		return;
-	}
-	if (error < 0)
+	if (procstat_getosrel(prstat, kipp, &osrel) != 0)
 		return;
 
 	printf("%5d ", kipp->ki_pid);
 	printf("%-16s ", kipp->ki_comm);
 	printf("%8d ", osrel);
 	printf("%s\n", pathname);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_cred.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_cred.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_cred.c	(revision 249699)
@@ -1,126 +1,99 @@
 /*-
  * Copyright (c) 2007-2008 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
-static const char *get_umask(struct kinfo_proc *kipp);
+static const char *get_umask(struct procstat *procstat,
+    struct kinfo_proc *kipp);
 
 void
-procstat_cred(struct kinfo_proc *kipp)
+procstat_cred(struct procstat *procstat, struct kinfo_proc *kipp)
 {
-	int i;
-	int mib[4];
-	int ngroups;
-	size_t len;
-	gid_t *groups = NULL;
+	unsigned int i, ngroups;
+	gid_t *groups;
 
 	if (!hflag)
 		printf("%5s %-16s %5s %5s %5s %5s %5s %5s %5s %5s %-15s\n",
 		    "PID", "COMM", "EUID", "RUID", "SVUID", "EGID", "RGID",
 		    "SVGID", "UMASK", "FLAGS", "GROUPS");
 
 	printf("%5d ", kipp->ki_pid);
 	printf("%-16s ", kipp->ki_comm);
 	printf("%5d ", kipp->ki_uid);
 	printf("%5d ", kipp->ki_ruid);
 	printf("%5d ", kipp->ki_svuid);
 	printf("%5d ", kipp->ki_groups[0]);
 	printf("%5d ", kipp->ki_rgid);
 	printf("%5d ", kipp->ki_svgid);
-	printf("%5s ", get_umask(kipp));
+	printf("%5s ", get_umask(procstat, kipp));
 	printf("%s", kipp->ki_cr_flags & CRED_FLAG_CAPMODE ? "C" : "-");
 	printf("     ");
 
+	groups = NULL;
 	/*
 	 * We may have too many groups to fit in kinfo_proc's statically
-	 * sized storage.  If that occurs, attempt to retrieve them via
-	 * sysctl.
+	 * sized storage.  If that occurs, attempt to retrieve them using
+	 * libprocstat.
 	 */
-	if (kipp->ki_cr_flags & KI_CRF_GRP_OVERFLOW) {
-		mib[0] = CTL_KERN;
-		mib[1] = KERN_PROC;
-		mib[2] = KERN_PROC_GROUPS;
-		mib[3] = kipp->ki_pid;
-
-		ngroups = sysconf(_SC_NGROUPS_MAX) + 1;
-		len = ngroups * sizeof(gid_t);
-		if((groups = malloc(len)) == NULL)
-			err(-1, "malloc");
-
-		if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
-			warn("sysctl: kern.proc.groups: %d "
-			    "group list truncated", kipp->ki_pid);
-			free(groups);
-			groups = NULL;
-		}
-		ngroups = len / sizeof(gid_t);
-	}
+	if (kipp->ki_cr_flags & KI_CRF_GRP_OVERFLOW)
+		groups = procstat_getgroups(procstat, kipp, &ngroups);
 	if (groups == NULL) {
 		ngroups = kipp->ki_ngroups;
 		groups = kipp->ki_groups;
 	}
 	for (i = 0; i < ngroups; i++)
 		printf("%s%d", (i > 0) ? "," : "", groups[i]);
 	if (groups != kipp->ki_groups)
-		free(groups);
+		procstat_freegroups(procstat, groups);
 
 	printf("\n");
 }
 
 static const char *
-get_umask(struct kinfo_proc *kipp)
+get_umask(struct procstat *procstat, struct kinfo_proc *kipp)
 {
-	int error;
-	int mib[4];
-	size_t len;
 	u_short fd_cmask;
 	static char umask[4];
 
-	mib[0] = CTL_KERN;
-	mib[1] = KERN_PROC;
-	mib[2] = KERN_PROC_UMASK;
-	mib[3] = kipp->ki_pid;
-	len = sizeof(fd_cmask);
-	error = sysctl(mib, 4, &fd_cmask, &len, NULL, 0);
-	if (error == 0) {
+	if (procstat_getumask(procstat, kipp, &fd_cmask) == 0) {
 		snprintf(umask, 4, "%03o", fd_cmask);
 		return (umask);
 	} else {
 		return ("-");
 	}
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_kstack.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_kstack.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_kstack.c	(revision 249699)
@@ -1,247 +1,206 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 /*
  * Walk the stack trace provided by the kernel and reduce it to what we
  * actually want to print.  This involves stripping true instruction pointers,
  * frame numbers, and carriage returns as generated by stack(9).  If -kk is
  * specified, print the function and offset, otherwise just the function.
  */
 enum trace_state { TS_FRAMENUM, TS_PC, TS_AT, TS_FUNC, TS_OFF };
 
 static enum trace_state
 kstack_nextstate(enum trace_state ts)
 {
 
 	switch (ts) {
 	case TS_FRAMENUM:
 		return (TS_PC);
 
 	case TS_PC:
 		return (TS_AT);
 
 	case TS_AT:
 		return (TS_FUNC);
 
 	case TS_FUNC:
 		return (TS_OFF);
 
 	case TS_OFF:
 		return TS_FRAMENUM;
 
 	default:
 		errx(-1, "kstack_nextstate");
 	}
 }
 
 static void
 kstack_cleanup(const char *old, char *new, int kflag)
 {
 	enum trace_state old_ts, ts;
 	const char *cp_old;
 	char *cp_new;
 
 	ts = TS_FRAMENUM;
 	for (cp_old = old, cp_new = new; *cp_old != '\0'; cp_old++) {
 		switch (*cp_old) {
 		case ' ':
 		case '\n':
 		case '+':
 			old_ts = ts;
 			ts = kstack_nextstate(old_ts);
 			if (old_ts == TS_OFF) {
 				*cp_new = ' ';
 				cp_new++;
 			}
 			if (kflag > 1 && old_ts == TS_FUNC) {
 				*cp_new = '+';
 				cp_new++;
 			}
 			continue;
 		}
 		if (ts == TS_FUNC || (kflag > 1 && ts == TS_OFF)) {
 			*cp_new = *cp_old;
 			cp_new++;
 		}
 	}
 	*cp_new = '\0';
 }
 
 /*
  * Sort threads by tid.
  */
 static int
 kinfo_kstack_compare(const void *a, const void *b)
 {
 
         return ((const struct kinfo_kstack *)a)->kkst_tid -
             ((const struct kinfo_kstack *)b)->kkst_tid;
 }
 
 static void
 kinfo_kstack_sort(struct kinfo_kstack *kkstp, int count)
 {
 
         qsort(kkstp, count, sizeof(*kkstp), kinfo_kstack_compare);
 }
 
 
 void
-procstat_kstack(struct kinfo_proc *kipp, int kflag)
+procstat_kstack(struct procstat *procstat, struct kinfo_proc *kipp, int kflag)
 {
 	struct kinfo_kstack *kkstp, *kkstp_free;
 	struct kinfo_proc *kip, *kip_free;
 	char trace[KKST_MAXLEN];
-	int error, name[4];
 	unsigned int i, j;
-	size_t kip_len, kstk_len;
+	unsigned int kip_count, kstk_count;
 
 	if (!hflag)
 		printf("%5s %6s %-16s %-16s %-29s\n", "PID", "TID", "COMM",
 		    "TDNAME", "KSTACK");
 
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_KSTACK;
-	name[3] = kipp->ki_pid;
-
-	kstk_len = 0;
-	error = sysctl(name, 4, NULL, &kstk_len, NULL, 0);
-	if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
-		warn("sysctl: kern.proc.kstack: %d", kipp->ki_pid);
-		return;
-	}
-	if (error < 0 && errno == ENOENT) {
-		warnx("sysctl: kern.proc.kstack unavailable");
-		errx(-1, "options DDB or options STACK required in kernel");
-	}
-	if (error < 0)
-		return;
-
-	kkstp = kkstp_free = malloc(kstk_len);
+	kkstp = kkstp_free = procstat_getkstack(procstat, kipp, &kstk_count);
 	if (kkstp == NULL)
-		err(-1, "malloc");
-
-	if (sysctl(name, 4, kkstp, &kstk_len, NULL, 0) < 0) {
-		warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
-		free(kkstp);
 		return;
-	}
 
 	/*
 	 * We need to re-query for thread information, so don't use *kipp.
 	 */
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
-	name[3] = kipp->ki_pid;
+	kip = kip_free = procstat_getprocs(procstat,
+	    KERN_PROC_PID | KERN_PROC_INC_THREAD, kipp->ki_pid, &kip_count);
 
-	kip_len = 0;
-	error = sysctl(name, 4, NULL, &kip_len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
+	if (kip == NULL) {
+		procstat_freekstack(procstat, kkstp_free);
 		return;
 	}
-	if (error < 0)
-		return;
 
-	kip = kip_free = malloc(kip_len);
-	if (kip == NULL)
-		err(-1, "malloc");
-
-	if (sysctl(name, 4, kip, &kip_len, NULL, 0) < 0) {
-		warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
-		free(kip);
-		return;
-	}
-
-	kinfo_kstack_sort(kkstp, kstk_len / sizeof(*kkstp));
-	for (i = 0; i < kstk_len / sizeof(*kkstp); i++) {
+	kinfo_kstack_sort(kkstp, kstk_count);
+	for (i = 0; i < kstk_count; i++) {
 		kkstp = &kkstp_free[i];
 
 		/*
 		 * Look up the specific thread using its tid so we can
 		 * display the per-thread command line.
 		 */
 		kipp = NULL;
-		for (j = 0; j < kip_len / sizeof(*kipp); j++) {
+		for (j = 0; j < kip_count; j++) {
 			kipp = &kip_free[j];
 			if (kkstp->kkst_tid == kipp->ki_tid)
 				break;
 		}
 		if (kipp == NULL)
 			continue;
 
 		printf("%5d ", kipp->ki_pid);
 		printf("%6d ", kkstp->kkst_tid);
 		printf("%-16s ", kipp->ki_comm);
 		printf("%-16s ", (strlen(kipp->ki_tdname) &&
 		    (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
 		    kipp->ki_tdname : "-");
 
 		switch (kkstp->kkst_state) {
 		case KKST_STATE_RUNNING:
 			printf("%-29s\n", "");
 			continue;
 
 		case KKST_STATE_SWAPPED:
 			printf("%-29s\n", "");
 			continue;
 
 		case KKST_STATE_STACKOK:
 			break;
 
 		default:
 			printf("%-29s\n", "");
 			continue;
 		}
 
 		/*
 		 * The kernel generates a trace with carriage returns between
 		 * entries, but for a more compact view, we convert carriage
 		 * returns to spaces.
 		 */
 		kstack_cleanup(kkstp->kkst_trace, trace, kflag);
 		printf("%-29s\n", trace);
 	}
-	free(kip_free);
-	free(kkstp_free);
+	procstat_freekstack(procstat, kkstp_free);
+	procstat_freeprocs(procstat, kip_free);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_rlimit.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_rlimit.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_rlimit.c	(revision 249699)
@@ -1,119 +1,106 @@
 /*-
  * Copyright (c) 2011 Mikolaj Golub
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 static struct {
 	const char *name;
 	const char *suffix;
 } rlimit_param[13] = {
 	{"cputime",          "sec"},
 	{"filesize",         "B  "},
 	{"datasize",         "B  "},
 	{"stacksize",        "B  "},
 	{"coredumpsize",     "B  "},
 	{"memoryuse",        "B  "},
 	{"memorylocked",     "B  "},
 	{"maxprocesses",     "   "},
 	{"openfiles",        "   "},
 	{"sbsize",           "B  "},
 	{"vmemoryuse",       "B  "},
 	{"pseudo-terminals", "   "},
 	{"swapuse",          "B  "},
 };
 
 #if RLIM_NLIMITS > 13
 #error "Resource limits have grown. Add new entries to rlimit_param[]."
 #endif
 
 static const char *
 humanize_rlimit(int indx, rlim_t limit)
 {
 	static char buf[14];
 	int scale;
 
 	if (limit == RLIM_INFINITY)
 		return ("infinity     ");
 
 	scale = humanize_number(buf, sizeof(buf) - 1, (int64_t)limit,
 	    rlimit_param[indx].suffix, HN_AUTOSCALE | HN_GETSCALE, HN_DECIMAL);
 	(void)humanize_number(buf, sizeof(buf) - 1, (int64_t)limit,
 	    rlimit_param[indx].suffix, HN_AUTOSCALE, HN_DECIMAL);
 	/* Pad with one space if there is no suffix prefix. */
 	if (scale == 0)
 		sprintf(buf + strlen(buf), " ");
 	return (buf);
 }
 
 void
-procstat_rlimit(struct kinfo_proc *kipp)
+procstat_rlimit(struct procstat *prstat, struct kinfo_proc *kipp)
 {
 	struct rlimit rlimit;
-	int error, i, name[5];
-	size_t len;
+	int i;
 
 	if (!hflag) {
 		printf("%5s %-16s %-16s %16s %16s\n",
 		    "PID", "COMM", "RLIMIT", "SOFT     ", "HARD     ");
 	}
-	len = sizeof(struct rlimit);
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_RLIMIT;
-	name[3] = kipp->ki_pid;
 	for (i = 0; i < RLIM_NLIMITS; i++) {
-		name[4] = i;
-		error = sysctl(name, 5, &rlimit, &len, NULL, 0);
-		if (error < 0 && errno != ESRCH) {
-			warn("sysctl: kern.proc.rlimit: %d", kipp->ki_pid);
+		if (procstat_getrlimit(prstat, kipp, i, &rlimit) == -1)
 			return;
-		}
-		if (error < 0 || len != sizeof(struct rlimit))
-			return;
-
 		printf("%5d %-16s %-16s ", kipp->ki_pid, kipp->ki_comm,
 		    rlimit_param[i].name);
 		printf("%16s ", humanize_rlimit(i, rlimit.rlim_cur));
 		printf("%16s\n", humanize_rlimit(i, rlimit.rlim_max));
 	}
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_sigs.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_sigs.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_sigs.c	(revision 249699)
@@ -1,144 +1,120 @@
 /*-
  * Copyright (c) 2010 Konstantin Belousov
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 static void
 procstat_print_signame(int sig)
 {
 	char name[12];
 	int i;
 
 	if (!nflag && sig < sys_nsig) {
 		strlcpy(name, sys_signame[sig], sizeof(name));
 		for (i = 0; name[i] != 0; i++)
 			name[i] = toupper(name[i]);
 		printf("%-7s ", name);
 	} else
 		printf("%-7d ", sig);
 }
 
 static void
 procstat_print_sig(const sigset_t *set, int sig, char flag)
 {
 
 	printf("%c", sigismember(set, sig) ? flag : '-');
 }
 
 void
 procstat_sigs(struct procstat *prstat __unused, struct kinfo_proc *kipp)
 {
 	int j;
 	pid_t pid;
 
 	pid = kipp->ki_pid;
 	if (!hflag)
 		printf("%5s %-16s %-7s %4s\n", "PID", "COMM", "SIG", "FLAGS");
 
 	for (j = 1; j <= _SIG_MAXSIG; j++) {
 		printf("%5d ", pid);
 		printf("%-16s ", kipp->ki_comm);
 		procstat_print_signame(j);
 		printf(" ");
 		procstat_print_sig(&kipp->ki_siglist, j, 'P');
 		procstat_print_sig(&kipp->ki_sigignore, j, 'I');
 		procstat_print_sig(&kipp->ki_sigcatch, j, 'C');
 		printf("\n");
 	}
 }
 
 void
-procstat_threads_sigs(struct procstat *prstat __unused, struct kinfo_proc *kipp)
+procstat_threads_sigs(struct procstat *procstat, struct kinfo_proc *kipp)
 {
 	struct kinfo_proc *kip;
 	pid_t pid;
-	int error, name[4], j;
-	unsigned int i;
-	size_t len;
+	int j;
+	unsigned int count, i;
 
 	pid = kipp->ki_pid;
 	if (!hflag)
 		printf("%5s %6s %-16s %-7s %4s\n", "PID", "TID", "COMM",
 		     "SIG", "FLAGS");
 
-	/*
-	 * We need to re-query for thread information, so don't use *kipp.
-	 */
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
-	name[3] = pid;
-
-	len = 0;
-	error = sysctl(name, 4, NULL, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.pid: %d", pid);
-		return;
-	}
-	if (error < 0)
-		return;
-
-	kip = malloc(len);
+	kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+	    pid, &count);
 	if (kip == NULL)
-		err(-1, "malloc");
-
-	if (sysctl(name, 4, kip, &len, NULL, 0) < 0) {
-		warn("sysctl: kern.proc.pid: %d", pid);
-		free(kip);
 		return;
-	}
-
-	kinfo_proc_sort(kip, len / sizeof(*kipp));
-	for (i = 0; i < len / sizeof(*kipp); i++) {
+	kinfo_proc_sort(kip, count);
+	for (i = 0; i < count; i++) {
 		kipp = &kip[i];
 		for (j = 1; j <= _SIG_MAXSIG; j++) {
 			printf("%5d ", pid);
 			printf("%6d ", kipp->ki_tid);
 			printf("%-16s ", kipp->ki_comm);
 			procstat_print_signame(j);
 			printf(" ");
 			procstat_print_sig(&kipp->ki_siglist, j, 'P');
 			procstat_print_sig(&kipp->ki_sigmask, j, 'B');
 			printf("\n");
 		}
 	}
-	free(kip);
+	procstat_freeprocs(procstat, kip);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_threads.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_threads.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_threads.c	(revision 249699)
@@ -1,143 +1,118 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 void
-procstat_threads(struct kinfo_proc *kipp)
+procstat_threads(struct procstat *procstat, struct kinfo_proc *kipp)
 {
 	struct kinfo_proc *kip;
-	int error, name[4];
-	unsigned int i;
+	unsigned int count, i;
 	const char *str;
-	size_t len;
 
 	if (!hflag)
 		printf("%5s %6s %-16s %-16s %2s %4s %-7s %-9s\n", "PID",
 		    "TID", "COMM", "TDNAME", "CPU", "PRI", "STATE", "WCHAN");
 
-	/*
-	 * We need to re-query for thread information, so don't use *kipp.
-	 */
-	name[0] = CTL_KERN;
-	name[1] = KERN_PROC;
-	name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
-	name[3] = kipp->ki_pid;
-
-	len = 0;
-	error = sysctl(name, 4, NULL, &len, NULL, 0);
-	if (error < 0 && errno != ESRCH) {
-		warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
-		return;
-	}
-	if (error < 0)
-		return;
-
-	kip = malloc(len);
+	kip = procstat_getprocs(procstat, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+	    kipp->ki_pid, &count);
 	if (kip == NULL)
-		err(-1, "malloc");
-
-	if (sysctl(name, 4, kip, &len, NULL, 0) < 0) {
-		warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
-		free(kip);
 		return;
-	}
-
-	kinfo_proc_sort(kip, len / sizeof(*kipp));
-	for (i = 0; i < len / sizeof(*kipp); i++) {
+	kinfo_proc_sort(kip, count);
+	for (i = 0; i < count; i++) {
 		kipp = &kip[i];
 		printf("%5d ", kipp->ki_pid);
 		printf("%6d ", kipp->ki_tid);
 		printf("%-16s ", strlen(kipp->ki_comm) ?
 		    kipp->ki_comm : "-");
 		printf("%-16s ", (strlen(kipp->ki_tdname) &&
 		    (strcmp(kipp->ki_comm, kipp->ki_tdname) != 0)) ?
 		    kipp->ki_tdname : "-");
 		if (kipp->ki_oncpu != 255)
 			printf("%3d ", kipp->ki_oncpu);
 		else if (kipp->ki_lastcpu != 255)
 			printf("%3d ", kipp->ki_lastcpu);
 		else
 			printf("%3s ", "-");
 		printf("%4d ", kipp->ki_pri.pri_level);
 		switch (kipp->ki_stat) {
 		case SRUN:
 			str = "run";
 			break;
 
 		case SSTOP:
 			str = "stop";
 			break;
 
 		case SSLEEP:
 			str = "sleep";
 			break;
 
 		case SLOCK:
 			str = "lock";
 			break;
 
 		case SWAIT:
 			str = "wait";
 			break;
 
 		case SZOMB:
 			str = "zomb";
 			break;
 
 		case SIDL:
 			str = "idle";
 			break;
 
 		default:
 			str = "??";
 			break;
 		}
 		printf("%-7s ", str);
 		if (kipp->ki_kiflag & KI_LOCKBLOCK) {
 			printf("*%-8s ", strlen(kipp->ki_lockname) ?
 			    kipp->ki_lockname : "-");
 		} else {
 			printf("%-9s ", strlen(kipp->ki_wmesg) ?
 			    kipp->ki_wmesg : "-");
 		}
 		printf("\n");
 	}
-	free(kip);
+	procstat_freeprocs(procstat, kip);
 }
Index: user/attilio/vmcontention/usr.bin/procstat/procstat_vm.c
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat/procstat_vm.c	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat/procstat_vm.c	(revision 249699)
@@ -1,112 +1,112 @@
 /*-
  * Copyright (c) 2007 Robert N. M. Watson
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * $FreeBSD$
  */
 
 #include 
 #include 
 #include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
 #include "procstat.h"
 
 void
-procstat_vm(struct kinfo_proc *kipp)
+procstat_vm(struct procstat *procstat, struct kinfo_proc *kipp)
 {
 	struct kinfo_vmentry *freep, *kve;
 	int ptrwidth;
 	int i, cnt;
 	const char *str;
 
 	ptrwidth = 2*sizeof(void *) + 2;
 	if (!hflag)
 		printf("%5s %*s %*s %3s %4s %4s %3s %3s %4s %-2s %-s\n",
 		    "PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES",
 		    "PRES", "REF", "SHD", "FL", "TP", "PATH");
 
-	freep = kinfo_getvmmap(kipp->ki_pid, &cnt);
+	freep = procstat_getvmmap(procstat, kipp, &cnt);
 	if (freep == NULL)
 		return;
 	for (i = 0; i < cnt; i++) {
 		kve = &freep[i];
 		printf("%5d ", kipp->ki_pid);
 		printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
 		printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
 		printf("%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
 		printf("%s", kve->kve_protection & KVME_PROT_WRITE ? "w" : "-");
 		printf("%s ", kve->kve_protection & KVME_PROT_EXEC ? "x" : "-");
 		printf("%4d ", kve->kve_resident);
 		printf("%4d ", kve->kve_private_resident);
 		printf("%3d ", kve->kve_ref_count);
 		printf("%3d ", kve->kve_shadow_count);
 		printf("%-1s", kve->kve_flags & KVME_FLAG_COW ? "C" : "-");
 		printf("%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" :
 		    "-");
 		printf("%-1s", kve->kve_flags & KVME_FLAG_SUPER ? "S" : "-");
 		printf("%-1s ", kve->kve_flags & KVME_FLAG_GROWS_UP ? "U" :
 		    kve->kve_flags & KVME_FLAG_GROWS_DOWN ? "D" : "-");
 		switch (kve->kve_type) {
 		case KVME_TYPE_NONE:
 			str = "--";
 			break;
 		case KVME_TYPE_DEFAULT:
 			str = "df";
 			break;
 		case KVME_TYPE_VNODE:
 			str = "vn";
 			break;
 		case KVME_TYPE_SWAP:
 			str = "sw";
 			break;
 		case KVME_TYPE_DEVICE:
 			str = "dv";
 			break;
 		case KVME_TYPE_PHYS:
 			str = "ph";
 			break;
 		case KVME_TYPE_DEAD:
 			str = "dd";
 			break;
 		case KVME_TYPE_SG:
 			str = "sg";
 			break;
 		case KVME_TYPE_UNKNOWN:
 		default:
 			str = "??";
 			break;
 		}
 		printf("%-2s ", str);
 		printf("%-s\n", kve->kve_path);
 	}
 	free(freep);
 }
Index: user/attilio/vmcontention/usr.bin/procstat
===================================================================
--- user/attilio/vmcontention/usr.bin/procstat	(revision 249698)
+++ user/attilio/vmcontention/usr.bin/procstat	(revision 249699)

Property changes on: user/attilio/vmcontention/usr.bin/procstat
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head/usr.bin/procstat:r247679-249698
Index: user/attilio/vmcontention/usr.sbin/acpi/acpidb/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/acpi/acpidb/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/acpi/acpidb/Makefile	(revision 249699)
@@ -1,75 +1,76 @@
 # $FreeBSD$
 
 PROG=	acpidb
 SRCS=	acpidb.c
 
 # components/debugger
 SRCS+=	dbcmds.c dbconvert.c dbdisply.c dbexec.c dbfileio.c	\
 	dbhistry.c dbinput.c dbmethod.c dbnames.c dbstats.c	\
 	dbutils.c dbxface.c
 
 # components/disassembler
 SRCS+=	dmbuffer.c dmdeferred.c dmnames.c dmobject.c dmopcode.c	\
 	dmresrc.c dmresrcl.c dmresrcl2.c dmresrcs.c dmutils.c	\
 	dmwalk.c
 
 # components/dispatcher
 SRCS+=	dsargs.c dscontrol.c dsfield.c dsinit.c dsmethod.c	\
 	dsmthdat.c dsobject.c dsopcode.c dsutils.c dswexec.c	\
 	dswload.c dswload2.c dswscope.c dswstate.c
 
 # components/events
 SRCS+=	evevent.c evglock.c evgpe.c evgpeblk.c evgpeinit.c	\
 	evgpeutil.c evhandler.c evmisc.c evregion.c evrgnini.c	\
 	evsci.c evxface.c evxfevnt.c evxfregn.c
 
 # components/executer
 SRCS+=	exconfig.c exconvrt.c excreate.c exdebug.c exdump.c	\
 	exfield.c exfldio.c exmisc.c exmutex.c exnames.c	\
 	exoparg1.c exoparg2.c exoparg3.c exoparg6.c exprep.c	\
 	exregion.c exresnte.c exresolv.c exresop.c exstore.c	\
 	exstoren.c exstorob.c exsystem.c exutils.c
 
 # components/hardware
 SRCS+=	hwacpi.c hwesleep.c hwgpe.c hwpci.c hwregs.c hwsleep.c	\
 	hwvalid.c hwxface.c hwxfsleep.c
 
 # components/namespace
-SRCS+=	nsaccess.c nsalloc.c nsconvert.c nsdump.c nseval.c	\
-	nsinit.c nsload.c nsnames.c nsobject.c nsparse.c	\
-	nspredef.c nsprepkg.c nsrepair.c nsrepair2.c nssearch.c	\
-	nsutils.c nswalk.c nsxfeval.c nsxfname.c nsxfobj.c
+SRCS+=	nsaccess.c nsalloc.c nsarguments.c nsconvert.c nsdump.c	\
+	nseval.c nsinit.c nsload.c nsnames.c nsobject.c		\
+	nsparse.c nspredef.c nsprepkg.c nsrepair.c nsrepair2.c	\
+	nssearch.c nsutils.c nswalk.c nsxfeval.c nsxfname.c	\
+	nsxfobj.c
 
 # components/parser
 SRCS+=	psargs.c psloop.c psobject.c psopcode.c psopinfo.c	\
 	psparse.c psscope.c pstree.c psutils.c pswalk.c		\
 	psxface.c
 
 # components/os_specific/service_layers
 SRCS+=	osunixxf.c
 
 # components/resources
 SRCS+=	rsaddr.c rscalc.c rscreate.c rsdump.c rsdumpinfo.c	\
 	rsinfo.c rsio.c rsirq.c rslist.c rsmemory.c rsmisc.c	\
 	rsserial.c rsutils.c rsxface.c
 
 # components/tables
 SRCS+=	tbfadt.c tbfind.c tbinstal.c tbutils.c tbxface.c	\
 	tbxfload.c
 
 # components/utilities
 SRCS+=	utaddress.c utalloc.c utcache.c utcopy.c utdebug.c	\
 	utdecode.c utdelete.c uteval.c utexcep.c utglobal.c	\
 	utids.c	utinit.c utlock.c utmath.c utmisc.c utmutex.c	\
 	utobject.c utosi.c utownerid.c utpredef.c utresrc.c	\
 	utstate.c utstring.c uttrack.c utxface.c utxferror.c	\
 	utxfinit.c
 
 MAN=	acpidb.8
 WARNS?=	2
 
 CFLAGS+= -DACPI_EXEC_APP -fno-strict-aliasing
 DPADD=	${LIBPTHREAD}
 LDADD=	-lpthread
 
 .include 
Index: user/attilio/vmcontention/usr.sbin/auditdistd/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/auditdistd/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/auditdistd/Makefile	(revision 249699)
@@ -1,32 +1,33 @@
 #
 # $FreeBSD$
 #
 
 OPENBSMDIR=${.CURDIR}/../../contrib/openbsm
 .PATH: ${OPENBSMDIR}/bin/auditdistd
 
 # Addition of auditdistd because otherwise generated parse.c can't find
 # auditdistd.h.  This seems like a makefile non-feature.
 CFLAGS+=-I${OPENBSMDIR} -I${OPENBSMDIR}/bin/auditdistd
 
 NO_WFORMAT=
+NO_WMISSING_VARIABLE_DECLARATIONS=
 
 PROG=	auditdistd
 SRCS=	auditdistd.c
 SRCS+=	parse.y pjdlog.c
 SRCS+=	proto.c proto_common.c proto_socketpair.c proto_tcp.c proto_tls.c
 SRCS+=	receiver.c
 SRCS+=	sandbox.c sender.c subr.c
 SRCS+=	token.l trail.c
 MAN=	auditdistd.8 auditdistd.conf.5
 
 DPADD=	${LIBL} ${LIBPTHREAD} ${LIBUTIL}
 LDADD=	-ll -lpthread -lutil
 DPADD+=	${LIBCRYPTO} ${LIBSSL}
 LDADD+=	-lcrypto -lssl
 
 YFLAGS+=-v
 
 CLEANFILES=parse.c parse.h parse.output
 
 .include 
Index: user/attilio/vmcontention/usr.sbin/bluetooth/bthidd/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/bluetooth/bthidd/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/bluetooth/bthidd/Makefile	(revision 249699)
@@ -1,16 +1,18 @@
 # $Id: Makefile,v 1.6 2006/09/07 21:36:55 max Exp $
 # $FreeBSD$
 
 PROG=		bthidd
 MAN=		bthidd.8
 #		bthidd.conf.5
 SRCS=		bthidd.c client.c hid.c kbd.c lexer.l parser.y server.c \
 		session.c
 
 CFLAGS+=	-I${.CURDIR}
 DEBUG_FLAGS=	-g
 
 DPADD=          ${LIBBLUETOOTH} ${LIBUSBHID}
 LDADD=		-lbluetooth -lusbhid
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
Index: user/attilio/vmcontention/usr.sbin/bsnmpd/modules/Makefile.inc
===================================================================
--- user/attilio/vmcontention/usr.sbin/bsnmpd/modules/Makefile.inc	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/bsnmpd/modules/Makefile.inc	(revision 249699)
@@ -1,9 +1,11 @@
 # $FreeBSD$
 
 SHLIB_MAJOR=	6
 
 MANFILTER=	sed -e 's%@MODPATH@%${LIBDIR}/%g'		\
 		    -e 's%@DEFPATH@%${DEFSDIR}/%g'		\
 		    -e 's%@MIBSPATH@%${BMIBSDIR}/%g'
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include "../Makefile.inc"
Index: user/attilio/vmcontention/usr.sbin/config/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/config/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/config/Makefile	(revision 249699)
@@ -1,21 +1,23 @@
 # 	@(#)Makefile	8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
 PROG=	config
 MAN=	config.5 config.8
 SRCS=	config.y main.c lang.l mkmakefile.c mkheaders.c \
 	mkoptions.c y.tab.h kernconf.c
 
 kernconf.c: kernconf.tmpl
 	file2c 'char kernconfstr[] = {' ',0};' < ${.CURDIR}/kernconf.tmpl > kernconf.c
 
 CFLAGS+= -I. -I${.CURDIR}
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 DPADD=	${LIBL} ${LIBSBUF}
 LDADD=	-ll -lsbuf
 
 CLEANFILES+=	kernconf.c
 
 mkmakefile.o: configvers.h
 
 .include 
Index: user/attilio/vmcontention/usr.sbin/fifolog/lib/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/fifolog/lib/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/fifolog/lib/Makefile	(revision 249699)
@@ -1,11 +1,13 @@
 # $FreeBSD$
 
 LIB=	fifolog
 INTERNALLIB=	# API not published or supported.
 
 SRCS=	fifolog_int.c fifolog_create.c fifolog_write_poll.c fifolog_reader.c
 SRCS+=	getdate.y
 
 CFLAGS+= -I${.CURDIR}
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 .include 
Index: user/attilio/vmcontention/usr.sbin/jail/Makefile
===================================================================
--- user/attilio/vmcontention/usr.sbin/jail/Makefile	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/jail/Makefile	(revision 249699)
@@ -1,24 +1,26 @@
 # $FreeBSD$
 
 .include 
 
 PROG=	jail
 MAN=	jail.8 jail.conf.5
 SRCS=	jail.c command.c config.c state.c jailp.h jaillex.l jailparse.y y.tab.h
 
 DPADD=	${LIBJAIL} ${LIBKVM} ${LIBUTIL} ${LIBL}
 LDADD=	-ljail -lkvm -lutil -ll
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 YFLAGS+=-v
 CFLAGS+=-I. -I${.CURDIR}
 
 .if ${MK_INET6_SUPPORT} != "no"
 CFLAGS+= -DINET6
 .endif
 .if ${MK_INET_SUPPORT} != "no"
 CFLAGS+= -DINET
 .endif
 
 CLEANFILES= y.output
 
 .include 
Index: user/attilio/vmcontention/usr.sbin/jail
===================================================================
--- user/attilio/vmcontention/usr.sbin/jail	(revision 249698)
+++ user/attilio/vmcontention/usr.sbin/jail	(revision 249699)

Property changes on: user/attilio/vmcontention/usr.sbin/jail
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head/usr.sbin/jail:r248869-249698
Index: user/attilio/vmcontention
===================================================================
--- user/attilio/vmcontention	(revision 249698)
+++ user/attilio/vmcontention	(revision 249699)

Property changes on: user/attilio/vmcontention
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /head:r249647-249698